yangsy
About 235 wordsLess than 1 minute
2024-11-04
Caution
Create a project and copy the include/ and lib/ directories from the SDK directory to the project directory.
Create a demo directory and within it, create a CMakeLists.txt and SDKTest.cpp file (you can create different directories and files according to your project's needs).
cmake_minimum_required(VERSION 3.4.1)
set(TARGET_NAME SDKTest)
message("configure ${TARGET_NAME}")
# +++++++ setting +++++++
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
# ############
# ### SDK ####
# ############
set(SDK_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include")
set(SDK_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../lib")
include_directories(${SDK_INCLUDE_DIR})
link_directories(${SDK_LIB_DIR})
if(WIN32)
set(APP_PREFIX .exe)
set(SDK_LIB SynexensSDK)
elseif(UNIX)
set(APP_PREFIX)
set(SDK_LIB csreconstruction2.0 SynexensSDK)
endif()
add_executable(${TARGET_NAME} SDKTest.cpp)
target_link_libraries(${TARGET_NAME} PRIVATE ${SDK_LIB})
set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX "_d")
Navigate to the demo directory, where the CMakeLists.txt file is located.
mkdir build
cd build
cmake .. && make
Install the so libraries from the lib/ folder in the project directory to the /usr/lib/ directory, or execute
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:Path_to_so_libraries
and then run the compiled program.