DSO Missing from command line error - c++

I tried to compile CMakeLists.txt for my project through KDevelop.
This is the output in KDevelop
/home/gopichand/Desktop/subsurface/build> make -j2
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gopichand/Desktop/subsurface/build
[ 1%] [ 2%] Automoc for target TestProfile
Automoc for target subsurface_corelib
[ 2%] [ 2%] Built target TestProfile_automoc
Built target subsurface_corelib_automoc
[ 3%] Automoc for target TestUnitConversion
[ 3%] Built target version
[ 3%] Built target TestUnitConversion_automoc
[ 3%] Built target link_marble_data
[ 4%] Automoc for target subsurface
[ 5%] Automoc for target subsurface_profile
[ 5%] Built target subsurface_automoc
[ 5%] Built target subsurface_profile_automoc
[ 6%] Automoc for target subsurface_generated_ui
[ 7%] Automoc for target subsurface_interface
[ 7%] Built target subsurface_generated_ui_automoc
[ 8%] [ 8%] Built target subsurface_interface_automoc
Automoc for target subsurface_statistics
AUTOMOC: warning: /home/gopichand/Desktop/subsurface/qt-ui/statistics/yearstatistics.cpp: file is empty
AUTOMOC: warning: /home/gopichand/Desktop/subsurface/qt-ui/statistics/statisticsbar.cpp: file is empty
AUTOMOC: warning: /home/gopichand/Desktop/subsurface/qt-ui/statistics/monthstatistics.cpp: file is empty
[ 8%] Built target subsurface_statistics_automoc
[ 26%] Built target subsurface_generated_ui
Scanning dependencies of target subsurface_corelib
[ 27%] Building C object CMakeFiles/subsurface_corelib.dir/save-git.c.o
[ 38%] Built target subsurface_profile
[ 39%] Building C object CMakeFiles/subsurface_corelib.dir/subsurfacestartup.c.o
Scanning dependencies of target subsurface_interface
[ 39%] Building CXX object CMakeFiles/subsurface_interface.dir/qt-ui/updatemanager.cpp.o
Linking CXX static library libsubsurface_corelib.a
[ 64%] Built target subsurface_corelib
[ 65%] Building CXX object CMakeFiles/subsurface_interface.dir/qt-ui/about.cpp.o
[ 66%] Building CXX object CMakeFiles/subsurface_interface.dir/qt-ui/mainwindow.cpp.o
[ 70%] Built target subsurface_statistics
[ 71%] Building CXX object CMakeFiles/subsurface_interface.dir/qt-ui/usersurvey.cpp.o
Linking CXX executable TestProfile
/usr/bin/ld: libsubsurface_corelib.a(parse-xml.c.o): undefined reference to symbol 'xmlCheckVersion##LIBXML2_2.4.30'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libxml2.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [TestProfile] Error 1
make[1]: *** [CMakeFiles/TestProfile.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX static library libsubsurface_interface.a
[ 93%] Built target subsurface_interface
make: *** [all] Error 2
*** Failure: Exit code 2 ***
I searched all DSO related posts, but could not get what went wrong.
This is the CMakeLists.txt file I compiled using KDevelop.
project(Subsurface)
cmake_minimum_required(VERSION 2.8)
#options
SET(SUBSURFACE_QT_VERSION "4")
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_MODULE_PATH ${${PROJECT_NAME}_SOURCE_DIR}/marbledata)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
endif()
INCLUDE_DIRECTORIES( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} qt-ui qt-ui/profile)
FIND_PACKAGE(PkgConfig)
MACRO(pkg_config_library LIBNAME pcfile)
pkg_check_modules(${LIBNAME} ${pcfile})
include_directories(${${LIBNAME}_INCLUDE_DIRS})
link_directories(${${LIBNAME}_LIBRARY_DIRS})
add_definitions(${${LIBNAME}_CFLAGS_OTHER})
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${${LIBNAME}_LIBRARIES})
ENDMACRO()
pkg_config_library(LIBXML libxml-2.0)
pkg_config_library(LIBSQLITE3 sqlite3)
pkg_config_library(LIBGIT2 libgit2)
pkg_config_library(LIBXSLT libxslt)
SET(LIBDCDEVEL "" CACHE STRING "libraries")
IF(NOT (LIBDCDEVEL STREQUAL ""))
cmake_policy(SET CMP0015 OLD)
include_directories(${LIBDCDEVEL}/include )
link_directories(${LIBDCDEVEL}/src/.libs)
ENDIF()
STRING(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}" "${${PROJECT_NAME}_BINARY_DIR}" insource)
GET_FILENAME_COMPONENT(PARENTDIR ${${PROJECT_NAME}_SOURCE_DIR} PATH)
STRING(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir)
IF(NOT (insource OR insourcedir))
add_custom_target(link_marble_data ALL COMMAND rm -f marbledata && ln -s ${${PROJECT_NAME}_SOURCE_DIR}/marbledata ${${PROJECT_NAME}_BINARY_DIR}/marbledata)
ENDIF()
#configure Qt version.
IF(${SUBSURFACE_QT_VERSION} MATCHES "4")
SET(QT_USE_QTNETWORK TRUE)
SET(QT_USE_QTXML TRUE)
SET(QT_USE_QTSVG TRUE)
SET(QT_USE_QTTEST TRUE)
SET(QT_USE_QTWEBKIT TRUE)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
FIND_PACKAGE(Marble REQUIRED)
INCLUDE_DIRECTORIES(${MARBLE_INCLUDE_DIR})
ELSEIF(${SUBSURFACE_QT_VERSION} MATCHES "5")
ADD_DEFINITIONS(-DNO_MARBLE)
ELSE()
message( FATAL_ERROR "Qt version should be 4 or 5" )
ENDIF()
# Generate the ssrf-config.h every 'make'
FILE(WRITE ${CMAKE_BINARY_DIR}/version.h.in "\#define VERSION_STRING \"4.1.\"#VERSION#\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/version.cmake "EXECUTE_PROCESS(
COMMAND date +\"%s\"
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
CONFIGURE_FILE(\${SRC} \${DST} #ONLY)
")
ADD_CUSTOM_TARGET(version ALL COMMAND
${CMAKE_COMMAND} -D SRC=${CMAKE_BINARY_DIR}/version.h.in
-D DST=${CMAKE_BINARY_DIR}/ssrf-version.h
-P ${CMAKE_BINARY_DIR}/version.cmake
)
# compile the core library, in C.
SET(SUBSURFACE_CORE_LIB_SRCS
cochran.c
deco.c
device.c
dive.c
divelist.c
equipment.c
file.c
libdivecomputer.c
load-git.c
membuffer.c
parse-xml.c
planner.c
profile.c
gaspressures.c
worldmap-save.c
save-git.c
save-xml.c
save-html.c
sha1.c
statistics.c
strtod.c
subsurfacestartup.c
time.c
uemis.c
uemis-downloader.c
linux.c
#gettextfrommoc should be added because we are using it on the c-code.
gettextfromc.cpp
#dirk ported some core functionality to c++.
qthelper.cpp
divecomputer.cpp
exif.cpp
subsurfacesysinfo.cpp
devicedetails.cpp
configuredivecomputer.cpp
configuredivecomputerthreads.cpp
)
#the interface, in C++
SET(SUBSURFACE_INTERFACE
qt-ui/updatemanager.cpp
qt-ui/about.cpp
qt-ui/completionmodels.cpp
qt-ui/divecomputermanagementdialog.cpp
qt-ui/divelistview.cpp
qt-ui/diveplanner.cpp
qt-ui/diveshareexportdialog.cpp
qt-ui/downloadfromdivecomputer.cpp
qt-ui/globe.cpp
qt-ui/graphicsview-common.cpp
qt-ui/kmessagewidget.cpp
qt-ui/maintab.cpp
qt-ui/mainwindow.cpp
qt-ui/modeldelegates.cpp
qt-ui/models.cpp
qt-ui/metrics.cpp
qt-ui/preferences.cpp
qt-ui/printdialog.cpp
qt-ui/printlayout.cpp
qt-ui/printoptions.cpp
qt-ui/simplewidgets.cpp
qt-ui/starwidget.cpp
qt-ui/subsurfacewebservices.cpp
qt-ui/tableview.cpp
qt-ui/divelogimportdialog.cpp
qt-ui/tagwidget.cpp
qt-ui/groupedlineedit.cpp
qt-ui/usermanual.cpp
qt-ui/divelogexportdialog.cpp
qt-ui/divepicturewidget.cpp
qt-ui/usersurvey.cpp
qt-ui/configuredivecomputerdialog.cpp
)
#the profile widget
SET(SUBSURFACE_PROFILE_LIB_SRCS
qt-ui/profile/profilewidget2.cpp
qt-ui/profile/diverectitem.cpp
qt-ui/profile/divepixmapitem.cpp
qt-ui/profile/divelineitem.cpp
qt-ui/profile/divetextitem.cpp
qt-ui/profile/animationfunctions.cpp
qt-ui/profile/divecartesianaxis.cpp
qt-ui/profile/diveplotdatamodel.cpp
qt-ui/profile/diveprofileitem.cpp
qt-ui/profile/diveeventitem.cpp
qt-ui/profile/divetooltipitem.cpp
qt-ui/profile/ruleritem.cpp
qt-ui/profile/tankitem.cpp
)
#the yearly statistics widget.
SET(SUBSURFACE_STATISTICS_LIB_SRCS
qt-ui/statistics/statisticswidget.cpp
qt-ui/statistics/yearstatistics.cpp
qt-ui/statistics/statisticsbar.cpp
qt-ui/statistics/monthstatistics.cpp
)
#the main app.
SET(SUBSURFACE_APP
main.cpp
qt-gui.cpp
qthelper.cpp
)
FILE(GLOB SUBSURFACE_UI qt-ui/*.ui)
# to be replaced by QT_WRAP_UI on CMake 3.
IF(${SUBSURFACE_QT_VERSION} MATCHES "4")
QT4_WRAP_UI( SUBSURFACE_UI_HDRS ${SUBSURFACE_UI} )
QT4_ADD_RESOURCES( SUBSURFACE_QRC_HRDS subsurface.qrc )
ELSEIF(${SUBSURFACE_QT_VERSION} MATCHES "5")
QT5_WRAP_UI( SUBSURFACE_UI_HDRS ${SUBSURFACE_UI} )
ENDIF()
ADD_LIBRARY(subsurface_corelib STATIC ${SUBSURFACE_CORE_LIB_SRCS} )
ADD_LIBRARY(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS})
ADD_LIBRARY(subsurface_statistics STATIC ${SUBSURFACE_STATISTICS_LIB_SRCS})
ADD_LIBRARY(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS})
ADD_LIBRARY(subsurface_interface STATIC ${SUBSURFACE_INTERFACE})
ADD_EXECUTABLE(subsurface ${SUBSURFACE_APP} ${SUBSURFACE_QRC_HRDS} )
target_link_libraries( subsurface
subsurface_generated_ui
subsurface_interface
subsurface_profile
subsurface_statistics
subsurface_corelib
${QT_LIBRARIES}
${MARBLE_LIBRARIES}
${SUBSURFACE_LINK_LIBRARIES}
-ldivecomputer
-lzip
)
ADD_DEPENDENCIES(subsurface_statistics subsurface_generated_ui)
ADD_DEPENDENCIES(subsurface_profile subsurface_generated_ui)
ADD_DEPENDENCIES(subsurface_interface subsurface_generated_ui)
ADD_DEPENDENCIES(subsurface_generated_ui version)
ADD_DEPENDENCIES(subsurface_corelib version)
ENABLE_TESTING()
ADD_EXECUTABLE( TestUnitConversion tests/testunitconversion.cpp )
TARGET_LINK_LIBRARIES( TestUnitConversion ${QT_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} -lzip -ldivecomputer subsurface_corelib)
ADD_TEST( NAME TestUnitConversion COMMAND TestUnitConversion)
ADD_EXECUTABLE( TestProfile tests/testprofile.cpp )
TARGET_LINK_LIBRARIES( TestProfile ${QT_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} -lzip -ldivecomputer subsurface_corelib)
ADD_TEST( NAME TestProfile COMMAND TestProfile)
Can someone please help me with this... :)

Related

LINK : fatal error LNK1104: cannot open file "libboost_json-vc142-mt-gd-x64-1_75.lib"

I am trying to build my project on Windows.
I compile with Clion. And toolchain for using it is Visual Studio 2019 x64
This is my CmakeList.txt:
cmake_minimum_required(VERSION 3.17)
project ("FB_REGULA")
set(CMAKE_CXX_STANDARD 17)
set(Boost_DEBUG 1)
set(Boost_DEBUG ON)
set(Boost_ARCHITECTURE -x64)
set(BOOST_ROOT "c:/repos/libs/boost_1_75_0")
set(BOOST_INCLUDEDIR "c:/repos/libs/boost_1_75_0")
set(BOOST_LIBRARYDIR "C:/repos/libs/boost_1_75_0/lib64-msvc-14.2")
#set(BOOST_ROOT "c:/repos/libs/boost_manual/boost_1_75_0")
#set(BOOST_INCLUDEDIR "c:/repos/libs/boost_manual/boost_1_75_0")
#set(BOOST_LIBRARYDIR "c:/repos/libs/boost_manual/boost_1_75_0/stage/x64/lib")
#[[set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")]]
find_package(Boost 1.75.0 REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
add_library(RegulaLibrary SHARED IMPORTED)
include_directories(RegulaDllDirectory "D:/Husan/projects_work/FB_REGULA/DR_SDK")
And my cmake build output :
"C:\Program Files\JetBrains\CLion
2020.3.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" D:\Husan\projects_work\FB_REGULA
-- _boost_TEST_VERSIONS = <unset>
-- Boost_USE_MULTITHREADED = "TRUE"
-- Boost_USE_STATIC_LIBS = "ON"
-- BOOST_ROOT = "c:/repos/libs/boost_1_75_0"
-- ENV{BOOST_ROOT} = "C:\repos\libs\boost_1_75_0"
-- BOOST_INCLUDEDIR = "c:/repos/libs/boost_1_75_0"
-- ENV{BOOST_INCLUDEDIR} = "C:\repos\libs\boost_1_75_0"
-- BOOST_LIBRARYDIR = "C:/repos/libs/boost_1_75_0/lib64-msvc-14.2"
-- ENV{BOOST_LIBRARYDIR} = "C:\repos\libs\boost_1_75_0\lib64-msvc-14.2"
-- location of version.hpp: C:/repos/libs/boost_1_75_0/boost/version.hpp
-- Boost_VERSION = "1.75.0"
-- Boost_VERSION_STRING = "1.75.0"
-- Boost_VERSION_MACRO = "107500"
-- Boost_VERSION_MAJOR = "1"
-- Boost_VERSION_MINOR = "75"
-- Boost_VERSION_PATCH = "0"
-- Boost_VERSION_COUNT = "3"
-- Boost_LIB_PREFIX = "lib"
-- Boost_NAMESPACE = "boost"
-- _boost_COMPILER = "-vc142;-vc141;-vc140" (guessed)
-- _boost_MULTITHREADED = "-mt"
-- _boost_ARCHITECTURE_TAG = "-x64" (user-specified via Boost_ARCHITECTURE)
-- _boost_RELEASE_ABI_TAG = "-"
-- _boost_DEBUG_ABI_TAG = "-gd"
-- _boost_LIBRARY_SEARCH_DIRS_RELEASE = "C:/repos/libs/boost_1_75_0/lib64-msvc-14.2;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
-- _boost_LIBRARY_SEARCH_DIRS_DEBUG = "C:/repos/libs/boost_1_75_0/lib64-msvc-14.2;NO_DEFAULT_PATH;NO_CMAKE_FIND_ROOT_PATH"
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Husan/projects_work/FB_REGULA/cmake-build-debug-visual-studio-x64
Please someone who can solve this is issue please answer my question.

Compilation problem on armhf with cmake on qt "Syntax error: wird unexpected (expecting ")""

recently i've been interested in qt for my work, I started a project on it and i needed to cross compile it.
On my computer, everything seems to work just fine like you can see below but on my colleague's computer I've got some errors. I've been searching for some answers but didn't find anything ...
~/work/qt/malo_zelie/armhf_build >cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: malo_zelie/armhf_build
~/work/qt/malo_zelie/armhf_build >make
Scanning dependencies of target malo_zelie_automoc
[ 16%] Automatic moc, uic and rcc for target malo_zelie
Generating moc source malo_zelie_automoc.dir/moc_mainwindow_BMDIVWC5MAP5U5.cpp
Generating moc compilation malo_zelie_automoc.cpp
Generating ui header ui_mainwindow.h
[ 16%] Built target malo_zelie_automoc
[ 33%] Generating ../malo_zelie_fr_FR.ts
Scanning directory '/home/mael/work/qt/malo_zelie'...
Updating '../malo_zelie_fr_FR.ts'...
Found 1 source text(s) (0 new and 1 already existing)
Scanning dependencies of target malo_zelie
[ 50%] Building CXX object CMakeFiles/malo_zelie.dir/src/main.cpp.o
[ 66%] Building CXX object CMakeFiles/malo_zelie.dir/src/mainwindow.cpp.o
[ 83%] Building CXX object CMakeFiles/malo_zelie.dir/malo_zelie_automoc.cpp.o
[100%] Linking CXX executable malo_zelie
[100%] Built target malo_zelie
but on my friend's computer here is what I got :
:~/workspace/malo_zelie_qt/armhf_build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: malo_zelie_qt/armhf_build
colin#debian:~/workspace/malo_zelie_qt/armhf_build$ make
[ 16%] Automatic moc, uic and rcc for target malo_zelie
Generating moc source malo_zelie_automoc.dir/moc_mainwindow_BMDIVWC5MAP5U5.cpp
/usr/lib/arm-linux-gnueabihf/qt5/bin/moc: 1: /usr/lib/arm-linux-gnueabihf/qt5/bin/moc: Syntax error: word unexpected (expecting ")")
AUTOGEN: error: process for /home/colin/workspace/malo_zelie_qt/armhf_build/malo_zelie_automoc.dir/moc_mainwindow_BMDIVWC5MAP5U5.cpp failed:
/usr/lib/arm-linux-gnueabihf/qt5/bin/moc: 1: /usr/lib/arm-linux-gnueabihf/qt5/bin/moc: Syntax error: word unexpected (expecting ")")
Generating moc compilation malo_zelie_automoc.cpp
Generating ui header ui_mainwindow.h
/usr/lib/arm-linux-gnueabihf/qt5/bin/uic: 1: /usr/lib/arm-linux-gnueabihf/qt5/bin/uic: Syntax error: word unexpected (expecting ")")
AUTOUIC: error: process for ui_mainwindow.h needed by
"/home/colin/workspace/malo_zelie_qt/src/mainwindow.cpp"
failed:
/usr/lib/arm-linux-gnueabihf/qt5/bin/uic: 1: /usr/lib/arm-linux-gnueabihf/qt5/bin/uic: Syntax error: word unexpected (expecting ")")
moc failed...
CMakeFiles/malo_zelie_automoc.dir/build.make:57 : la recette pour la cible « CMakeFiles/malo_zelie_automoc » a échouée
make[2]: [CMakeFiles/malo_zelie_automoc]
Erreur 1 CMakeFiles/Makefile2:104 : la recette pour la cible « CMakeFiles/malo_zelie_automoc.dir/all » a échouée make[1]: [CMakeFiles/malo_zelie_automoc.dir/all]
Erreur 2 Makefile:83 : la recette pour la cible « all » a échouée make: [all] Erreur 2
here is the CmakeList.txt :
cmake_minimum_required(VERSION 3.5)
project(malo_zelie LANGUAGES CXX)
set( CMAKE_PREFIX_PATH "~/Qt/5.15.0" )
option( USE_CLANG "Use Clang compiler." OFF )
option( USE_LIBCPP "Use LLVM's libc++ instead of GNU's libstdc++ (requires clang)" OFF )
option( USE_ARMHF "use armhf compiler and linker." OFF)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# They need to be set before the find_package(Qt5 ...) call.
#if(ANDROID)
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
# if (ANDROID_ABI STREQUAL "armeabi-v7a")
# set(ANDROID_EXTRA_LIBS
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
# endif()
#endif()
if( USE_ARMHF )
set( CMAKE_FIND_ROOT_PATH "/usr/lib/arm-linux-gnueabihf/")
set( COMXENTEO "ComXenteo2-armhf")
set( CMAKE_LINKER "arm-linux-gnueabihf-ld")
set( CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++" )
set( CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FMAGS} -Wno-attributes")
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3" )
set( Qt5Core_DIR "/usr/lib/arm-linux-gnueabihf/cmake/Qt5Core" )
set( Qt5Gui_DIR "/usr/lib/arm-linux-gnueabihf/cmake/Qt5Gui" )
set( Qt5LinguistTools_DIR "/usr/lib/arm-linux-gnueabihf/cmake/Qt5LinguistTools" )
set( Qt5Widgets_DIR "/usr/lib/arm-linux-gnueabihf/cmake/Qt5Widgets" )
set( Qt5_DIR "/usr/lib/arm-linux-gnueabihf/cmake/Qt5" )
else()
set( CMAKE_FIND_ROOT_PATH "/usr/lib/x86_64-linux-gnu/")
set( Qt5Core_DIR "/usr/lib/x86_64-linux-gnu/cmake/Qt5Core" )
set( Qt5Gui_DIR "/usr/lib/x86_64-linux-gnu/cmake/Qt5Gui" )
set( Qt5LinguistTools_DIR "/usr/lib/x86_64-linux-gnu/cmake/Qt5LinguistTools" )
set( Qt5Widgets_DIR "/usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets" )
set( Qt5_DIR "/usr/lib/x86_64-linux-gnu/cmake/Qt5" )
set(COMXENTEO "ComXenteo2-x64")
if( USE_CLANG )
set( CMAKE_CXX_COMPILER "clang++" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors" )
if( USE_LIBCPP )
set( ${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -stdlib=libc++" )
endif
endif()
endif()
find_package( Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
set(TS_FILES malo_zelie_fr_FR.ts)
file( GLOB malo_zelie_src "src/*.cpp" "src/*.h" "src/*.ui" )
if(ANDROID)
add_library(malo_zelie SHARED
${malo_zelie_src}
${TS_FILES}
)
else()
add_executable(malo_zelie
${malo_zelie_src}
${TS_FILES}
)
endif()
set( EXT_LIBS
# ${sga_LIBRARIES}
${COMXENTEO}
)
set( EXT_INCLUDES
# ${sga_INCLUDE_DIRS}
)
set( EXT_COMP
# ${sga_CFLAGS_OTHER}
)
target_link_libraries( malo_zelie PRIVATE Qt5::Widgets ${EXT_LIBS} )
target_include_directories( malo_zelie PUBLIC src ${EXT_INCLUDES} )
target_compile_options( malo_zelie PUBLIC ${EXT_COMP} )
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})()
does someone has any idea ? Sorry for the clumsy post, it's my first one.
Okey that was it, thanx to Frant, on my computer there was qemu installed so I could run arm binary, but on my colleague's computer, qemu wasn't installed and moc uic and rcc called are arm binary, I should change this in the future but for now I just installed qemu on his computer and everythings works just fine, thx.

How to build c++ project with make when tests fail

I'm using cmake for build configuration and gtests as testing framework.
Currently make fails if tests fail and running ctest or make test after successful build says "No tests were found!!!". I would like to be able to build project even if some tests are failing and to run tests with ctest/make test command
My CMakeLists.txt (tests added at the end of file):
cmake_minimum_required(VERSION 3.10.0)
project(ExampleProject VERSION 0.1.0)
add_subdirectory("${PROJECT_SOURCE_DIR}/src/models")
add_subdirectory("${PROJECT_SOURCE_DIR}/src/logic")
add_subdirectory("${PROJECT_SOURCE_DIR}/src/executable")
include(CTest)
enable_testing()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
################################################
# GOOGLE TEST
################################################
# Download and unpack googletest at configure time
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()
# # Now simply link against gtest or gtest_main as needed. Eg
# add_executable(example example.cpp)
# target_link_libraries(example gtest_main)
# add_test(NAME example_test COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/example)
# ################################################
include(GoogleTest)
add_executable(example example.cpp)
target_link_libraries(example gtest)
gtest_discover_tests(example)
example.cpp:
#include "gtest/gtest.h"
using namespace std;
int main()
{
testing::InitGoogleTest();
auto a = RUN_ALL_TESTS();
return a;
}
TEST(MYTEST,MYTEST1)
{
EXPECT_EQ(1,1);
}
TEST(MYTEST,MYTEST2)
{
EXPECT_EQ(2,2);
}
TEST(MYTEST3,MYTEST12)
{
EXPECT_EQ(1,1);
}
TEST(MYTEST4,MYTEST22)
{
EXPECT_EQ(2,122);
}
make output:
make
[ 16%] Built target gtest
Scanning dependencies of target example
[ 25%] Building CXX object CMakeFiles/example.dir/example.cpp.o
[ 33%] Linking CXX executable build/example
CMake Error at /usr/share/cmake-3.10/Modules/GoogleTestAddTests.cmake:39 (message):
Error running test executable.
Path: '/PathToExampleProject/build/example'
Result: 1
Output:
[==========] Running 4 tests from 3 test suites.
[----------] Global test environment set-up.
[----------] 2 tests from MYTEST
[ RUN ] MYTEST.MYTEST1
[ OK ] MYTEST.MYTEST1 (0 ms)
[ RUN ] MYTEST.MYTEST2
[ OK ] MYTEST.MYTEST2 (0 ms)
[----------] 2 tests from MYTEST (0 ms total)
[----------] 1 test from MYTEST3
[ RUN ] MYTEST3.MYTEST12
[ OK ] MYTEST3.MYTEST12 (0 ms)
[----------] 1 test from MYTEST3 (0 ms total)
[----------] 1 test from MYTEST4
[ RUN ] MYTEST4.MYTEST22
/PathToExampleProject/example.cpp:27: Failure
Expected equality of these values:
2
122
[ FAILED ] MYTEST4.MYTEST22 (0 ms)
[----------] 1 test from MYTEST4 (0 ms total)
[----------] Global test environment tear-down
[==========] 4 tests from 3 test suites ran. (0 ms total)
[ PASSED ] 3 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] MYTEST4.MYTEST22
1 FAILED TEST
CMakeFiles/example.dir/build.make:95: recipe for target 'build/example' failed
make[2]: *** [build/example] Error 1
make[2]: *** Deleting file 'build/example'
CMakeFiles/Makefile2:867: recipe for target 'CMakeFiles/example.dir/all' failed
make[1]: *** [CMakeFiles/example.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

How do you setup CMake to work with an external library (sqlpp11)?

I have gotten the two libraries necessary for my cpp application.
https://github.com/rbock/sqlpp11
https://github.com/rbock/sqlpp11-connector-mysql
I have them downloaded along with libmysqlclient-dev and the date library. All of the library tests work when I create a build dir in each of the project cmake .. and make and run make tests.
I import both the libraries in the root directory of the project using import_library(), and there are no errors with cmake .. from the build dir. When I run a make the code is unable to find the includes for <sqlpp11/sqlpp11.h> even though the cmake .. runs ok. The following is my root CMakeLists.txt and my src CMakeLists.txt.
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "${PROJECT_SOURCE_DIR}/date")
find_library(sqlpp11 REQUIRED)
include_directories(${sqlpp11_INCLUDE_DIRS})
find_library(sqlpp11-connector-mysql REQUIRED)
include_directories(${sqlpp11-connector-mysql_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
and
add_executable(mysql_sample main.cpp)
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
Edit 1
In response to the comment the error is
Maker Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Sqlpp11-connector-mysql (missing:
sqlpp11-connector-mysql_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
CMake/FindSqlpp11-connector-mysql.cmake:7 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:15 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/andrew/cpp_work/sql_sample_project/build/CMakeFiles/CMakeOutput.log".
See also "/home/andrew/cpp_work/sql_sample_project/build/CMakeFiles/CMakeError.log".
With CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "${PROJECT_SOURCE_DIR}/date")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
find_package(Sqlpp11 REQUIRED)
include_directories(${sqlpp11_INCLUDE_DIRS})
set(include_dir "${PROJECT_SOURCE_DIR}/include")
file(GLOB_RECURSE sqlpp_headers ${include_dir}/*.h ${SQLPP11_INCLUDE_DIR}/*.h)
include_directories(${include_dir})
find_package(Sqlpp11-connector-mysql REQUIRED)
include_directories(${sqlpp11-connector-mysql_INCLUDE_DIRS})
file(GLOB_RECURSE sqlpp11-connector-mysql_headers ${include_dir}/*.h ${sqlpp11-connector-mysql_INCLUDE_DIR}/*.h)
include_directories(${include_dir})
add_executable(mysql_sample src/main.cpp)
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
and FindSqlpp11.cmake
find_path(SQLPP11_INCLUDE_DIR sqlpp11.h
${PROJECT_SOURCE_DIR}/sqlpp11
${PROJECT_SOURCE_DIR}/include/sqlpp11
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sqlpp11 DEFAULT_MSG SQLPP11_INCLUDE_DIR)
mark_as_advanced(SQLPP11_INCLUDE_DIR)
and FindSqlpp11-connector-mysql.cmake
find_path(Sqlpp11-connector-mysql_INCLUDE_DIR sqlpp11-connector-mysql.h
${PROJECT_SOURCE_DIR}/sqlpp11-connector-mysql
${PROJECT_SOURCE_DIR}/include/sqlpp11-connector-mysql
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sqlpp11-connector-mysql DEFAULT_MSG sqlpp11-connector-mysql_INCLUDE_DIR)
mark_as_advanced(Sqlpp11-connector-mysql_INCLUDE_DIR)
Why is there an error here and am I on the right track?
Edit 2
I managed to get the above working, my issue was that I was not installing properly. I now get the following error from this code.
main.cpp:(.text+0x124): undefined reference to `sqlpp::mysql::connection::connection(std::shared_ptr<sqlpp::mysql::con
nection_config> const&)'
main.cpp:(.text+0x12e): undefined reference to `sqlpp::mysql::connection::~connection()'
collect2: error: ld returned 1 exit status
CMakeFiles/mysql_sample.dir/build.make:94: recipe for target 'mysql_sample' failed
make[2]: *** [mysql_sample] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/mysql_sample.dir/all' failed
make[1]: *** [CMakeFiles/mysql_sample.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Code:
include "TabSample.h"
#include <sqlpp11/sqlpp11.h>
#include <sqlpp11/mysql/mysql.h>
namespace mysql = sqlpp::mysql;
int main()
{
auto config = std::make_shared<mysql::connection_config>();
config->user = "root";
config->database = "sqlpp_mysql";
config->debug = true;
mysql::connection db(config);
TabSample tab;
for(const auto& row : db.run(sqlpp::select(all_of(tab)).from(tab).unconditionally()))
{
std::cerr << "row.alpha: " << row.alpha << ", row.beta: " << row.beta << ", row.gamma: " << row.gamma << std::endl;
};
return 0;
}
I am using gcc 4.9 and there are no errors with the make / make install, am I missing something in my CMakeLists.txt?
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "/usr/local/lib/date")
include_directories(/usr/local/lib/date)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
set(SQLPP11_INCLUDE_DIR /usr/local/include)
find_package(Sqlpp11 REQUIRED)
add_executable(mysql_sample src/main.cpp)
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(mysql_sample)
set(HinnantDate_ROOT_DIR "/usr/local/lib/date")
include_directories(/usr/local/lib/date)
set(CMAKE_CXX_STANDARD 11)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
set(SQLPP11_INCLUDE_DIR /usr/local/include)
find_package(Sqlpp11 REQUIRED)
add_executable(mysql_sample src/main.cpp)
include_directories(${sqlpp11_INCLUDE_DIRS})
include_directories(${sqlpp11-connector-mysql_INCLUDE_DIRS})
target_link_libraries(mysql_sample ${sqlpp11_LIBRARIES})
target_link_libraries(mysql_sample ${sqlpp11-connector-mysql_LIBRARIES})
target_link_libraries(mysql_sample mysqlclient)
include_directories(${PROJECT_SOURCE_DIR}/include)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(test)
FindSqlpp11-connector-mysql.cmake
## -----------------------------------------------------------------------------
## Check for the library
find_library (sqlpp11-connector-mysql-mysql_LIBRARIES sqlpp11-connector-mysql-mysql
PATHS usr/local/cmake /usr/local/cmake/sqlpp11-connector-mysql-mysql /usr/local/lib /usr/lib /lib /sw/lib /usr/local/include
)
## -----------------------------------------------------------------------------
## Actions taken when all components have been found
if (sqlpp11-connector-mysql-mysql_INCLUDES AND sqlpp11-connector-mysql-mysql_LIBRARIES)
set (HAVE_sqlpp11-connector-mysql-mysql TRUE)
else (sqlpp11-connector-mysql-mysql_INCLUDES AND sqlpp11-connector-mysql-mysql_LIBRARIES)
if (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
if (NOT sqlpp11-connector-mysql-mysql_INCLUDES)
message (STATUS "Unable to find sqlpp11-connector-mysql-mysql header files!")
endif (NOT sqlpp11-connector-mysql-mysql_INCLUDES)
if (NOT sqlpp11-connector-mysql-mysql_LIBRARIES)
message (STATUS "Unable to find sqlpp11-connector-mysql-mysql library files!")
endif (NOT sqlpp11-connector-mysql-mysql_LIBRARIES)
endif (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
endif (sqlpp11-connector-mysql-mysql_INCLUDES AND sqlpp11-connector-mysql-mysql_LIBRARIES)
if (HAVE_sqlpp11-connector-mysql-mysql)
if (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
message (STATUS "Found components for sqlpp11-connector-mysql-mysql")
message (STATUS "sqlpp11-connector-mysql-mysql_INCLUDES = ${sqlpp11-connector-mysql-mysql_INCLUDES}")
message (STATUS "sqlpp11-connector-mysql-mysql_LIBRARIES = ${sqlpp11-connector-mysql-mysql_LIBRARIES}")
endif (NOT sqlpp11-connector-mysql-mysql_FIND_QUIETLY)
else (HAVE_sqlpp11-connector-mysql-mysql)
if (sqlpp11-connector-mysql-mysql_FIND_REQUIRED)
message (FATAL_ERROR "Could not find sqlpp11-connector-mysql-mysql!")
endif (sqlpp11-connector-mysql-mysql_FIND_REQUIRED)
endif (HAVE_sqlpp11-connector-mysql-mysql)
mark_as_advanced (
HAVE_sqlpp11-connector-mysql-mysql
sqlpp11-connector-mysql-mysql_LIBRARIES
sqlpp11-connector-mysql-mysql_INCLUDES
)
and the error output:
root#beaglebone:~/cpp_work/sql_sample_project/build# cmake ..
-- Attempting to find SQLPP11 FILES
-- Unable to find SQLPP11 library files!
-- Unable to find sqlpp11-connector-mysql-mysql header files!
-- Unable to find sqlpp11-connector-mysql-mysql library files!
-- Configuring done
-- Generating done

RCC Parse Error during make with cmake and Qt4

I have a small Qt4 project which I want to build with cmake.
It has a QTcpServer and a QThread, which both include the Q_OBJECT macro.
When I'm running make I always get an RCC Parse Error after generating qrc_tcpserver.cxx.
The exact failure output is:
[ 9%] Generating qrc_tcpserver.cxx
RCC Parse Error: '/home/path/server/include/tcpserver.h' Line: 1 Column: 1 [error occurred while parsing element]
make[2]: *** [qrc_tcpserver.cxx] Fehler 1
make[1]: *** [CMakeFiles/TcpServer.dir/all] Fehler 2
make: *** [all] Fehler 2
My cmake file looks like this:
set(PROJECT_NAME TcpServer)
PROJECT(${PROJECT_NAME} )
cmake_minimum_required(VERSION 2.6)
# FOR QT4
find_package(Qt4 REQUIRED COMPONENTS QtCore QtNetwork)
SET(CMAKE_PACKAGE_QTGUI FALSE)
SET( QT_WRAP_CPP TRUE )
set(QT_USE_QTXML TRUE)
# ENABLE WARNINGS
ADD_DEFINITIONS( -Wall )
#FOR GOOGLETEST
if(test)
find_package(GTest REQUIRED)
enable_testing()
endif()
set(QT_USE_QTNETWORK TRUE)
set(INCLUDES ${PROJECT_SOURCE_DIR}/include)
set(${PROJECT_NAME}_Qt_SRC
${INCLUDES}/tcpworkerthread.h
${INCLUDES}/tcpserver.h
)
set(${PROJECT_NAME}_Qt_UI
)
set(${PROJECT_NAME}_Qt_RES
)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
IF(QT_WRAP_CPP)
MESSAGE("Wrap cpp!")
QT4_WRAP_CPP(${PROJECT_NAME}_MOC_CPP ${${PROJECT_NAME}_Qt_SRC})
ENDIF(QT_WRAP_CPP)
QT4_WRAP_UI(${PROJECT_NAME}_UI_CPP ${${PROJECT_NAME}_Qt_UI})
QT4_ADD_RESOURCES(${PROJECT_NAME}_RES_H ${${PROJECT_NAME}_Qt_SRC})
if(test)
include_directories(${GTEST_INCLUDE_DIRS} ${INCLUDES} ${QT_QTNETWORK_INCLUDE_DIR})
else()
include_directories(${INCLUDES} ${QT_QTNETWORK_INCLUDE_DIR})
endif()
if(test)
set(${PROJECT_NAME}_SRC_TEST
src_test/main.cpp
src_test/tcpservertest.cpp
src_test/tcpworkerthreadtest.cpp
)
set(PROJECT_TEST_NAME "${PROJECT_NAME}_test")
set(${PROJECT_NAME}_SRC
src/tcpserver.cpp
src/tcpworkerthread.cpp
)
else()
set(${PROJECT_NAME}_SRC
main.cpp
src/tcpserver.cpp
src/tcpworkerthread.cpp
)
endif()
set(${PROJECT_NAME}_LIB
${QT_LIBRARIES}
${QT_QTNETWORK_LIBRARIES}
)
if(test)
add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_SRC} )
add_executable(${PROJECT_TEST_NAME} ${${PROJECT_NAME}_SRC_TEST})
target_link_libraries(${PROJECT_TEST_NAME} ${PROJECT_NAME} ${${PROJECT_NAME}_LIB} ${GTEST_BOTH_LIBRARIES} pthread)
add_test(${PROJECT_TEST_NAME} ${PROJECT_TEST_NAME})
else()
add_executable( ${PROJECT_NAME} ${${PROJECT_NAME}_SRC} ${${PROJECT_NAME}_MOC_CPP} ${${PROJECT_NAME}_UI_CPP} ${${PROJECT_NAME}_RES_H})
target_link_libraries( ${PROJECT_NAME} ${${PROJECT_NAME}_LIB} )
endif()
I execute it without test variable, so this is set to false(I use it for generating gtest, which is not so important for me, just for playing around).
Any idea where my failure is?
I'm not very familar with CMake, but it seems you're feeding a wrong list of files to QT4_ADD_RESOURCES.
The line
QT4_ADD_RESOURCES(${PROJECT_NAME}_RES_H ${${PROJECT_NAME}_Qt_SRC})
should probably be
QT4_ADD_RESOURCES(${PROJECT_NAME}_RES_H ${${PROJECT_NAME}_Qt_RES})