I'm tring to use CMS and cannot link libraries that i compiled on my linux. My CMakeLists.txt:
project(region_algorithm)
SET_TARGET_PROPERTIES(PROPERTIES LINKER_LANGUAGE CXX)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
INCLUDE_DIRECTORIES(
/usr/local/include/activemq-cpp-3.8.3
/usr/local/apr/include/apr-1)
link_libraries(
/usr/local/lib/libactivemq-cpp.a
/usr/local/apr/lib/libapr-1.a)
When i'm building project i got errors like:
regionalgorithmconsumer.cpp:-1: error: undefined reference to
`decaf::util::concurrent::CountDownLatch::CountDownLatch(int)'
Related
I built Open3D from source into a /home/user/custom_location/Open3D/build
I have a project with a dependency on Open3D and a CMakeLists.txt like this:
cmake_minimum_required(VERSION 3.12)
project(graph_filter)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
# Pybind11
find_package(pybind11 REQUIRED)
# OpenMP
find_package(OpenMP REQUIRED)
# Eigen
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
# Open3D
list(APPEND CMAKE_INSTALL_PREFIX "~/libraries/")
find_package(Open3D HINTS ${CMAKE_INSTALL_PREFIX}/lib/CMake)
list(APPEND Open3D_LIBRARIES dl)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Open3D_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${Open3D_EXE_LINKER_FLAGS}")
include_directories(${Open3D_INCLUDE_DIRS})
link_directories(${Open3D_LIBRARY_DIRS})
pybind11_add_module(
graph_filter
wrapper.cpp
)
target_link_libraries(graph_filter PRIVATE ${Open3D_LIBRARIES} Eigen3::Eigen OpenMP::OpenMP_CXX)
How can I link it? When I run
INSTALL_DIR=/home/user/custom_location/Open3D/build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}```
I am getting:
Could NOT find Open3D (missing: Open3D_DIR)
fatal error: Open3D/Open3D.h: No such file or directory
2 | #include <Open3D/Open3D.h>
What is more confusing is the contents of Open3D/build folder after building from source.
I just want to resolve this dependency on Open3D. Thanks for any help!!!
I'm trying to learn OpenGL from a tutorial, and I need to link SOIL2 to my project.
I tried to write my CMake like this:(all other libs are working, Cmake gets no error but I can't include SOIL2.h because of 'SOIL2.h' file not found). I'm working with Clion IDE.
cmake_minimum_required(VERSION 3.15)
project(OpenGL_Tutorial)
set(CMAKE_CXX_STANDARD 14)
add_executable(OpenGL_Tutorial main.cpp)
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
find_library(SOIL2 lib/libsoil2.a)
include_directories(
${OPENGL_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${GLFW_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}
)
target_link_libraries(OpenGL_Tutorial
${OPENGL_LIBRARY}
${GLEW_LIBRARY}
${GLFW_LIBRARIES}
${SDL2_LIBRARY}
${SOIL2_LIBRARY}
)
libsoil2.a is located in my lib directory in the project directory
(see project direcory image)
Thanks!
I am trying to compile my game project using Clion IDE but I have a problem when porting allegro 5. I get this error:
main.cpp:2:10: fatal error: 'allegro/allegro.h' file not found
#include <allegro/allegro.h>
My CMakeLists is:
cmake_minimum_required(VERSION 3.5)
project(testAllegro)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(testAllegro ${SOURCE_FILES})
INCLUDE_DIRECTORIES( /usr/local/include )
LINK_DIRECTORIES( /usr/local/lib )
file(GLOB LIBRARIES "/usr/local/Cellar/allegro/5.2.1.1_1/lib/*.dylib")
message("LIBRARIES = ${LIBRARIES}")
TARGET_LINK_LIBRARIES(testAllegro ${LIBRARIES})
Just I want to ask how can I add external Library allegro to Clion?
when you install allegro using homebrew link
use this cmake to compile clion project
cmake_minimum_required(VERSION 3.5)
project(testAllegro)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(testAllegro ${SOURCE_FILES})
INCLUDE_DIRECTORIES( /usr/local/Cellar/allegro/5.2.1.1_1/include )
LINK_DIRECTORIES( /usr/local/Cellar/allegro/5.2.1.1_1/lib )
file(GLOB LIBRARIES "/usr/local/Cellar/allegro/5.2.1.1_1/lib/*.dylib")
message("LIBRARIES = ${LIBRARIES}")
TARGET_LINK_LIBRARIES(testAllegro ${LIBRARIES})
I know how the basic Makefile for a simple project using pjsip library looks like. But what does the equivalent CMake file look like?
project(myapp)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
include (FindPkgConfig)
if (PKG_CONFIG_FOUND) # true if pkg-config works on the system
pkg_check_modules(PJSIP REQUIRED libpjproject)
endif()
include_directories(${PJSIP_INCLUDE_DIRS})
link_directories(${PJSIP_LIBRARY_DIRS})
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${PJSIP_LIBRARIES})
I'm trying to build python bindings for a library that i wrote, and i'm having some trouble getting cmake to understand that it should use the boost-python library for python 3.
Here is my cmake file:
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(Boost COMPONENTS
system
thread
python REQUIRED)
find_package(PythonLibs REQUIRED)
INCLUDE_DIRECTORIES(${PYTHON_LIBRARIES})
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ADD_LIBRARY(
pschulze SHARED
src/candidate_relation.cpp
src/schulze.cpp
src/calculate.cpp
src/candidate.cpp
src/ranking.cpp
src/userinput.cpp
python.cpp)
TARGET_LINK_LIBRARIES(pschulze ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
ADD_EXECUTABLE(
schulze
src/candidate_relation.cpp
src/schulze.cpp
src/calculate.cpp
src/candidate.cpp
src/ranking.cpp
src/userinput.cpp
src/json-spirit/json_spirit_reader.cpp
src/json-spirit/json_spirit_value.cpp
main.cpp)
TARGET_LINK_LIBRARIES(schulze ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
ADD_DEFINITIONS(-std=gnu++0x -Os)
add_subdirectory (tests)
set(CMAKE_BUILD_TYPE Debug)
And this is the linker error that I get:
Linking CXX executable schulze
CMakeFiles/schulze.dir/src/schulze.cpp.o: In function `arg_to_python':
/usr/include/boost/python/converter/builtin_converters.hpp:122: undefined reference to `PyInt_FromLong'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libboost_python.so: undefined reference to `PyString_Size'
This might do the trick :
set(Python_ADDITIONAL_VERSIONS 3.2)
find_package(Boost COMPONENTS system thread python-py32 REQUIRED)