3

我正在尝试从

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>>(std::basic_istream >&, __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

4

1 回答 1

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 中,将链接命令更改为

$(RESULT): $(OBJECTS)
    $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
于 2015-03-05T23:30:26.777 回答