I'am working on melodic and trying to add SDK to ROS in my ubuntu 18.04. When I was do catkin_make in command line, I got an error be like :
'/home/jenana/catkin_ws/src/Sonar/libs/GeminiComms/x86_64-linux-gnu/x64/Release/libGeminiComms.so: undefined reference to boost::re_detail_106501::cpp_regex_traits_implementation<wchar_t>::transform_primary(wchar_t const*, wchar_t const*) const' /home/jenana/catkin_ws/src/Sonar/libs/GeminiComms/x86_64-linux-gnu/x64/Release/libGeminiComms.so: undefined reference to boost::re_detail_106501::cpp_regex_traits_implementation::transform(char const*, char const*) const' /home/jenana/catkin_ws/src/Sonar/libs/GeminiComms/x86_64-linux-gnu/x64/Release/libGeminiComms.so: undefined reference to boost::re_detail_106501::cpp_regex_traits_implementation<wchar_t>::transform(wchar_t const*, wchar_t const*) const' /home/jenana/catkin_ws/src/Sonar/libs/GeminiComms/x86_64-linux-gnu/x64/Release/libGeminiComms.so: undefined reference to boost::re_detail_106501::cpp_regex_traits_implementation::transform_primary(char const*, char const*) const' collect2: error: ld returned 1 exit status Sonar/src/geminisdkconsoleapp/CMakeFiles/geminisdkconsoleapp1.dir/build.make:116: recipe for target '/home/jenana/catkin_ws/devel/lib/geminisdk/geminisdkconsoleapp1' failed make[2]: [/home/jenana/catkin_ws/devel/lib/geminisdk/geminisdkconsoleapp1] Error 1 CMakeFiles/Makefile2:1037: recipe for target 'Sonar/src/geminisdkconsoleapp/CMakeFiles/geminisdkconsoleapp1.dir/all' failed make[1]: [Sonar/src/geminisdkconsoleapp/CMakeFiles/geminisdkconsoleapp1.dir/all] Error 2 Makefile:140: recipe for target 'all' failed make: *** [all] Error 2'.
Does anyone know how to solve it ?
I've already put the boost in TARGET_LINK_LIBRARIES, but I got still an error.
I also attached my package Cmakelist file, package.xml, and my sub package Cmakelist file below:
My package Cmakelist file :
cmake_minimum_required(VERSION 3.5.1)
PROJECT(geminisdk)
if (POLICY CMP0071)
cmake_policy(SET CMP0071 OLD)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set (ARCH ARCH64)
message ( "Arch : ${ARCH}" )
set(SDK_PLATFORM_NAME x32)
find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs genmsg message_generation)
find_package(Boost REQUIRED COMPONENTS system thread filesystem)
catkin_package(
CATKIN_DEPENDS roscpp std_msgs message_runtime
DEPENDS Boost
)
INCLUDE_DIRECTORIES(
include
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
if("${ARCH}" STREQUAL "ARCH32")
set(SDK_PLATFORM_NAME x32)
elseif("${ARCH}" STREQUAL "AARCH64")
#arm arch64
set(SDK_PLATFORM_NAME aarch64)
else()
set(SDK_PLATFORM_NAME x64)
endif()
if( "${CMAKE_BUILD_TYPE}" STREQUAL "" )
set(CMAKE_BUILD_TYPE Release)
endif()
if( "${_LOW_PERFORMANCE_CPU_}" STREQUAL "1" )
add_definitions(-D_LOW_PERFORMANCE_CPU_)
endif()
if( "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" )
set(STATIC_LIB_PREFIX "")
set(DYNAMIC_LIB_SUFFIX lib)
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC )
add_definitions(-D_WIN32_WINNT=0x0601 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
endif()
Set( LIB_ARCHITECTURE ${CMAKE_SYSTEM_NAME})
else()
set(STATIC_LIB_PREFIX lib)
set(DYNAMIC_LIB_SUFFIX so)
if( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7at2hf-neon-angstrom" )
Set (CMAKE_CXX_LIBRARY_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR} )
endif()
if( "${CMAKE_CXX_LIBRARY_ARCHITECTURE}" STREQUAL "" )
set(CMAKE_CXX_LIBRARY_ARCHITECTURE ${CMAKE_SYSTEM_NAME})
endif()
Set( LIB_ARCHITECTURE ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#set( SYSTEM_LIBRARIES "-lrt -lpthread")
# Enable static linking for gcc and stdc++
set(CMAKE_SHARED_LINKER_FLAGS "-static-libstdc++ -static-libgcc ${CMAKE_SHARED_LINKER_FLAGS}")
set( zLIBWARPPER_LIB ${CMAKE_CURRENT_SOURCE_DIR}/libs/zLibWrapper/${LIB_ARCHITECTURE}/${SDK_PLATFORM_NAME}/${CMAKE_BUILD_TYPE}/${STATIC_LIB_PREFIX}zLibWrapper.${DYNAMIC_LIB_SUFFIX} )
endif()
set( GEMINI_COMMS_LIB ${CMAKE_CURRENT_SOURCE_DIR}/libs/GeminiComms/${LIB_ARCHITECTURE}/${SDK_PLATFORM_NAME}/${CMAKE_BUILD_TYPE}/${STATIC_LIB_PREFIX}GeminiComms.${DYNAMIC_LIB_SUFFIX} )
set( SVS5_LIB ${CMAKE_CURRENT_SOURCE_DIR}/libs/Svs5SeqLib/${LIB_ARCHITECTURE}/${SDK_PLATFORM_NAME}/${CMAKE_BUILD_TYPE}/${STATIC_LIB_PREFIX}Svs5SeqLib.${DYNAMIC_LIB_SUFFIX} )
set( GNS_SERIALIZER_LIB ${CMAKE_CURRENT_SOURCE_DIR}/libs/GenesisSerializer/${LIB_ARCHITECTURE}/${SDK_PLATFORM_NAME}/${CMAKE_BUILD_TYPE}/${STATIC_LIB_PREFIX}GenesisSerializer.${DYNAMIC_LIB_SUFFIX} )
add_subdirectory (src/geminisdkconsoleapp)
Set( EXPORT_EXE_FILES
${CMAKE_CURRENT_BINARY_DIR}/src/geminisdkconsoleapp/geminisdkconsoleapp1
)
This is my package.xml file:
<?xml version="1.0"?>
<package format="2">
<name>geminisdk</name>
<version>0.0.0</version>
<description>The geminisdk package</description>
<maintainer email="jungde#todo.todo">jungde</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>Boost</build_depend>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<export>
</export>
</package>
This is my sub package Cmakelist file :
PROJECT(geminisdkconsoleapp)
add_executable(geminisdkconsoleapp1 GeminiSDKConsole1.cpp)
TARGET_LINK_LIBRARIES(geminisdkconsoleapp1
${GNS_SERIALIZER_LIB}
${zLIBWARPPER_LIB}
${SVS5_LIB}
${GEMINI_COMMS_LIB}
${SYSTEM_LIBRARIES}
${catkin_LIBRARIES}
${Boost_LIBRARY}
)
Related
The env is VTK-8.0 ITK-5.2 QT-5.12
This error occurs when I compile this cmake file:
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(QtDICOMViewer)
find_package(VTK REQUIRED)
#find_package(VTK COMPONENTS
# vtkCommonCore
# vtkFiltersSources
# vtkGUISupportQt
# vtkIOImage
# vtkInteractionImage
# vtkFiltersCore
# vtkInfovisCore
# vtkInteractionStyle
# vtkViewsQt
# vtkCommonDataModel
# vtkCommonExecutionModel
# vtkRenderingCore
# vtkRenderingFreeType
# vtkRenderingOpenGL2
# )
include(${VTK_USE_FILE})
if("${VTK_QT_VERSION}" STREQUAL "")
message(FATAL_ERROR "VTK was not built with Qt")
endif()
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
# Set your files and resources here
set( Srcs main.cpp mainwindow.cpp)
set( Hdrs mainwindow.h )
set( MOC_Hdrs mainwindow.h )
set( UIs mainwindow.ui )
set( QRCs images.qrc )
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 COMPONENTS Widgets REQUIRED QUIET)
qt5_wrap_ui(UI_Srcs ${UIs})
qt5_add_resources(QRC_Srcs ${QRCs} )
source_group("Resources" FILES
${UIs}
${QRCs}
${EXE_ICON} # Not present
)
source_group("Generated" FILES
${UI_Srcs}
${MOC_Srcs}
${QRC_Srcs}
)
include_directories(/usr/include/gdcm-2.6)
# CMAKE_AUTOMOC in ON so the MocHdrs will be automatically wrapped.
add_executable(QtDICOMViewer MACOSX_BUNDLE ${Srcs} ${Hdrs} ${UI_Srcs} ${MOC_Hdrs} ${QRC_Srcs})
qt5_use_modules(QtDICOMViewer Core Gui Widgets)
target_link_libraries(QtDICOMViewer ${VTK_LIBRARIES} ${ITK_LIBRARIES})
And the error is:
undefined reference to 'QVTKWidget::QVTKWidget' in ui.mainwindow.h:xxx
There is no LINK errors and any include fault, just can't detect this variable. I'm struggling in it all day:( But when I compile the example in VTK/Examples, nothing fails. The example CMakeLists is:
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(QtVTKRenderWindows)
find_package(VTK COMPONENTS
vtkCommonCore
vtkFiltersSources
vtkGUISupportQt
vtkIOImage
vtkInteractionImage
vtkFiltersCore
vtkInfovisCore
vtkInteractionStyle
vtkViewsQt
)
include(${VTK_USE_FILE})
if("${VTK_QT_VERSION}" STREQUAL "")
message(FATAL_ERROR "VTK was not built with Qt")
endif()
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
# Set your files and resources here
set( Srcs QtVTKRenderWindowsApp.cxx QtVTKRenderWindows.cxx)
set( Hdrs QtVTKRenderWindows.h)
set( MOC_Hdrs QtVTKRenderWindows.h)
#set( UIs QtVTKRenderWindows.ui )
set( QRCs Icons/icons.qrc )
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 COMPONENTS Widgets REQUIRED QUIET)
#qt5_wrap_ui(UI_Srcs ${UIs})
qt5_add_resources(QRC_Srcs ${QRCs} )
source_group("Resources" FILES
${UIs}
${QRCs}
${EXE_ICON} # Not present
)
source_group("Generated" FILES
${UI_Srcs}
${MOC_Srcs}
${QRC_Srcs}
)
# CMAKE_AUTOMOC in ON so the MocHdrs will be automatically wrapped.
add_executable(QtVTKRenderWindows MACOSX_BUNDLE ${Srcs} ${Hdrs} ${UI_Srcs} ${MOC_Hdrs} ${QRC_Srcs})
qt5_use_modules(QtVTKRenderWindows Core Gui Widgets)
target_link_libraries(QtVTKRenderWindows ${VTK_LIBRARIES})
I can't find there is any difference between them. So is there any probability that the code resulting in this error?
You have to link your program to the library vtkGUISupportQt-7.1
In my case, I am in ubuntu 20.04 and that library is located in /usr/lib/x86_64-linux-gnu/libvtkGUISupportQt-7.1.so
you can get it installing the apt package: libvtk7-qt-dev
apt-get install libvtk7-qt-dev
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.
I'm trying to add sound and music to my openGL project. I'm using Cmake. I get undefined reference errors and have tried for days using many methods and suggestions I've read about, but I am over my head apparently.
I have installed the libraries that I think are needed, I have configured and make installed, tried, finding the packages, added module code to help facilitate it. I am somewhat aware not all of these methods are likely useful in my case. Or maybe I need to have these libraries in my project folder and on my system ...installed. Ok, not super clear about that. I am using Ubuntu Linux with codeblocks to edit my scripts, but not to compile.
My cmakelists.text
cmake_minimum_required (VERSION 3.0)
project (maficengine LANGUAGES C CXX ASM)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/external/")
find_package(OpenGL REQUIRED)
#FIND_PACKAGE(SDL2_MIXER)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
#target_link_libraries(maficengine ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
find_file(SDL2_INCLUDE_DIR NAME SDL.h HINTS SDL2)
find_library(SDL2_LIBRARY NAME SDL2)
set(SDL2_INCLUDE_DIR /usr/include/SDL2)
set(SDL2_LIBRARY /usr/lib/x86_64-linux-gnu/libSDL2.so)
#file(GLOB_RECURSE SOURCE_FILES/usr/lib/x86_64-linux-gnu
# ${CMAKE_SOURCE_DIR}/src/*.c
# ${CMAKE_SOURCE_DIR}/src/*.cpp)
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL REQUIRED sdl)
set(SDL_INCLUDE_DIR "/usr/include/SDL2")
set(SDL_LIBRARY "SDL2")
include(FindSDL)
if(SDL_FOUND)
message(STATUS "SDL FOUND")
elseif(!SDL_FOUND)
message(STATUS "SDL not FOUND")
endif()
find_library(SDL_MIXER_LIBRARY
NAMES SDL2_mixer
HINTS
ENV SDLMIXERDIR
ENV SDLDIR
PATH_SUFFIXES lib
)
if( CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR )
message( FATAL_ERROR "Please select another Build Directory ! (and give it a clever name, like bin_Visual2012_64bits/)" )
endif()
if( CMAKE_SOURCE_DIR MATCHES " " )
message( "Your Source Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
if( CMAKE_BINARY_DIR MATCHES " " )
message( "Your Build Directory contains spaces. If you experience problems when compiling, this can be the cause." )
endif()
file(GLOB SOURCES "external/myCustomHeaders/*.cpp")
add_library(loaders SHARED ${SOURCES}
${SDL2_INCLUDE_DIR}
external/SDL2_image-2.0.4/SDL_image.h
external/myCustomHeaders/include/loadTexture.h
external/myCustomHeaders/loadTexture.cpp
/usr/include/SDL2/SDL.h
/usr/include/SDL/SDL_image.h
external/SDL2_mixer-2.0.4/SDL_mixer.h
)
include_directories( external/myCustomHeaders/include )
include_directories( external/SDL2_mixer-2.0.4/acinclude )
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}external/SDL2_mixer-2.0.4 )
include_directories(/usr/include/SDL2)
include_directories(/usr/include/SDL)
include_directories(${SDL2_INCLUDE_DIRS})
include(FindPackageHandleStandardArgs)
find_path(
SDL_MIXER_INCLUDE_DIR
PATHS
/usr/include/SDL
/usr/include/SDL2
/usr/include
/usr/local/include
/sw/include
/opt/local/include
${SDL_MIXER_ROOT_DIR}/include
DOC "The directory where SDL_mixer.h resides")
link_directories(external/myCustomHeaders/include)
link_directories(external/myCustomHeaders)
link_directories(external/SDL2_mixer-2.0.4)
link_directories(/usr/include/SDL2)
link_directories(/usr/include/SDL)
# Compile external dependencies
add_subdirectory (external)
# On Visual 2005 and above, this module can set the debug working directory
cmake_policy(SET CMP0026 OLD)
cmake_policy(SET CMP0079 NEW)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/rpavlik-cmake-modules-fe2273")
include(CreateLaunchers)
include(MSVCMultipleProcessCompile) # /MP
if(INCLUDE_DISTRIB)
add_subdirectory(distrib)
endif(INCLUDE_DISTRIB)
include_directories(
external/AntTweakBar-1.16/include/
external/glfw-3.1.2/include/
external/glm-0.9.7.1/
external/glew-1.13.0/include/
external/assimp-3.0.1270/include/
external/bullet-2.81-rev2613/src/
external/myCustomHeaders/include
common/
)
set(ALL_LIBS
${OPENGL_LIBRARY}
glfw
GLEW_1130
loaders
)
add_definitions(
-DTW_STATIC
-DTW_NO_LIB_PRAGMA
-DTW_NO_DIRECT3D
-DGLEW_STATIC
-D_CRT_SECURE_NO_WARNINGS
)
# Tutorial 17
add_executable(mageengine
${SDL2_LIBRARY}
Mafic/mafic.cpp
common/shader.cpp
common/shader.hpp
common/controls.cpp
common/controls.hpp
common/texture.cpp
common/texture.hpp
common/objloader.cpp
common/objloader.hpp
common/vboindexer.cpp
common/vboindexer.hpp
common/quaternion_utils.cpp
common/quaternion_utils.hpp
Mafic/StandardShading.vertexshader
Mafic/StandardShading.fragmentshader
)
set_target_properties(loaders
PROPERTIES LINKER_LANGUAGE CXX)
#target_sources(loaders
# PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/myCustomHeaders/loadTexture.h
# )
target_link_libraries(mageengine
${ALL_LIBS}
ANTTWEAKBAR_116_OGLCORE_GLFW
${SDL2_LIBRARIES}
loaders
)
#target_link_libraries(${maficengine } SDL2::Main SDL2::Image)
# Xcode and Visual working directories
set_target_properties(mageengine PROPERTIES XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Mafic/")
create_target_launcher(mageengine WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/Mafic/")
SOURCE_GROUP(common REGULAR_EXPRESSION ".*/common/.*" )
SOURCE_GROUP(shaders REGULAR_EXPRESSION ".*/.*shader$" )
if (NOT ${CMAKE_GENERATOR} MATCHES "Xcode" )
add_custom_command(
TARGET mageengine POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mageengine${CMAKE_EXECUTABLE_SUFFIX}" "${CMAKE_CURRENT_SOURCE_DIR}/Mafic/"
)
#target_link_libraries(mageengine LINK_PUBLIC ${mylibrary}
# )
elseif (${CMAKE_GENERATOR} MATCHES "Xcode" )
endif (NOT ${CMAKE_GENERATOR} MATCHES "Xcode" )
this is my module code that I'm using, I assume its possibly being used by cmake
# Locate SDL_image library
#
# This module defines:
#
# ::
#
# SDL2_IMAGE_LIBRARIES, the name of the library to link against
# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
# SDL2_IMAGE_FOUND, if false, do not try to link against
# SDL2_IMAGE_VERSION_STRING - human-readable string containing the version of SDL_image
#
#
#
# For backward compatibility the following variables are also set:
#
# ::
#
# SDLIMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
# SDLIMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
# SDLIMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
#
#
#
# $SDLDIR is an environment variable that would correspond to the
# ./configure --prefix=$SDLDIR used in building SDL.
#
# Created by Eric Wing. This was influenced by the FindSDL.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
HINTS
ENV SDL2IMAGEDIR
ENV SDL2DIR
PATH_SUFFIXES SDL2
# path suffixes to search inside ENV{SDLDIR}
include/SDL2 include
PATHS ${SDL2_IMAGE_PATH}
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif()
find_library(SDL2_IMAGE_LIBRARY
NAMES SDL2_image
HINTS
ENV SDL2IMAGEDIR
ENV SDL2DIR
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
PATHS ${SDL2_IMAGE_PATH}
)
if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h")
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$")
file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MAJOR "${SDL2_IMAGE_VERSION_MAJOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MINOR "${SDL2_IMAGE_VERSION_MINOR_LINE}")
string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_PATCH "${SDL2_IMAGE_VERSION_PATCH_LINE}")
set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH})
unset(SDL2_IMAGE_VERSION_MAJOR_LINE)
unset(SDL2_IMAGE_VERSION_MINOR_LINE)
unset(SDL2_IMAGE_VERSION_PATCH_LINE)
unset(SDL2_IMAGE_VERSION_MAJOR)
unset(SDL2_IMAGE_VERSION_MINOR)
unset(SDL2_IMAGE_VERSION_PATCH)
endif()
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
VERSION_VAR SDL2_IMAGE_VERSION_STRING)
# for backward compatibility
set(SDLIMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
set(SDLIMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
set(SDLIMAGE_FOUND ${SDL2_IMAGE_FOUND})
mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
My Cmake error output, I am a beginner with cmake btw, so laugh all you will.
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `load_image(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
mafic.cpp:(.text+0x2c): undefined reference to `IMG_Load'
mafic.cpp:(.text+0x43): undefined reference to `SDL_DisplayFormat'
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `init()':
mafic.cpp:(.text+0x133): undefined reference to `SDL_SetVideoMode'
mafic.cpp:(.text+0x152): undefined reference to `TTF_Init'
mafic.cpp:(.text+0x17c): undefined reference to `Mix_OpenAudio'
mafic.cpp:(.text+0x19e): undefined reference to `SDL_WM_SetCaption'
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `load_files()':
mafic.cpp:(.text+0x21c): undefined reference to `TTF_OpenFont'
mafic.cpp:(.text+0x25b): undefined reference to `Mix_LoadMUS'
mafic.cpp:(.text+0x298): undefined reference to `Mix_LoadWAV_RW'
mafic.cpp:(.text+0x2bf): undefined reference to `Mix_LoadWAV_RW'
mafic.cpp:(.text+0x2e6): undefined reference to `Mix_LoadWAV_RW'
mafic.cpp:(.text+0x30d): undefined reference to `Mix_LoadWAV_RW'
CMakeFiles/mageengine.dir/Mafic/mafic.cpp.o: In function `clean_up()':
mafic.cpp:(.text+0x3ba): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3c9): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3d8): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3e7): undefined reference to `Mix_FreeChunk'
mafic.cpp:(.text+0x3f6): undefined reference to `Mix_FreeMusic'
mafic.cpp:(.text+0x405): undefined reference to `TTF_CloseFont'
mafic.cpp:(.text+0x40a): undefined reference to `Mix_CloseAudio'
mafic.cpp:(.text+0x40f): undefined reference to `TTF_Quit'
collect2: error: ld returned 1 exit status
CMakeFiles/mageengine.dir/build.make:197: recipe for target 'mageengine' failed
make[2]: *** [mageengine] Error 1
CMakeFiles/Makefile2:75: recipe for target 'CMakeFiles/mageengine.dir/all' failed
make[1]: *** [CMakeFiles/mageengine.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Ok, I seem to have worked out the kinks. A magnitude harder than I led myself and others to believe.. - Probably did it the wrong way, but doesn't seem like many are going about it the way I am. I just went through and linked the libraries in my cmake file by doing this target_link_libraries(loaders -lSDLmain) target_link_libraries(loaders -lSDL) target_link_libraries(loaders -lSDL2_ttf) target_link_libraries(loaders -lSDL2_mixer) and downloading and istalling libs as needed. All this being said, i still have many problems, but i think it's a step closer.
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
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})