首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >MacOs -编译c++ OpenCv返回找不到体系结构x86_64的符号

MacOs -编译c++ OpenCv返回找不到体系结构x86_64的符号
EN

Stack Overflow用户
提问于 2019-04-15 02:44:14
回答 1查看 291关注 0票数 0

我想在MacOs上试用this OpenCv code

我跟随this tutorial在MacOs上安装了OpenCv。(在我尝试用自制软件安装之前)

我有以下CMakeLists.txt

代码语言:javascript
复制
cmake_minimum_required(VERSION 3.1)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
SET(OpenCV_DIR <path>/installation/OpenCV-master/lib/cmake/opencv4)

# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
find_package(OpenCV REQUIRED)

# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS "    config: ${OpenCV_DIR}")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

# Declare the executable target built from your sources
#add_executable(opencv_example example.cpp)
project(intro_PCA)
add_executable(myapp introduction_to_pca.cpp)

# Link your application with OpenCV libraries
#target_link_libraries(opencv_example ${OpenCV_LIBS})

include_directories(
        <path>/installation/OpenCV-master/include/opencv4
    )

install(TARGETS myapp DESTINATION ../0-BRIQUE_PCA/briquepca/)

在文件夹build中,我使用以下命令编译代码:

代码语言:javascript
复制
$ cmake ..
$ cmake --build . --config Release

编译结束时出现以下错误:

代码语言:javascript
复制
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [myapp] Error 1
make[1]: *** [CMakeFiles/myapp.dir/all] Error 2
make: *** [all] Error 2

我发现here应该添加以下内容:

代码语言:javascript
复制
-libopencv_core \
-libopencv_imgproc \
-libopencv_features2d \
-libopencv_highgui

但是我不知道在我的CMakeLists.txt中应该在哪里添加这些行

有没有人有主意?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-15 04:00:10

您可以使用以下命令链接库:target_link_libraries(myapp ${OpenCV_LIBS}),它会将myapp链接到find_package(OpenCV REQUIRED)定义的所有OpenCV库。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55678775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档