I am compiling a google test project and the compilation is successful. However I am getting the following error during linking with my project.
Is this related to how the linking is ordered I wonder?
CMakeFiles/Test.dir/Test1.cpp.o: In function `GetTimeMock::GetTime(int*, _time_data*)':
Test1.cpp:(.text._ZN20GetTimeMock19ENET_GetTimeEPiP19_time_data[_ZN20EnetGetTimeMock19ENET_GetTimeEPiP19_time_data]+0x4a): undefined reference to `testing::internal::UntypedFunctionMockerBase::UntypedInvokeWith(void const*)'
Here is what my CMAKE looks like
make_minimum_required(VERSION 3.2.2)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
# Set compiler to c++17
#set(CMAKE_CXX_STANDARD 17)
ExternalProject_Add(
GoogleTest
URL https://github.com/google/googletest/archive/6ce9b98f541b8bcd84c5c5b3483f29a933c4aefb.zip
URL_MD5 "0bca4c8c9fc2d06634185057a905ff11"
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/external"
BUILD_COMMAND "$(MAKE)"
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -O2 -DNDEBUG -Wall -Wextra -pedantic")
set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../source)
set(UNIT_TEST_MAIN ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_test_main.cpp)
set(GTEST_MAIN ${CMAKE_BINARY_DIR}/external/lib/libgtest_main.a)
set(GTEST ${CMAKE_BINARY_DIR}/external/lib/libgtest.a)
set(GMOCK_MAIN ${CMAKE_BINARY_DIR}/external/lib/libgmock_main.a)
set(GMOCK ${CMAKE_BINARY_DIR}/external/lib/libgmock.a)
set(SOURCE
${UNIT_TEST_MAIN}
${SOURCE_PATH}test.cpp
${SOURCE_PATH}/test1.cpp
${SOURCE_PATH}/test2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bar.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bar1.cpp
${STUB_PATH}/platforms/k64f/src/fstub.cpp
)
include_directories(
${SOURCE_PATH}/include
${SOURCE_PATH}/Files
${SOURCE_PATH}/
)
set(target "Test")
add_definitions(${DEFINITION})
add_executable("${target}" ${SOURCE})
add_dependencies("${target}" GoogleTest)
target_link_libraries("${target}"
"${GMOCK_MAIN}"
"${GMOCK}"
"${GTEST_MAIN}"
"${GTEST}"
pthread)
Related
I am trying to make a CMAKE file that allows me to cross compile a WxWidgets application From Ubuntu For Windows.
My tools are all installed correctly, and I am able to run:
i686-w64-mingw32.static-gcc main.cpp $(i686-w64-mingw32.static-wx-config --cxxflags --libs) -o main.exe -std=c++11 -lstdc++
and produce a working output.
But I have been unsuccessful in finding a way to convert this into a CMAKE file. Does anyone have any resources or even examples of a working example?
Here is an example of my non-working file:
cmake_minimum_required(VERSION 3.11)
SET (PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(PROJECT_NAME "WxWidgets")
SET(CMAKE_C_COMPILER i686-w64-mingw32.static)
project(
${PROJECT_NAME}
VERSION 1.0
LANGUAGES CXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} (i686-w64-mingw32.static-wx-config --cxxflags --libs) -L /home/kevin/wxWidgets/include/ -Wall -std=gnu++2a -static -g")
file(GLOB all_SRCS
"${PROJECT_SOURCE_DIR}/src/*.h"
"${PROJECT_SOURCE_DIR}/src/*.hpp"
"${PROJECT_SOURCE_DIR}/src/*.c"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/**/*.c"
"${PROJECT_SOURCE_DIR}/src/**/*.cpp"
"${PROJECT_SOURCE_DIR}/src/**/*.hpp"
)
add_executable(${PROJECT_NAME} ${all_SRCS})
I am running the command:
i686-w64-mingw32.static-cmake ..
within my build directory.
By removing:
**(i686-w64-mingw32.static-wx-config --cxxflags --libs) -L /home/kevin/wxWidgets/include/**
...I am getting the error:
fatal error: wx/wxprec.h: No such file or directory
8 | #include "wx/wxprec.h"
I have this file I checked with locate:
$ locate wx/wxprec.h
/home/kevin/mxe/usr/i686-w64-mingw32.static/include/wx-3.1/wx/wxprec.h
/home/kevin/wxWidgets/include/wx/wxprec.h
/usr/local/include/wx-3.3/wx/wxprec.h
EDIT:
Thanks to #vre's comment, I have updated my CMakeLists.txt file and have moved closer, it seems now that I just need to link correctly Here is what I have:
cmake_minimum_required(VERSION 3.11)
SET (PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(PROJECT_NAME "WxWidgets")
SET(CMAKE_C_COMPILER i686-w64-mingw32.static)
project(
${PROJECT_NAME}
VERSION 1.0)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++2a -static -g")
file(GLOB all_SRCS
"${PROJECT_SOURCE_DIR}/src/*.h"
"${PROJECT_SOURCE_DIR}/src/*.hpp"
"${PROJECT_SOURCE_DIR}/src/*.c"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/**/*.c"
"${PROJECT_SOURCE_DIR}/src/**/*.cpp"
"${PROJECT_SOURCE_DIR}/src/**/*.hpp"
)
add_executable(${PROJECT_NAME} ${all_SRCS})
include( "${wxWidgets_USE_FILE}" )
find_package(wxWidgets REQUIRED)
target_include_directories(${PROJECT_NAME} PUBLIC /home/kevin/mxe/usr/i686-w64-mingw32.static/include/wx-3.1/ /home/kevin/mxe/usr/i686-w64-mingw32.static/lib/wx/include/i686-w64-mingw32.static-msw-unicode-static-3.1/)
target_link_directories(${PROJECT_NAME} PRIVATE /home/kevin/mxe/usr/i686-w64-mingw32.static/lib/)
But sadly, I have many linker errors such as:
undefined reference to `wxFrame::GetDefaultIcon() const'
I have a project where I link to boost; the CMakeLists.txt looks like this:
project(test VERSION 1.0)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wextra -Wfloat-equal -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Woverloaded-virtual")
find_package(Boost COMPONENTS filesystem program_options log log_setup REQUIRED)
include_directories(
${Boost_INCLUDE_DIRS}
)
add_executable(test src/test.cpp)
target_link_libraries(test
LINK_PUBLIC
${Boost_LIBRARIES}
config++
)
install(TARGETS test DESTINATION /usr/bin)
Now I am stumped how the linking in CMake works under the hood. It compiles fine but after I upgraded Boost, I am getting the error
test: error while loading shared libraries: libboost_program_options.so.1.75.0: cannot open shared object file: No such file or directory
and I'd like to avoid having to recompile every time a library gets an update.
The CMake doc says that
The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both the link dependencies and the link interface in one command.
But I don't quite understand how or why CMake links to the specific version of Boost and not simply to /usr/lib/libboost_program_options.so which is just a symlink to the currently installed version.
When trying to compile my project using the toolchain provided by the manufacturer of the hardware I'm developing for, compilation succeeds, however linking fails with the following error messages:
/media/xxx/Data/toolchains/sysroots/x86_64-xxx-linux/usr/bin/arm-xxx-linux-gnueabi/../../libexec/arm-xxx-linux-gnueabi/gcc/arm-xxx-linux-gnueabi/4.8.4/ld: cannot find -latomic
/media/xxx/Data/toolchains/sysroots/x86_64-xxx-linux/usr/bin/arm-xxx-linux-gnueabi/../../libexec/arm-xxx-linux-gnueabi/gcc/arm-xxx-linux-gnueabi/4.8.4/ld: cannot find -lstdc++
However, when building a small test program using the same compiler and linker, everything works.
Below is an excerpt of the important parts of my CMake toolchain file:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
###
# Get $CROSS
###
if (NOT $ENV{CROSS_COMPILE} STREQUAL "")
set(cross $ENV{CROSS_COMPILE}) # WARNING: Ends with a - (minus)
else()
set(cross "arm-xxx-linux-gnueabi-")
endif()
###
# Set CMake sysroot
###
set(CMAKE_SYSROOT $ENV{SDKTARGETSYSROOT})
set(CMAKE_SYSROOT_LINK $ENV{SDKTARGETSYSROOT})
set(CMAKE_SYSROOT_COMPILE $ENV{SDKTARGETSYSROOT})
set(CMAKE_C_COMPILER $ENV{TOOLCHAIN_TOOLSDIR}/${cross}gcc)
set(CMAKE_CXX_COMPILER $ENV{TOOLCHAIN_TOOLSDIR}/${cross}g++)
set(CMAKE_LD $ENV{TOOLCHAIN_TOOLSDIR}/${cross}ld)
set(CMAKE_STRIP $ENV{TOOLCHAIN_TOOLSDIR}/${cross}strip)
set(CMAKE_AR $ENV{TOOLCHAIN_TOOLSDIR}/${cross}ar)
include_directories($ENV{SDKTARGETSYSROOT}/usr/include)
I'm not at liberty to disclose source code, but the source code isn't the issue here as it compiles correctly.
Here's another MWE of the CMakeLists.txt file:
cmake_minimum_required(VERSION 3.10)
project(xxx LANGUAGES CXX VERSION 2.0.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(TARGET_NAME xxx.bin)
include_directories(
include/
${INCLUDE_DIRS}
)
file(GLOB_RECURSE FILES ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
if (xxx_DEBUG)
add_compile_options(
-Wpedantic
-DDDC_STUB
-fabi-version=6
-Wno-format-security
-Wno-reorder
-ggdb3
-O0
-fpermissive # Test
-fPIC
#-static-libstdc++ # with or without, doesn't change the behaviour
#-static-libgcc # with or without, doesn't change the behaviour
)
else()
add_compile_options(
-Wpedantic
-fabi-version=6
-Wno-format-security
-Wno-reorder
-O3
-fpermissive # Test
-fPIC
#-static-libstdc++ # with or without, doesn't change the behaviour
#-static-libgcc # with or without, doesn't change the behaviour
)
endif()
add_executable(${TARGET_NAME} ${FILES} ${MEMWATCH_FILES})
I've tried setting the sysroot-argument for ld, I've tried manually specifying the link (search) path -L$ENV{SDKTARGETSYSROOT}/usr/lib/.debug, and I've also tried hard-wiring the path to the library in question: $ENV{SDKTARGETSYSROOT}/usr/lib/.debug/libatomic.so.1.0.0
Is there another way I can tell ld what libraries to use?
This works perfectly with standard toolchains!
EDIT:
I've now also tried brute-forcing it by creating a symlink from the .debug/libatomic to usr/lib/libatomic. That also hasn't had the desired effect.
I am working on some parts of a fairly large project that involves using GraphViz on C++, but I can't seem to use the GraphViz functions. My code is intended to generate a .png from .dot files automatically, but I keep getting "undefined reference" to 'functionName' (all functions that are related to the gvc.h include) when I try to compile it. I highly suspect that something is not linking during compilation, but I can't figure out what to do with the CMakeLists.txt and what I should link in the first place. I did, however, notice that there was a gv.cpp file in my /usr/include/graphviz folder, but I don't know if I'm supposed to somehow link that file or if it's something completely different.
/usr/bin/ld: CMakeFiles/ag_gen.dir/src/main.cpp.o: in function `save_image_gv(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
main.cpp:(.text+0xf07): undefined reference to `gvContext'
/usr/bin/ld: main.cpp:(.text+0xf27): undefined reference to `agread'
/usr/bin/ld: main.cpp:(.text+0xf3c): undefined reference to `gvLayout'
/usr/bin/ld: main.cpp:(.text+0xfc8): undefined reference to `gvRender'
/usr/bin/ld: main.cpp:(.text+0xfef): undefined reference to `gvFreeLayout'
/usr/bin/ld: main.cpp:(.text+0xff7): undefined reference to `agclose'
/usr/bin/ld: main.cpp:(.text+0xfff): undefined reference to `gvFreeContext'
collect2: error: ld returned 1 exit status
make[3]: *** [CMakeFiles/ag_gen.dir/build.make:460: ag_gen] Error 1
make[2]: *** [CMakeFiles/Makefile2:156: CMakeFiles/ag_gen.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:163: CMakeFiles/ag_gen.dir/rule] Error 2
make: *** [Makefile:164: ag_gen] Error 2
Here is the problematic part of my code in main.cpp:
#include <graphviz/gvc.h>
bool save_image_gv(std::string filename){
GVC_t *gvc;
Agraph_t *g;
FILE *fp;
gvc = gvContext();
fp = fopen((filename).c_str(), "r");
g = agread(fp, 0);
gvLayout(gvc, g, "dot");
gvRender(gvc, g, "png", fopen((filename+".png").c_str(), "w"));
gvFreeLayout(gvc, g);
agclose(g);
return (gvFreeContext(gvc));
}
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
# Uncomment for gcc
# set(CMAKE_C_COMPILER "gcc-8")
# set(CMAKE_CXX_COMPILER "g++-8")
project(ag_gen)
set_source_files_properties(
mem.c
PROPERTIES
COMPILE_DEFINITIONS UNIT_TEST=1
)
# Common compiler options among built types
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
# Specific compiler options for Debug or Release builds
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -ggdb -Wall -fopenmp -pedantic")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -Wall -fopenmp -pedantic -O1")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1 -fopenmp")
set(PostgreSQL_TYPE_INCLUDE_DIR "9.5")
set(PostgreSQL_ADDITIONAL_VERSIONS "10.1" "10" "9.5")
find_program(LSB_RELEASE lsb_release)
execute_process(COMMAND ${LSB_RELEASE} -is
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
include_directories("/usr/include/postgresql")
# Apple has a different openssl directory when using brew
if(APPLE)
set(BISON_EXECUTABLE "/usr/local/opt/bison/bin/bison")
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
set(ENV{PKG_CONFIG_PATH} "/usr/local/lib/pkgconfig")
find_package(PkgConfig REQUIRED)
find_package(PostgreSQL REQUIRED)
find_package(OpenMP)
find_package(BISON 2.4 REQUIRED)
find_package(FLEX REQUIRED)
find_package(Boost REQUIRED)
find_package(OpenSSL)
find_package(Doxygen)
pkg_check_modules(CMOCKA cmocka)
pkg_check_modules(CPPREDIS cpp_redis)
if(OpenSSL_FOUND)
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
# Enable thread-level parallelization if OpenMP is found.
if(OpenMP_CXX_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile #ONLY)
add_custom_target(doc ALL ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif(DOXYGEN_FOUND)
include_directories("${CMAKE_SOURCE_DIR}/src/")
file(GLOB ag_gen_src "${CMAKE_SOURCE_DIR}/src/ag_gen/*.cpp")
file(GLOB utils_src "${CMAKE_SOURCE_DIR}/src/util/*.c" "${CMAKE_SOURCE_DIR}/src/util/*.cpp")
########################
### Network Model Parser
########################
BISON_TARGET(nm_parser "${CMAKE_SOURCE_DIR}/src/parser/nm-parser/nm_parser.yy"
"${CMAKE_CURRENT_BINARY_DIR}/nm_parser.c"
DEFINES_FILE "${CMAKE_CURRENT_BINARY_DIR}/nm_parser.tab.h")
FLEX_TARGET(nm_scanner "${CMAKE_SOURCE_DIR}/src/parser/nm-parser/nm_scanner.l"
"${CMAKE_CURRENT_BINARY_DIR}/nm_scanner.c"
COMPILE_FLAGS "-Pnm")
ADD_FLEX_BISON_DEPENDENCY(nm_scanner nm_parser)
#add_executable(nm_test ${FLEX_nm_scanner_OUTPUTS} ${BISON_nm_parser_OUTPUTS} ${utils_src})
#target_include_directories(nm_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_SOURCE_DIR}/src/compiler/nm-parser")
##########################
### Exploit Pattern Parser
##########################
BISON_TARGET(xp_parser "${CMAKE_SOURCE_DIR}/src/parser/xp-parser/xp_parser.yy"
"${CMAKE_CURRENT_BINARY_DIR}/xp_parser.c"
DEFINES_FILE "${CMAKE_CURRENT_BINARY_DIR}/xp_parser.tab.h")
FLEX_TARGET(xp_scanner "${CMAKE_SOURCE_DIR}/src/parser/xp-parser/xp_scanner.l"
"${CMAKE_CURRENT_BINARY_DIR}/xp_scanner.c"
COMPILE_FLAGS "-Pxp")
ADD_FLEX_BISON_DEPENDENCY(xp_scanner xp_parser)
#add_executable(xp_test ${FLEX_xp_scanner_OUTPUTS} ${BISON_xp_parser_OUTPUTS} ${utils_src})
#target_include_directories(xp_test PRIVATE ${CMAKE_CURRENT_BINARY_DIR} "${CMAKE_SOURCE_DIR}/src/compiler/xp-parser")
####################
### Main application
####################
add_executable(ag_gen "${CMAKE_SOURCE_DIR}/src/main.cpp"
${FLEX_nm_scanner_OUTPUTS} ${BISON_nm_parser_OUTPUTS}
${FLEX_xp_scanner_OUTPUTS} ${BISON_xp_parser_OUTPUTS}
${ag_gen_src} ${utils_src})
target_link_libraries(ag_gen ${PostgreSQL_LIBRARIES})
add_executable(decode "${CMAKE_SOURCE_DIR}/src/tools/decode.cpp"
${ag_gen_src} ${utils_src})
target_link_libraries(decode ${PostgreSQL_LIBRARIES})
if(CPPREDIS_FOUND)
#include_directories("${CPPREDIS_INCLUDE_DIRS}")
link_directories("${CPPREDIS_LIBRARY_DIRS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DREDIS")
target_link_libraries(ag_gen cpp_redis tacopie)
target_link_libraries(decode cpp_redis tacopie)
endif()
################
### Unit Testing
################
if(CMOCKA_FOUND)
add_executable(dynstr_test ${CMAKE_SOURCE_DIR}/src/util/mem.c ${CMAKE_SOURCE_DIR}/src/tests/mem_test.c)
target_link_libraries(dynstr_test ${CMOCKA_LIBRARIES})
endif()
# Files to be added to build directory
configure_file("config.ini" "config.ini" COPYONLY)
if(CPPREDIS_FOUND)
add_custom_command(TARGET ag_gen PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/redis_scripts $<TARGET_FILE_DIR:ag_gen>/redis_scripts)
endif()
Link libgvc.so with your binary as follows:
target_link_libraries(ag_gen PUBLIC gvc)
Using Botje's answer and this Stack Overflow question, I was able to solve the problem. Here's what I did to my CMakeLists.txt:
I added cgraph and gvc in target_link_libraries.
target_link_libraries(ag_gen ${PostgreSQL_LIBRARIES} cgraph gvc)
And, voila! After this simple change, compilation was a success!
I am trying to compile a program on QT creator with cmake. The code(its not my code, I am using it to test something) uses openMP. in my cmake file I have:
`enter code here`project(dbscan_try)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
SET(CMAKE_CXX_FLAGS "{CMAKE_CXX_FLAGS} -std=c++11 -Wall -fPIC -pedantic -fopenmp -mtune=corei7-avx")
set(Boost_USE_STATIC_LIBS OFF) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) add_definitions(-DBOOST_UBLAS_NDEBUG) add_definitions("-std=c++11") add_definitions("-fopenmp")
add_definitions("-lgomp")
OPTION (USE_OpenMP "Use OpenMP" ON)
find_package(OpenMP)
if (OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fopenmp")
find_package(PCL REQUIRED COMPONENTS) include_directories(${PCL_INCLUDE_DIRS} ) link_directories(${PCL_LIBRARY_DIRS}) add_definitions(${PCL_DEFINITIONS})
include_directories({/home/raman/Work/dbscan_try})
set(project_SOURCES
/home/raman/Work/cplusplus_projects/dbscan_try/main.cpp
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.cpp )
set(project_HEADERS
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.h)
set(OpenCV_INCLUDE_DIRS "${OpenCV_INSTALL_PATH}/include/opencv;${OpenCV_INSTALL_PATH}/include")
find_package(OpenCV 3.1.0 REQUIRED COMPONENTS) include_directories(-L/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_saliency -lboost_system -lopencv_contrib) set( CMAKE_CXX_FLAGS "-g -Wall")
add_executable(${PROJECT_NAME} ${project_SOURCES})
target_link_libraries(dbscan_try ${PCL_LIBRARIES} ${OpenCV_LIBS} )
However, I am getting errors such as:
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.cpp:88: error: undefined reference to omp_set_num_threads'
/home/raman/Work/cplusplus_projects/dbscan_try/dbscan.cpp:89: error: undefined reference toGOMP_parallel_start'
etc.
I am new to C++ and cmake so I am not sure if I am doing somethign wrong here. I seem to have followed what other suggestions here mentioned and it worked for them.