简体   繁体   English

在Mac上编译使用Macports安装的CGAL程序

[英]Compiling CGAL programs on mac, installed using macports

I am working on a project that requires CGAL running on a mac and am very new to C++ in general. 我正在从事一个需要在Mac上运行CGAL的项目,并且对C ++来说通常是一个非常新的项目。 I installed CGAL using macports using the command 我使用命令使用macports安装了CGAL

sudo port install cgal

The installation completed and the .h files were placed in 安装完成,并将.h文件放入

/opt/local/include/cgal

I copied the tutorial program into a .cpp file and compiled using 我将教程程序复制到一个.cpp文件中,并使用

g++ -lcgal -I/opt/local/include/ vec.cpp

This returns the error 这将返回错误

ld: library not found for -lcgal clang: error: linker command failed with exit code 1 (use -v to see invocation) ld:找不到用于-lcgal的库:错误:链接器命令失败,退出代码为1(使用-v查看调用)

g++ -lcgal -v -I/opt/local/include/ vec.cpp

returns 退货

Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.2.0 Thread model: posix "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name vec.cpp -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1 -I /opt/local/include -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/sujeath/C practice -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/tm/bgg4k0xs4v36pzwxvsrqtsb00000gn/T/vec-0a56fb.o -x c++ ve Apple LLVM版本5.1(clang-503.0.40)(基于LLVM 3.4svn)目标:x86_64-apple-darwin13.2.0线程模型:posix“ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr / bin / clang“ -cc1-三联x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier-主文件名vec.cpp -mrelocation-model图片-pic -level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 236.3 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault。 xctoolchain / usr / bin /../ lib / clang / 5.1 -I / opt / local / include -stdlib = libc ++ -fdeprecated-macro -fdebug-compilation-dir / Users / sujeath / C实践-ferror-limit 19 -fmessage长度80-堆栈保护器1 -mstackrealign -fblocks -fobjc-runtime = macosx-10.9.0 -fencode扩展块签名-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/tm/bgg4k0xs4v36pzwxvsrqtsb00000gn/T/vec-0a56fb.o -x c ++ ve c.cpp clang -cc1 version 5.1 based upon LLVM 3.4svn default target x86_64-apple-darwin13.2.0 ignoring nonexistent directory "/usr/include/c++/v1" \\#include "..." search starts here: \\#include search starts here: /opt/local/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1 /usr/local/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. 基于LLVM 3.4svn的c.cpp clang -cc1版本5.1默认目标x86_64-apple-darwin13.2.0忽略不存在的目录“ / usr / include / c ++ / v1” \\ #include“ ...”,搜索从此处开始:\\ #include搜索从此处开始:/ opt / local / include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1 / usr / local / include / Applications / Xcode。 app / Contents / Developer / Toolchains / XcodeDefault.xctoolchain / usr / bin /../ lib / clang / 5.1 / include /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include / usr / include / System / Library / Frameworks(框架目录)/ Library / Frameworks(框架目录)搜索列表的结尾。 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out /var/folders/tm/bgg4k0xs4v36pzwxvsrqtsb00000gn/T/vec-0a56fb.o -lcgal -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a ld: library not found for -lcgal clang: error: linker command failed with exit code 1 (use -v to see invocation) “ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld” -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out / var / folders / tm / bgg4k0xs4v36pzwxvsrqtsb00000gn / T / vec-0a56fb.o -lcgal -lc ++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx .a ld:-lcgal clang找不到库:错误:链接器命令失败,退出代码为1(使用-v查看调用)

I am using Mavericks BTW and gnu gcc 我正在使用Mavericks BTW和gnu gcc

Thanks! 谢谢!

so, first of all, I'm new on stackoverflow and actually would have preferred to add a comment rather then posting an answer as I'm pretty new to the C++/Mac world too. 因此,首先,我是stackoverflow的新手,实际上我本来希望添加评论而不是发布答案,因为我也是C ++ / Mac领域的新手。

Stated this disclaimer I would like to point out a two things that I saw "parsing" the output you posted: 声明此免责声明,我想指出两件我“解析”您发布的输出的内容:

  1. You're calling g++ , however, you're using clang to compile (default on OS X Mavericks) as /usr/bin/g++ points to /usr/bin/clang++ 您正在调用g++ ,但是,您正在使用clang进行编译(在OS X Mavericks中为默认设置),因为/usr/bin/g++指向/usr/bin/clang++
  2. I think the cgal library is not on your search path. 我认为cgal库不在您的搜索路径上。 Marc Glisse pointed you to the -L option of the ld command that let you define further search directories. Marc Glisse指出了ld命令的-L选项,该选项可让您定义更多的搜索目录。 Probably -L/opt/local/lib might work for you using Macports (I didn't use Macports for a long time so I'm not sure if that's the correct path for the libraries). 可能-L/opt/local/lib使用Macports可能对您有用(我很长时间没有使用Macports了,所以我不确定这是否是库的正确路径)。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM