我在一个文件夹中写了一系列包,我想编写一个使用它们的程序。最重要的是,我希望将文件夹保持在同一级别,以便拥有更独立的管理。 例如,我有一个名为brisk的包,必须由另一个名为place_recognition
的包使用cpp
|
-- brisk
| |
| --CMakeLists.txt
| |
| --release
| | |
| | --lib
--etc...
-- place_recognition
| |
| --cmake
| |
| -- CMakeLists.txt
| |
| -- src
| |
| -- include
我写了一个FindBrisk.cmake文件,并将其添加到我的“place_recognition”项目中。
get_filename_component(BRISK_CURRENT_CONFIG_DIR “$ {CMAKE_CURRENT_LIST_FILE}”路径“
set(BRISK_EXPORTED_BUILD_DIR ${BRISK_CURRENT_CONFIG_DIR})
get_filename_component(BRISK_EXPORTED_SOURCE_DIR
${BRISK_EXPORTED_BUILD_DIR}/../../brisk/ ABSOLUTE)
set(BRISK_INCLUDE_DIR "${BRISK_EXPORTED_SOURCE_DIR}/include")
set(BRISK_LIBRARY_DIR "${BRISK_EXPORTED_SOURCE_DIR}/release/lib")
set(BRISK_FOUND True)
set(BRISK_LIBRARIES "${BRISK_EXPORTED_SOURCE_DIR}/release/lib/libbrisk.a")
set(AGAST_INCLUDE_DIR "${BRISK_EXPORTED_SOURCE_DIR}/agast/include")
set(AGAST_LIBRARIES "${BRISK_EXPORTED_SOURCE_DIR}/release/lib/libagast.a")
set(AGAST_FOUND True)
mark_as_advanced(BRISK_INCLUDE_DIR BRISK_LIBRARY_DIR BRISK_LIBRARIES AGAST_INCLUDE_DIR AGAST_LIBRARIES)
我将它包含在我在此处报告的CMakeLists.txt中
cmake_minimum_required(VERSION 2.8.11)
project(place_recognition)
#set up the output tree
set(CMAKE_BINARY_DIR ${PROJECT_SOURCE_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(Brisk REQUIRED)
find_package( OpenCV REQUIRED )
include_directories(BEFORE ${OpenCV_INCLUDE_DIRS})
if(BRISK_FOUND)
message(STATUS "Found BRISK in " ${BRISK_INCLUDE_DIR})
else(BRISK_FOUND)
message(STATUS "BRISK NOT FOUND")
endif(BRISK_FOUND)
# copy all needed files to binary dir (when cmake)
file(GLOB files_needed
dataset/*
)
file(COPY ${files_needed} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
include_directories(
include
${BRISK_INCLUDE_DIR}
${AGAST_INCLUDE_DIR}
)
add_definitions(-mssse3 -DAGAST_GLOG -Werror -Wextra -Wall -pedantic -std=c++0x)
add_executable(
${PROJECT_NAME}
src/main.cpp
)
link_directories(
${BRISK_LIBRARY_DIR}
)
target_link_libraries(
${PROJECT_NAME}
${OpenCV_LIBS}
${AGAST_LIBRARIES}
${BRISK_LIBRARIES}
)
然而,我得到了一个奇怪的行为。当我尝试编译代码时,编译器无法找到brisk包的依赖项,我被要求将它们显式包含在我的cmake文件中,在我的示例中,我必须使用OpenCV。因为,轻快使用GLOG现在我在尝试编译时遇到以下错误
链接CXX可执行文件../bin/place_recognition /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(brisk-scale-space.cc.o): 在功能上
brisk::BriskScaleSpace::GetKeypoints(std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >*)': brisk-scale-space.cc:(.text+0x4690): undefined reference to
google :: LogMessageFatal :: LogMessageFatal(char const *,int, google :: CheckOpString const&amp;)'brisk-scale-space.cc :(. text + 0x469d): 未明确引用google::LogMessageFatal::~LogMessageFatal()' /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(brisk-layer.cc.o): In function
brisk :: BriskLayer :: GetAgastPoints(unsigned char, std :: vector&gt; )': brisk-layer.cc :(. text + 0x4cc):未定义的引用google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)' brisk-layer.cc:(.text+0x156): undefined reference to
谷歌:: LogMessageFatal ::〜LogMessageFatal()” /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(brisk-layer.cc.o): 在函数brisk::BriskLayer::BriskLayer(cv::Mat const&, unsigned char, unsigned char, float, float)': brisk-layer.cc:(.text+0x29ef): undefined reference to
vtable for agast :: OastDetector9_16' brisk-layer.cc :(. text + 0x2b4d):未定义引用vtable for agast::AgastDetector5_8' /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(brisk-layer.cc.o): In function
brisk :: BriskLayer :: BriskLayer(brisk :: BriskLayer const&amp ;,, int,unsigned char,unsigned char)':brisk-layer.cc :(. text + 0x32e3): 对vtable for agast::OastDetector9_16' brisk-layer.cc:(.text+0x3456): undefined reference to
vtable的未定义引用 agast :: AgastDetector5_8' /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(image-down-sampling.cc.o): 在函数brisk::Halfsample16(cv::Mat const&, cv::Mat&)': image-down-sampling.cc:(.text+0xc4e): undefined reference to
google :: LogMessageFatal :: LogMessageFatal(char const ,int, google :: CheckOpString const&amp;)'image-down-sampling.cc :(. text + 0xc56): 对google::LogMessage::stream()' image-down-sampling.cc:(.text+0xc5e): undefined reference to
google :: LogMessageFatal :: ~LogMessageFatal()'的未定义引用 image-down-sampling.cc:(.text+0xcab):未定义的引用google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)' image-down-sampling.cc:(.text+0xcb3): undefined reference to
谷歌::的LogMessage ::流()” image-down-sampling.cc:(.text+0xd02):未定义的引用google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)' image-down-sampling.cc:(.text+0xd0a): undefined reference to
谷歌::的LogMessage ::流()” /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(image-down-sampling.cc.o): 在函数brisk::Halfsample8(cv::Mat const&, cv::Mat&)': image-down-sampling.cc:(.text+0x1227): undefined reference to
google :: LogMessageFatal :: LogMessageFatal(char const *,int, google :: CheckOpString const&amp;)'image-down-sampling.cc :(. text + 0x212f): 对google::LogMessage::stream()' image-down-sampling.cc:(.text+0x1237): undefined reference to
google :: LogMessageFatal :: ~LogMessageFatal()'的未定义引用 image-down-sampling.cc:(.text+0x1280):未定义的引用google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)' image-down-sampling.cc:(.text+0x1288): undefined reference to
谷歌::的LogMessage ::流()” /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(image-down-sampling.cc.o): 在函数brisk::Twothirdsample8(cv::Mat const&, cv::Mat&)': image-down-sampling.cc:(.text+0x168f): undefined reference to
google :: LogMessageFatal :: LogMessageFatal(char const *,int, google :: CheckOpString const&amp;)'image-down-sampling.cc :(. text + 0x1697): 对google::LogMessage::stream()' image-down-sampling.cc:(.text+0x169f): undefined reference to
google :: LogMessageFatal :: ~LogMessageFatal()'的未定义引用 image-down-sampling.cc:(.text+0x16e5):未定义的引用google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)' image-down-sampling.cc:(.text+0x16ed): undefined reference to
谷歌::的LogMessage ::流()” /home/andrea/development/cpp/brisk/release/lib/libbrisk.a(image-down-sampling.cc.o): 在函数std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)': image-down-sampling.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x15): undefined reference to
google :: base :: CheckOpMessageBuilder :: CheckOpMessageBuilder(char 常量*)” image-down-sampling.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x2c): 未定义的引用google::base::CheckOpMessageBuilder::ForVar2()' image-down-sampling.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x40): undefined reference to
谷歌::基:: CheckOpMessageBuilder :: NewString()” image-down-sampling.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x4f): 未定义的引用google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()' image-down-sampling.cc:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x68): undefined reference to
谷歌::基:: CheckOpMessageBuilder ::〜CheckOpMessageBuilder()” collect2:错误:ld返回1退出状态make [2]: * [../bin/place_recognition]错误1 make [1]:* [CMakeFiles / place_recognition.dir / all]错误2 make:*** [all]错误2
我做错了什么? 谢谢 安德烈