/usr/bin/ld: 找不到 -lconfig++

/usr/bin/ld: cannot find -lconfig++

我认为这是一个常见问题,但我想我已经尽力了。 当我尝试编译这个文件时:

g++ -o build/opt/fftoggle --static build/opt/fftoggle.o build/opt/config.o build/opt/galloc.o build/opt/log.o build/opt/pin_cmd.o -lconfig++ -lpthread

我得到/usr/bin/ld: cannot find -lconfig++

我假设这与 libconfig++ 库有关,我发现它位于 运行ning ld -lconfig++ --verbose

/usr/lib64/libconfig++.so

这是我在 运行 ld -lconfig++ --verbose

时得到的
attempt to open //usr/x86_64-redhat-linux/lib64/libconfig++.a failed
attempt to open //usr/lib64/libconfig++.so succeeded
-lconfig++ (//usr/lib64/libconfig++.so)
libstdc++.so.6 needed by //usr/lib64/libconfig++.so
found libstdc++.so.6 at /usr/local/lib64//libstdc++.so.6
libm.so.6 needed by //usr/lib64/libconfig++.so
found libm.so.6 at /usr/lib64/libm.so.6
libc.so.6 needed by //usr/lib64/libconfig++.so
found libc.so.6 at /usr/lib64/libc.so.6
libgcc_s.so.1 needed by //usr/lib64/libconfig++.so
found libgcc_s.so.1 at /usr/local/lib64//libgcc_s.so.1
ld-linux-x86-64.so.2 needed by /usr/local/lib64//libstdc++.so.6
found ld-linux-x86-64.so.2 at /usr/lib64/ld-linux-x86-64.so.2
ld: warning: cannot find entry symbol _start; not setting start address

现在,我的 LD_LIBRARY_PATH 的路径中已经有 /usr/lib64/ 但我仍然面临这个问题,除此之外,我还尝试通过在编译命令中链接库来进行编译:

g++ -o build/opt/fftoggle --static build/opt/fftoggle.o build/opt/config.o build/opt/galloc.o build/opt/log.o build/opt/pin_cmd.o -L/usr/lib64/ -lconfig++ -lpthread

仍然没有运气。我是不是遗漏了什么或者 -lconfig++libconfig++

无关

我认为问题在于您需要一个静态库,但没有。

g++ -o build/opt/fftoggle --static

我不确定为什么会这样;选项是 -static(一个破折号)。 info gcc-static 阻止与 [原文如此] 共享库 的链接。 ld 告诉你没有这样的:

attempt to open //usr/x86_64-redhat-linux/lib64/libconfig++.a failed

顺便说一句,

My LD_LIBRARY_PATH already has /usr/lib64/

LD_LIBRARY_PATH 不被静态链接器使用。它会影响 runtime 链接器在加载可执行文件时搜索动态库的方式。