简体   繁体   English

如何在OSX上cmake /制作正确链接到libassimp dylib的CGAL二进制文件?

[英]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.

相关问题 CMAKE为dylib创建OSX包? - CMAKE create OSX bundle for dylib? 如何在OSX的.app捆绑包中正确分配dylib依赖项? - How do I properly distribute dylib dependencies in a .app bundle on OSX? 如何解决/usr/lib64/libstdc++.so.6:在我的CGAL cmake项目中找不到版本&#39;GLIBCXX_3.4.15&#39;? - How can I resolve /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found in my CGAL cmake project? CGAL如何判断三角形是否在边界上 - CGAL How can I tell if triangle is on the boundary 如何使CMAKE在OSX上找到lib curl的特定版本? - How to make CMAKE find specific version of lib curl on OSX? CMake链接错误的库版本 - CMake links against wrong version of library 如何使用CMake选择性地链接静态或动态boost库? - How can I optionally link against static or dynamic boost library using CMake? 如何使用 CMake 和 FindLibXml2 链接不需要 DLL 的静态版本的 LibXml2 - How can I use CMake and FindLibXml2 to link against a static version of LibXml2 that requires no DLL CGAL:如何成功编译和链接CGAL示例(在Mac OS X 10.9 Mavericks上) - CGAL: How can I successfully compile and link CGAL examples (on Mac OS X 10.9 Mavericks) 如何使鼠标支持适用于 OSX 上的 ncurses? - How can I make mouse support work for ncurses on OSX?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM