奇怪的错误-链接到自己的库gcc时存在未定义的引用

时间:2018-09-07 13:50:23

标签: gcc g++ linker-errors

我在创建和链接库方面经验不足,但是这次我为这个愚蠢的事情而发疯。

> tdata  
    X     T3AM    T3AMx
1   1 03:00:00 03:00:00
2   2 03:00:00 03:00:00
3   3 03:00:00 03:00:00
4   4 03:00:00 03:00:00
5   5 03:00:00 03:00:00
6   6 03:00:00 03:00:00
7   7 03:00:00 03:00:00
8   8 03:00:00 03:00:00
9   9 03:00:00 03:00:00
10 10 03:00:00 03:00:00

确认我的lib已引用这些功能,例如下面的

rep.times

进一步确认,

-bash-3.2$ g++ -m32 src/main.cpp -Iinc -lblpapi3_32 -I/tmp/diff/include -L/tmp/diff/lib -lbbbmds
/tmp/ccQCKwnF.o: In function `main':
main.cpp:(.text+0x14e): undefined reference to `MDS::BloombergSource::BloombergSource()'
main.cpp:(.text+0x4ed): undefined reference to `MDS::BloombergSource::startSession()'
main.cpp:(.text+0x555): undefined reference to `MDS::BloombergSource::openService()'
main.cpp:(.text+0x560): undefined reference to `MDS::BloombergSource::authorize()'
main.cpp:(.text+0x5fc): undefined reference to `MDS::BloombergSource::AddSubscription(char const*, 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> > > >&, 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> > > >&, BloombergLP::blpapi::CorrelationId const&)'
main.cpp:(.text+0x655): undefined reference to `MDS::BloombergSource::subscribe()'
collect2: ld returned 1 exit status

-bash-3.2$ nm /tmp/diff/lib/libbbbmds.so |grep startSession
0000000000002a62 t _ZN3MDS15BloombergSource12startSessionEv

尝试重新排序libs / src。

1 个答案:

答案 0 :(得分:0)

nm输出列表MDS::BloombergSource::startSession()作为t的功能-具有内部链接的功能。此类功能无法从其他翻译部门获得。