OSX 上 Eclipse 中的 CGAL
我正在尝试在 OS X 10.7 上使用 CGAL 和 Eclipse。我通过 MacPorts 安装了 CGAL,并通过将 /opt/local/include 添加到其包含列表来让 Eclipse 意识到这一点。现在我收到链接器错误。我在这里有点迷失,你有什么建议吗?
这就是我的编译方式:
make all
Building file: ../hit.cpp
Invoking: Cross G++ Compiler
g++ -I/opt/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"hit.d" -MT"hit.d" -o "hit.o" "../hit.cpp"
Finished building: ../hit.cpp
Building target: Hit
Invoking: Cross G++ Linker
g++ -o "Hit" ./hit.o
Undefined symbols for architecture x86_64:
"CGAL::assertion_fail(char const*, char const*, int, char const*)", referenced from:
CGAL::Interval_nt<false>::Interval_nt(double)in hit.o
CGAL::Interval_nt<false>::Interval_nt(double, double)in hit.o
bool CGAL::get_certain<bool>(CGAL::Uncertain<bool>)in hit.o
CGAL::Interval_nt<false>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()in hit.o
CGAL::Interval_nt<true>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()in hit.o
CGAL::Gmpq::Gmpq(double)in hit.o
bool CGAL::internal::seg_seg_do_intersect_crossing<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >(CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> > const&)in hit.o
...
"___gmpq_init", referenced from:
CGAL::Gmpq_rep::Gmpq_rep()in hit.o
"___gmpq_clear", referenced from:
CGAL::Gmpq_rep::~Gmpq_rep()in hit.o
"boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)", referenced from:
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::~thread_specific_ptr()in hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::~thread_specific_ptr()in hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::reset(CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >*)in hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::reset(CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >*)in hit.o
"boost::detail::get_tss_data(void const*)", referenced from:
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::get() constin hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::get() constin hit.o
"CGAL::precondition_fail(char const*, char const*, int, char const*)", referenced from:
CGAL::Handle::Handle(CGAL::Handle const&)in hit.o
CGAL::Handle::operator=(CGAL::Handle const&)in hit.o
CGAL::Uncertain<bool>::Uncertain(bool, bool)in hit.o
CGAL::Uncertain<CGAL::Sign>::Uncertain(CGAL::Sign, CGAL::Sign)in hit.o
"_mpfr_init2", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"_mpfr_set_q", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"_mpfr_get_d", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"_mpfr_clear", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"___gmpq_set_d", referenced from:
CGAL::Gmpq::Gmpq(double)in hit.o
"___gmpq_cmp", referenced from:
CGAL::Gmpq::operator<(CGAL::Gmpq const&) constin hit.o
"___gmpq_sub", referenced from:
CGAL::Gmpq::operator-=(CGAL::Gmpq const&)in hit.o
"___gmpq_mul", referenced from:
CGAL::Gmpq::operator*=(CGAL::Gmpq const&)in hit.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [Hit] Error 1
I am trying to use CGAL on OS X 10.7 with Eclipse. I installed CGAL via MacPorts and made Eclipse aware of that by adding /opt/local/include to it's include lists. Now I get linker errors. I am a bit lost here, do you have any suggestions?
This is how I compile:
make all
Building file: ../hit.cpp
Invoking: Cross G++ Compiler
g++ -I/opt/local/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"hit.d" -MT"hit.d" -o "hit.o" "../hit.cpp"
Finished building: ../hit.cpp
Building target: Hit
Invoking: Cross G++ Linker
g++ -o "Hit" ./hit.o
Undefined symbols for architecture x86_64:
"CGAL::assertion_fail(char const*, char const*, int, char const*)", referenced from:
CGAL::Interval_nt<false>::Interval_nt(double)in hit.o
CGAL::Interval_nt<false>::Interval_nt(double, double)in hit.o
bool CGAL::get_certain<bool>(CGAL::Uncertain<bool>)in hit.o
CGAL::Interval_nt<false>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()in hit.o
CGAL::Interval_nt<true>::Test_runtime_rounding_modes::Test_runtime_rounding_modes()in hit.o
CGAL::Gmpq::Gmpq(double)in hit.o
bool CGAL::internal::seg_seg_do_intersect_crossing<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >(CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >::Point_2 const&, CGAL::Simple_cartesian<CGAL::Interval_nt<false> > const&)in hit.o
...
"___gmpq_init", referenced from:
CGAL::Gmpq_rep::Gmpq_rep()in hit.o
"___gmpq_clear", referenced from:
CGAL::Gmpq_rep::~Gmpq_rep()in hit.o
"boost::detail::set_tss_data(void const*, boost::shared_ptr<boost::detail::tss_cleanup_function>, void*, bool)", referenced from:
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::~thread_specific_ptr()in hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::~thread_specific_ptr()in hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::reset(CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >*)in hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::reset(CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > >*)in hit.o
"boost::detail::get_tss_data(void const*)", referenced from:
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Segment_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::get() constin hit.o
boost::thread_specific_ptr<CGAL::Lazy<CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false> > >, CGAL::Point_2<CGAL::Simple_cartesian<CGAL::Gmpq> >, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false> >, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false> > > > >::get() constin hit.o
"CGAL::precondition_fail(char const*, char const*, int, char const*)", referenced from:
CGAL::Handle::Handle(CGAL::Handle const&)in hit.o
CGAL::Handle::operator=(CGAL::Handle const&)in hit.o
CGAL::Uncertain<bool>::Uncertain(bool, bool)in hit.o
CGAL::Uncertain<CGAL::Sign>::Uncertain(CGAL::Sign, CGAL::Sign)in hit.o
"_mpfr_init2", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"_mpfr_set_q", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"_mpfr_get_d", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"_mpfr_clear", referenced from:
CGAL::Real_embeddable_traits<CGAL::Gmpq>::To_interval::operator()(CGAL::Gmpq const&) constin hit.o
"___gmpq_set_d", referenced from:
CGAL::Gmpq::Gmpq(double)in hit.o
"___gmpq_cmp", referenced from:
CGAL::Gmpq::operator<(CGAL::Gmpq const&) constin hit.o
"___gmpq_sub", referenced from:
CGAL::Gmpq::operator-=(CGAL::Gmpq const&)in hit.o
"___gmpq_mul", referenced from:
CGAL::Gmpq::operator*=(CGAL::Gmpq const&)in hit.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [Hit] Error 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CGAL 使用 cmake 作为构建工具,并且使用 CGAL 的程序应使用的所有编译器标志都在文件 CGALConfig.cmake 中设置。
就您而言,您至少缺少 -lCGAL -lgmp -lmpfr -lboost_thread。
另请查看 CGALConfig.cmake 文件以检查所需的 gcc 选项(例如 frounding-math)。
请注意,cmake 可以为 eclipse 生成 makefile。
CGAL uses cmake as building tool and all compiler flags that should be used for a program using CGAL are set up in the file CGALConfig.cmake.
In your case, you are at least missing -lCGAL -lgmp -lmpfr -lboost_thread.
Also look at your CGALConfig.cmake files to check gcc options required (such as frounding-math for example).
Note that cmake can generate makefiles for eclipse.
虽然不在 Eclipse 中,但这对我有用:
然后执行二进制文件:
Although not in Eclipse, this works for me:
Then to execute the binary: