Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build Qt project on Linux, but it does on windows #9296

Closed
jepessen opened this issue Dec 12, 2019 · 6 comments
Closed

Cannot build Qt project on Linux, but it does on windows #9296

jepessen opened this issue Dec 12, 2019 · 6 comments
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@jepessen
Copy link
Contributor

Describe the bug
I'm working on a CMake project. I use vcpkg for using Qt and all other libraries. The project builds correctly on windows, but I've a CMake configuration error in Linux.

This is the CMakeFiles.txt that gives me the problem:

cmake_minimum_required (VERSION 3.13.4)

project (zlaeditorgui)

message (STATUS "Building project ${PROJECT_NAME}")

set (Boost_USE_MULTITHREADED ON)
unset (Boost_INCLUDE_DIR CACHE)
unset (Boost_LIBRARY_DIRS CACHE)
set (CMAKE_INCLUDE_CURRENT_DIR ON)
set (CMAKE_AUTOMOC ON)
set (CMAKE_AUTORCC ON)

find_package (Boost COMPONENTS program_options filesystem REQUIRED)
find_package(Qt5 COMPONENTS Core Widgets Gui REQUIRED)

include_directories (${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/Serializers ${Boost_INCLUDE_DIRS})
include_directories (${CMAKE_SOURCE_DIR}/thirdparty/loginlib/src)

set (PROJECT_SRC
  main.cpp
  manyotherfiles.cpp
  )

set (PROJECT_QRC
  Resources/ZLAEditorGui.qrc
  )

add_executable (${PROJECT_NAME} ${PROJECT_SRC} ${PROJECT_QRC})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)

target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} otherlibraries Qt5::Core Qt5::Widgets Qt5::Gui)

This is the error that I've when I build.

