问题描述
使用cmake编译项目时,报错内容为
Undefined symbols for architecture x86_64:
"Obstacle::run()", referenced from:
_main in 1.o
"Obstacle::Obstacle()", referenced from:
_main in 1.o
"Obstacle::~Obstacle()", referenced from:
_main in 1.o
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]: *** [s] Error 1
make[1]: *** [CMakeFiles/s.dir/all] Error 2
make: *** [all] Error 2
原因
非常初级的BUG:包含着报错的类的cpp没有被编译
问题解决
project( test )
set(OpenCV_DIR "/usr/local/Cellar/opencv/4.0.1/lib/cmake/opencv4")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
find_package( OpenCV REQUIRED )
add_executable( test 1.cpp)
target_link_libraries( s ${OpenCV_LIBS} )
将add_executable后,添加了我新加入项目的cpp,问题解决
add_executable( test 1.cpp AddObstacle.cpp)
评论(0)
您还未登录,请登录后发表或查看评论