与OS X 10.10.2的“__mpf_struct”相关的未定义符号错误

时间:2015-03-05 23:22:15

标签: gcc boost osx-yosemite gmp mpfr

我正在尝试从

编译程序

https://github.com/davidsd/sdpb

在OS X 10.10.2上使用gcc-4.9,boost 1.57.0,gmp-6.0.0a和mpfr-3.1.2,但我一直在收到与gmp和mpfr软件包相关的错误。我认识一个在10.9.5上成功编译的人。任何人都可以建议修复吗?


架构x86_64的未定义符号:   “operator<<(std :: basic_ostream>&,__ mpf_struct const *)”,引自:

  operator<<(std::basic_ostream<char, std::char_traits<char> >&, Matrix const&) in Matrix.o
  operator<<(std::basic_ostream<char, std::char_traits<char> >&, SDPSolverParameters const&) in SDPSolverIO.o
  SDPSolver::saveSolution(SDPSolverTerminateReason, boost::filesystem::path const&)  in SDPSolverIO.o
  std::basic_ostream<char, std::char_traits<char> >& operator<< <__gmp_expr<__mpf_struct [1], __mpf_struct [1]> >(std::basic_ostream<char, std::char_traits<char> >&, std::vector<__gmp_expr<__mpf_struct [1], __mpf_struct [1]>, std::allocator<__gmp_expr<__mpf_struct [1], __mpf_struct [1]> > > const&) in SDPSolverIO.o
  void boost::serialization::save<boost::archive::text_oarchive>(boost::archive::text_oarchive&, __gmp_expr<__mpf_struct [1], __mpf_struct [1]> const&, unsigned int) in SDPSolverIO.o
  solveSDP(boost::filesystem::path const&, boost::filesystem::path const&, boost::filesystem::path const&, SDPSolverParameters) in main.o
  boost::detail::lexical_converter_impl<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, __gmp_expr<__mpf_struct [1], __mpf_struct [1]> >::try_convert(__gmp_expr<__mpf_struct [1], __mpf_struct [1]> const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) in main.o
  ...

“operator&gt;&gt;(std :: basic_istream&gt;&amp;,__ mpf_struct *)”,引自:

  void boost::program_options::validate<__gmp_expr<__mpf_struct [1], __mpf_struct [1]>, char>(boost::any&, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, __gmp_expr<__mpf_struct [1], __mpf_struct [1]>*, long) in main.o

ld:找不到架构x86_64的符号 collect2:错误:ld返回1退出状态 make:*** [sdpb]错误1

1 个答案:

答案 0 :(得分:1)

在我的(linux)系统上,链接器命令行最终为

g++ -g -O2 -Wall -ansi -L/home/dsd/lib -Isrc/mpack -I/home/dsd/include -I/home/dsd/include/boost -fopenmp -D___MPACK_BUILD_WITH_GMP___ -MMD -lgomp -lgmp -lgmpxx -lboost_serialization -lboost_system -lboost_filesystem -lboost_timer -lboost_program_options -o sdpb obj/BlockDiagonalMatrix.o obj/main.o obj/Matrix.o obj/parse.o obj/SDP.o obj/SDPSolver.o obj/SDPSolverIO.o obj/mpack/iMlaenv.o obj/mpack/iRamax.o obj/mpack/Mlsame.o obj/mpack/Mxerbla.o obj/mpack/Raxpy.o obj/mpack/Rcopy.o obj/mpack/Rdot.o obj/mpack/Rgemm.o obj/mpack/RgemmParallel.o obj/mpack/Rgemv.o obj/mpack/Rger.o obj/mpack/Rgetf2.o obj/mpack/Rgetrf.o obj/mpack/Rgetrs.o obj/mpack/Rlae2.o obj/mpack/Rlaev2.o obj/mpack/Rlamch.o obj/mpack/Rlanst.o obj/mpack/Rlansy.o obj/mpack/Rlapy2.o obj/mpack/Rlarfb.o obj/mpack/Rlarf.o obj/mpack/Rlarfg.o obj/mpack/Rlarft.o obj/mpack/Rlartg.o obj/mpack/Rlascl.o obj/mpack/Rlaset.o obj/mpack/Rlasr.o obj/mpack/Rlasrt.o obj/mpack/Rlassq.o obj/mpack/Rlaswp.o obj/mpack/Rlatrd.o obj/mpack/Rnrm2.o obj/mpack/Rorg2l.o obj/mpack/Rorg2r.o obj/mpack/Rorgql.o obj/mpack/Rorgqr.o obj/mpack/Rorgtr.o obj/mpack/Rpotf2.o obj/mpack/Rpotf2Stabilized.o obj/mpack/Rpotrf.o obj/mpack/RpotrfStabilized.o obj/mpack/Rrot.o obj/mpack/Rrotg.o obj/mpack/Rscal.o obj/mpack/Rsteqr.o obj/mpack/Rsterf.o obj/mpack/Rswap.o obj/mpack/Rsyev.o obj/mpack/Rsymv.o obj/mpack/Rsyr2.o obj/mpack/Rsyr2k.o obj/mpack/Rsyrk.o obj/mpack/Rsytd2.o obj/mpack/Rsytrd.o obj/mpack/Rtrmm.o obj/mpack/Rtrmv.o obj/mpack/Rtrsm.o obj/mpack/Rtrsv.o obj/tinyxml2/tinyxml2.o