[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/login/Projects/zla/build/vscode --config Debug --target all -- -j 1
[build] [1/12   8% :: 0.018] Automatic MOC for target zlaeditorgui
[build] [2/11  18% :: 0.396] Linking CXX executable build/Debug/bin/zlaeditorgui
[build] FAILED: build/Debug/bin/zlaeditorgui 
[build] : && /bin/g++-9  -g   src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/main.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/ProgramOptions.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/ApplicationOptions.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Application.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/SessionManager.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/MainWindow.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/MenuBar.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/SessionToolbar.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/CodeGenerationToolbar.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/StatusBar.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/ObjectModel.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/Federate.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/FederatesList.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/Tree.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/StackedEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/EmptyEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/SimpleDatatypeEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/EnumeratedDatatypeEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/ArrayDatatypeEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/StructureDatatypeEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/Unit.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/Multiplicity.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/ObjectSectionEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/ObjectNamespaceEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/DatatypeNamespaceEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/RootObjectEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/ObjectEditor.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/Gui/ObjectAttribute.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/zlaeditorgui_autogen/mocs_compilation.cpp.o src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/zlaeditorgui_autogen/S5YYZ2ZCNV/qrc_ZLAEditorGui.cpp.o  -o build/Debug/bin/zlaeditorgui  -Wl,-rpath,/home/login/Projects/zla/build/vscode/build/Debug/lib /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libboost_program_options.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libboost_filesystem.a build/Debug/lib/libxmlserializer.so /home/login/Projects/vcpkg/installed/x64-linux/lib/libQt5Core.a /home/login/Projects/vcpkg/installed/x64-linux/lib/libQt5Widgets.a /home/login/Projects/vcpkg/installed/x64-linux/lib/libQt5Gui.a build/Debug/lib/libsession.so build/Debug/lib/libast.so /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libboost_serialization.a /home/login/Projects/vcpkg/installed/x64-linux/lib/libQt5Core.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libjpeg.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libfreetyped.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libpng16d.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libz.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libbz2d.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libsqlite3.a -lpthread /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libharfbuzz.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libfreetyped.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libbz2d.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libpng16d.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libz.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libdouble-conversion.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libssl.a /home/login/Projects/vcpkg/installed/x64-linux/debug/lib/libcrypto.a -ldl -lpcre2-16_LIBRARY_DEBUG-NOTFOUND -llibpq_LIBRARY_DEBUG-NOTFOUND -lQt5ThemeSupport_LIBRARY_DEBUG-NOTFOUND -lQt5EventDispatcherSupport_LIBRARY_DEBUG-NOTFOUND -lQt5PlatformCompositorSupport_LIBRARY_DEBUG-NOTFOUND -lQt5FontDatabaseSupport_LIBRARY_DEBUG-NOTFOUND && :
[build] /usr/bin/ld: cannot find -lpcre2-16_LIBRARY_DEBUG-NOTFOUND
[build] /usr/bin/ld: cannot find -llibpq_LIBRARY_DEBUG-NOTFOUND
[build] /usr/bin/ld: cannot find -lQt5ThemeSupport_LIBRARY_DEBUG-NOTFOUND
[build] /usr/bin/ld: cannot find -lQt5EventDispatcherSupport_LIBRARY_DEBUG-NOTFOUND
[build] /usr/bin/ld: cannot find -lQt5PlatformCompositorSupport_LIBRARY_DEBUG-NOTFOUND
[build] /usr/bin/ld: cannot find -lQt5FontDatabaseSupport_LIBRARY_DEBUG-NOTFOUND
[build] collect2: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[build] Build finished with exit code 1

I've checked and, for example, both pcre2 and libpq are installed correctly using vcpkg, so I don't know where the error is.

I've also tried to use find_package with not found libraries, like Qt5FontDatabaseSupport but I cannot find them.

What I'm doing wrong?

I'm using Kubuntu 19.04

@Neumann-A
Copy link
Contributor

How does your CMake cmd line look like?

@jepessen
Copy link
Contributor Author

That output appears when I use the Visual Studio code cmake extension with following settings:

{
    "cmake.buildDirectory": "${workspaceRoot}/build/vscode",
    "cmake.configureSettings": {
      "CMAKE_TOOLCHAIN_FILE" : "~/Projects/vcpkg/scripts/buildsystems/vcpkg.cmake",
      "VCPKG_TARGET_TRIPLET": "x64-linux"
    },
    "cmakeExplorer.buildDir": "build/vscode",
    "cmakeExplorer.logpanel": true,
    "cmake.ctestArgs": [
      "--output-on-failure"
    ],
    "C_Cpp.default.includePath": [
      "/Projects/vcpkg/installed/x64-linux"
    ],
    "cmake.configureOnOpen": true,
    "cmake.parallelJobs": 1
  }

With the console command:

cmake -DVCPKG_DEFAULT_TRIPLET=x64-linux -DCMAKE_TOOLCHAIN_FILE=~/Projects/vcpkg/scripts/buildsystems/vcpkg.cmake ../../

I obtain following error

/usr/bin/ld: cannot find -llibpq
/usr/bin/ld: cannot find -llibpq_LIBRARY_RELEASE-NOTFOUND
collect2: error: ld returned 1 exit status
make[2]: *** [src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/build.make:568: build/bin/zlaeditorgui] Error 1
make[1]: *** [CMakeFiles/Makefile2:1326: src/ZLAEditorGui/CMakeFiles/zlaeditorgui.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

@janholt
Copy link
Contributor

janholt commented Dec 12, 2019

From VSCode you get cmake config with CMAKE_BUILD_TYPE=Debug
Additional libraries, like Qt5FontDatabaseSupport, are linked in share/qt5core/vcpkg-cmake-wrapper.cmake by

function(add_qt_library _target)
    foreach(_lib IN LISTS ARGN)
        find_library(${_lib}_LIBRARY_DEBUG NAMES ${_lib}d PATH_SUFFIXES debug/plugins/platforms)
        find_library(${_lib}_LIBRARY_RELEASE NAMES ${_lib} PATH_SUFFIXES plugins/platforms)
        set_property(TARGET ${_target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES
        \$<\$<NOT:\$<CONFIG:DEBUG>>:${${_lib}_LIBRARY_RELEASE}>\$<\$<CONFIG:DEBUG>:${${_lib}_LIBRARY_DEBUG}>)
    endforeach()
endfunction()

Qt5FontDatabaseSupport_LIBRARY_DEBUG-NOTFOUND comes from find_library( ... ${lib}d ...), but on Linux Qt libraries in debug folder does not get d suffix (there is only debug\lib\libQt5FontDatabaseSupport.a)

Fix for libpq: #9260, see commit Update the Wrapper to use the Postgres target

@AlvinZhangH AlvinZhangH added the category:question This issue is a question label Dec 13, 2019
@NancyLi1013 NancyLi1013 added category:port-bug The issue is with a library, which is something the port should already support and removed category:question This issue is a question labels Dec 13, 2019
@jepessen
Copy link
Contributor Author

Ok then I'll wait, thanks for taking care of this.

@NancyLi1013
Copy link
Contributor

Hi @jepessen thanks for posting this issue.
The PR #9260 has been merged.
Could you update vcpkg and try to built it again?

@NancyLi1013
Copy link
Contributor

I cannot repro on my local.
This should be fixed now. Please try to update vcpkg and rebuild this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

No branches or pull requests

5 participants