gpt4 book ai didi

gcc - 与 OS X 10.10.2 的 "__mpf_struct"相关的 undefined symbol 错误

转载 作者:行者123 更新时间:2023-12-04 14:43:50 26 4
gpt4 key购买 nike

我正在尝试编译一个程序

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 的 undefined symbol : “运算符<<(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
...

“运算符>>(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

最佳答案

在我的 (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)

关于gcc - 与 OS X 10.10.2 的 "__mpf_struct"相关的 undefined symbol 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28889744/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com