看起来排序错了。库应该跟随目标文件

当我将其修复为

g++ -g -O2 -Wall -ansi -L/home/dsd/lib -Isrc/mpack -I/home/dsd/include -I/home/dsd/include/boost -fopenmp -D___MPACK_BUILD_WITH_GMP___ -MMD obj/BlockDiagonalMatrix.o obj/main.o obj/Matrix.o obj/parse.o obj/SDP.o obj/SDPSolver.o obj/SDPSolverIO.o obj/mpack/iMlaenv.o obj/mpack/iRamax.o obj/mpack/Mlsame.o obj/mpack/Mxerbla.o obj/mpack/Raxpy.o obj/mpack/Rcopy.o obj/mpack/Rdot.o obj/mpack/Rgemm.o obj/mpack/RgemmParallel.o obj/mpack/Rgemv.o obj/mpack/Rger.o obj/mpack/Rgetf2.o obj/mpack/Rgetrf.o obj/mpack/Rgetrs.o obj/mpack/Rlae2.o obj/mpack/Rlaev2.o obj/mpack/Rlamch.o obj/mpack/Rlanst.o obj/mpack/Rlansy.o obj/mpack/Rlapy2.o obj/mpack/Rlarfb.o obj/mpack/Rlarf.o obj/mpack/Rlarfg.o obj/mpack/Rlarft.o obj/mpack/Rlartg.o obj/mpack/Rlascl.o obj/mpack/Rlaset.o obj/mpack/Rlasr.o obj/mpack/Rlasrt.o obj/mpack/Rlassq.o obj/mpack/Rlaswp.o obj/mpack/Rlatrd.o obj/mpack/Rnrm2.o obj/mpack/Rorg2l.o obj/mpack/Rorg2r.o obj/mpack/Rorgql.o obj/mpack/Rorgqr.o obj/mpack/Rorgtr.o obj/mpack/Rpotf2.o obj/mpack/Rpotf2Stabilized.o obj/mpack/Rpotrf.o obj/mpack/RpotrfStabilized.o obj/mpack/Rrot.o obj/mpack/Rrotg.o obj/mpack/Rscal.o obj/mpack/Rsteqr.o obj/mpack/Rsterf.o obj/mpack/Rswap.o obj/mpack/Rsyev.o obj/mpack/Rsymv.o obj/mpack/Rsyr2.o obj/mpack/Rsyr2k.o obj/mpack/Rsyrk.o obj/mpack/Rsytd2.o obj/mpack/Rsytrd.o obj/mpack/Rtrmm.o obj/mpack/Rtrmv.o obj/mpack/Rtrsm.o obj/mpack/Rtrsv.o obj/tinyxml2/tinyxml2.o -lgomp -lgmp -lgmpxx -lboost_serialization -lboost_system -lboost_filesystem -lboost_timer -lboost_program_options -o sdpb 

它在我的系统上没有错误链接

所以在Makefile中,将link命令改为

$(RESULT): $(OBJECTS)
    $(CC) $(CFLAGS) -o $@ $^ $(LIBS)