[英]How can I cmake/make a CGAL binary that correctly links against a libassimp dylib on OSX?
I think this is very simple for someone who knows about this stuff; 我认为这对于了解这些知识的人来说非常简单。 please over-explain because I'm not used to cmake or command line development on OSX.
请过度解释,因为我不习惯在OSX上进行cmake或命令行开发。
I am getting started with CGAL and have one of the examples correctly buildings and running from Terminal ( http://doc.cgal.org/latest/AABB_tree/ section 3.2). 我正在开始使用CGAL,并有一个示例可以正确构建并从终端运行( http://doc.cgal.org/latest/AABB_tree/第3.2节)。 I copy that code to a .cpp in its own folder, and then
我将该代码复制到其自己的文件夹中的.cpp,然后
/opt/local/bin/cgal_create_cmake_script
cmake .
make .
This works fine; 这很好用; the cgal create script bootstraps a cmake file, and then its a standard build process from there.
cgal create脚本引导一个cmake文件,然后从那里启动它的标准构建过程。
I am now interested in using libassimp to add to that example project, in order to load .PLY files. 我现在对使用libassimp添加到该示例项目感兴趣,以便加载.PLY文件。 In a different folder I acquired the source for libassimp, and installed via:
在另一个文件夹中,我获得了libassimp的源,并通过以下方式安装:
cmake -G 'Unix Makefiles'
make
sudo make install
This appears successful; 这看起来很成功; several libassimp .h files are in /usr/local/lib/libassimp, as well as a /usr/local/lib/libassimp.dylib
/ usr / local / lib / libassimp和/usr/local/lib/libassimp.dylib中有几个libassimp .h文件
Back in my CGAL example project, I try 回到我的CGAL示例项目中,我尝试
#include <assimp/Importer.hpp>
int main() {
Assimp::Importer importer;
return 0;
}
(ie just to test successful integration of the library.) (即只是为了测试库的成功集成。)
When I run make I get: 当我运行make时,我得到:
[100%] Building CXX object CMakeFiles/sample.dir/sample.cpp.o
Linking CXX executable sample
Undefined symbols for architecture x86_64:
"Assimp::Importer::Importer()", referenced from:
assimp_test() in sample.cpp.o
_main in sample.cpp.o
"Assimp::Importer::~Importer()", referenced from:
assimp_test() in sample.cpp.o
_main in sample.cpp.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]: *** [sample] Error 1
make[1]: *** [CMakeFiles/sample.dir/all] Error 2
make: *** [all] Error 2
This does not surprise me; 这并不令我惊讶; I presumably need to add something to CMakelists.txt.
我大概需要在CMakelists.txt中添加一些内容。 But what!
可是!
Found this after asking, which gave me the clues I needed: How to find a library with cmake? 在询问后发现了这个问题,这给了我所需的线索: 如何使用cmake查找图书馆?
Essentially I changed the relevant lines in my CMakelists.txt to read: 基本上,我将CMakelists.txt中的相关行更改为:
create_single_source_cgal_program( "sample.cpp" )
target_link_libraries (sample assimp)
this works because apparently when you tell cmake to target_link_libraries(EXENAME FOO), it will look for /usr/local/lib/libFOO.dylib 这很有效,因为显然当您将cmake告诉target_link_libraries(EXENAME FOO)时,它将查找/usr/local/lib/libFOO.dylib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.