【问题标题】:Unresolved symbols linking static libraries链接静态库的未解析符号
【发布时间】:2016-01-19 21:19:53
【问题描述】:

我通过静态库和动态库的链接获得了一些未定义的引用。

我的目标是获得一个带有静态链接的 poco 和 uiohook 库的可执行文件。为了指定静态链接,我提供了库的直接路径,有些是path/libName.a

以下命令:

/home/lrleon/LLVM-3.7/bin/clang -o collector -g -O2 -fno-strict-aliasing \
collector.o common-vars.o collector-events.o listeners.o \
active_window.o ../lib/libperfq-common.a \
/home/lrleon/aleph-w/libAleph.a /home/lrleon/poco/lib/libPocoNet.a \
/home/lrleon/poco/lib/libPocoFoundation.a /home/lrleon/uiohook/lib/libuiohook.a \
-lstdc++ -lX11 -lcairo -lgsl -lgslcblas -lpthread -lc 

给我以下错误:

/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::dayOfWeek() const: error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::toJulianDay(int, int, int, int, int, int, int, int): error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::toJulianDay(int, int, int, int, int, int, int, int): error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(DateTime.o):DateTime.cpp:function Poco::DateTime::toJulianDay(int, int, int, int, int, int, int, int): error: undefined reference to 'floor'
/home/lrleon/poco/lib/libPocoFoundation.a(NumericString.o):NumericString.cpp:function double_conversion::PowersOfTenCache::GetCachedPowerForBinaryExponentRange(int, int, double_conversion::DiyFp*, int*): error: undefined reference to 'ceil'
/home/lrleon/poco/lib/libPocoFoundation.a(NumericString.o):NumericString.cpp:function double_conversion::BignumDtoa(double, double_conversion::BignumDtoaMode, int, double_conversion::Vector<char>, int*, int*): error: undefined reference to 'ceil'
/home/lrleon/poco/lib/libPocoFoundation.a(NumericString.o):NumericString.cpp:function Poco::floatToStr(std::string&, float, int, int, char, char): error: undefined reference to 'floorf'
src/x11/input_hook.c:673: error: undefined reference to 'XRecordFreeData'
src/x11/input_hook.c:722: error: undefined reference to 'XRecordQueryVersion'
src/x11/input_hook.c:733: error: undefined reference to 'XRecordAllocRange'
src/x11/input_hook.c:745: error: undefined reference to 'XRecordCreateContext'
src/x11/input_hook.c:792: error: undefined reference to 'XRecordEnableContext'
src/x11/input_hook.c:812: error: undefined reference to 'XRecordFreeContext'
src/x11/input_hook.c:883: error: undefined reference to 'XRecordGetContext'
src/x11/input_hook.c:885: error: undefined reference to 'XRecordDisableContext'
src/x11/system_properties.c:134: error: undefined reference to 'XineramaIsActive'
src/x11/system_properties.c:136: error: undefined reference to 'XineramaQueryScreens'
src/x11/system_properties.c:396: error: undefined reference to 'XtGetMultiClickTime'
src/x11/system_properties.c:480: error: undefined reference to 'XtToolkitInitialize'
src/x11/system_properties.c:481: error: undefined reference to 'XtCreateApplicationContext'
src/x11/system_properties.c:485: error: undefined reference to 'XtOpenDisplay'
src/x11/system_properties.c:502: error: undefined reference to 'XtCloseDisplay'
src/x11/system_properties.c:503: error: undefined reference to 'XtDestroyApplicationContext'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我不明白为什么找不到某些符号。例如,ceilfloor 被 poco 库引用,但这些符号属于 c 标准库。据我了解,这些符号应该是可解析的,因为 c 库是在最后链接的;那是在 poco 图书馆之后。类似于对 X11 符号的引用,我认为这些符号是用 libuiohook 引用的,并且链接顺序 -lX11 是在后面给出的

知道我做错了什么吗?提前致谢

【问题讨论】:

    标签: c++ linker poco-libraries


    【解决方案1】:

    floor 和 ceil 函数在数学库中定义,我没有看到您使用 -lm 标志与 libm 链接

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-14
      • 1970-01-01
      • 2013-09-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多