for Robot Artificial Inteligence

understanding cmake by experience and error(0)

|

Find_Package

find_package(COLMAP REQUIRED base exe controllers estimators feature optim sfm tools mvs util )

find_package里面的参数是就是这样,第一是在local 计算机上找package然后编辑。

第二个是我们可以不用使用全部package里面的so,o file。所以定一个条Require然后后面是只我们需要的source code或者我们可以特定的Version使用

经路:build/src/CMakeFiles/colmap.dir/controllers

在build里面的object file使用的

Manually add package condition

set( YOLO_INCLUDE_DIRS “${PROJECT_SOURCE_DIR}/third_party/darknet/include/”)

set( YOLO_LIBS “${PROJECT_SOURCE_DIR}/third_party/darknet/libdarknet.so”)

include_directories( ${PROJECT_HEADER_DIR} ${COLMAP_INCLUDE_DIRS} ${EZSIFT_INCLUDE_DIRS} ${DBoW2_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS} ${YOLO_INCLUDE_DIRS} )

target_link_libraries(${PROJECT_NAME}_program Qt5::Widgets ${COLMAP_LIBRARIES} ${EZSIFT_LIBS} ${DBoW2_LIBS} image_database_selector_lib ${YOLO_LIBS} #${SQLITE3_LIBRARY} ${OpenCV_LIB} )

Useful CMAKE

set(IMAGE_DATABASE_SELECTOR_INCLUDE_PATH ${PROJECT_HEADER_DIR}/image_database_selector)

set(LIB_HEADERS ${IMAGE_DATABASE_SELECTOR_INCLUDE_PATH}/common_include.h ${IMAGE_DATABASE_SELECTOR_INCLUDE_PATH}/feature_utility.h ${IMAGE_DATABASE_SELECTOR_INCLUDE_PATH}/feature.h ${IMAGE_DATABASE_SELECTOR_INCLUDE_PATH}/keyframe.h ${IMAGE_DATABASE_SELECTOR_INCLUDE_PATH}/utility.h ${IMAGE_DATABASE_SELECTOR_INCLUDE_PATH}/database_manager.h)

set(LIB_NAME “image_database_selector”)

target_link_libraries(${LIB_NAME}_lib ${OpenCV_LIBS} ${DBoW2_LIBS} ${EZSIFT_LIBS})

##

QT USE

qt5_wrap_cpp(qt_HEADERS ${PROJECT_HEADER_DIR}/mainwindow.h)

qt5_wrap_ui(qt_UI ${PROJECT_GUI_DIR}/mainwindow.ui)

set(IMAGE_DATABASE_SELECTOR_INCLUDE_PATH ${PROJECT_HEADER_DIR}/image_database_selector)

set(HEADERS ${PROJECT_HEADER_DIR}/visual_database_management_info.h)

set(SOURCES visual_database_management_info.cpp

mainwindow.cpp

main.cpp)

set(OBJECT_DETECTOR object_detector/objectDetector.cpp)

subdirs(image_database_selector)

add_executable(${PROJECT_NAME}_program

${SOURCES}

${HEADERS}

${qt_UI} ${qt_HEADERS}

${OBJECT_DETECTOR}

)

add_executable(helloworld

src/mainwindow.ui

src/mainwindow.cpp

src/main.cpp

# resources.qrc

)

qt5_use_modules(${PROJECT_NAME}_program Widgets)

message(${COLMAP_LIBRARIES})

target_link_libraries(${PROJECT_NAME}_program

Qt5::Widgets

${COLMAP_LIBRARIES}

${EZSIFT_LIBS}

${DBoW2_LIBS}

image_database_selector_lib

${YOLO_LIBS} #${SQLITE3_LIBRARY}

${OpenCV_LIB}

)

cmake编译错误”relocation R_X86_64_32 against .rodata can not be used when making a shared object“解决办法

在CMakeLists.txt中添加如下一行: add_definitions(-fPIC)

static library를 쓰려면 이를 추가해야 된다.

Comments