【问题标题】:Boost static linking in unix提升 unix 中的静态链接
【发布时间】:2012-06-29 06:09:28
【问题描述】:

我在 Unix 中使用 Boost 库,GCC。我阅读了以下主题:Boost static linking 并将 -static 添加到我的 Makefile 中。但是,这不起作用。

这是我的 Makefile:

all: nbbo

nbbo: nbbo.o reader.o
    g++ -static -O3 -ffast-math -funroll-loops -ansi -pedantic-errors -L/usr/lib -lboost_filesystem -lboost_serialization -lboost_iostreams -lz -I /usr/include/boost -o nbbo nbbo.o reader.o

nbbo.o: nbbo.cpp
    g++ -static -O3 -ffast-math -funroll-loops -ansi -pedantic-errors -I /usr/include/boost -c -o nbbo.o nbbo.cpp

reader.o: reader.cc reader.h
    g++ -static -O3 -ffast-math -funroll-loops -ansi -pedantic-errors -I /usr/include/boost -c -o reader.o reader.cc

clean:
    rm *.o

这是错误信息:

nbbo.o: In function `__tcf_10':
nbbo.cpp:(.text+0x3d9): undefined reference to `boost::serialization::extended_type_info::key_unregister() const'
nbbo.cpp:(.text+0x3e3): undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::type_unregister()'
nbbo.cpp:(.text+0x3fb): undefined reference to `boost::serialization::typeid_system::extended_type_info_typeid_0::~extended_type_info_typeid_0()'
etc

【问题讨论】:

    标签: boost static-linking


    【解决方案1】:

    您使用的是哪个“UNIX”?使用 -static 标志应该可以在 linux 上正常工作。但不是在 OSX 上。在 OSX 上,您必须删除静态标志并提供库的完整路径才能静态链接。我不知道这将如何在其他“UNIX”上工作

    例如。

    g++ ..... /path/to/your/lib.a ... -o ..
    

    【讨论】:

      猜你喜欢
      • 2011-01-20
      • 2012-12-17
      • 1970-01-01
      • 1970-01-01
      • 2011-06-26
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      • 2020-10-14
      相关资源
      最近更新 更多