提问人:Przemysław Czechowski 提问时间:8/1/2018 最后编辑:pseyfertPrzemysław Czechowski 更新时间:8/1/2018 访问量:607
未定义的引用,尽管符号存在于 .so 中
Undefined reference although symbol present in .so
问:
免责声明:我知道像这样那样的问题,但没有什么能帮助我解决我的问题。
我正在尝试编译一个依赖于ROOT包的更大项目,并且我能够在最小的示例中重现我面临的错误:
测试.cpp:
#include "Math/GenVector/GenVector_exception.h"
int main()
{
ROOT::Math::GenVector::Throw("foo");
}
编译方式: 给出:g++ -lGenVector test.cpp
/tmp/ccq9A45m.o: In function `main':
test.cpp:(.text+0xc): undefined reference to `ROOT::Math::GenVector::Throw(char const*)'
collect2: error: ld returned 1 exit status
本地化 libGenVector.so 提供:ld --verbose -lGenVector | grep "lib GenVector.so succeeded"
attempt to open //usr/local/lib/libGenVector.so succeeded
检查是否在库中定义了符号,并给出:nm -DgC --defined-only /usr/local/lib/libGenVector.so| grep Throw
000000000003f180 T ROOT::Math::Throw(ROOT::Math::GenVector_exception&)
000000000003f1e0 T ROOT::Math::GenVector::Throw(char const*)
根据对这个问题的回答,我还尝试使用 and 和进行编译,但一切都给出了相同的错误消息。-std=c++11
-std=c++14
-std=c++17
答: 暂无答案
评论
A
B
A
B
g++ test.cpp -lGenVector
root-config --cflags
-std=c++1?