gcc - /usr/bin/ld error: cannot find in /usr/local/lib though ldconfig list it, and path added to ld.so.conf

后端 未结 3 1485
有刺的猬
有刺的猬 2021-02-19 09:52

I try to compile a C++ code, using a library I\'ve also compiled manually and installed in /usr/local/lib

The compilation of the software fails at the linking step:

相关标签:
3条回答
  • 2021-02-19 10:20

    ld, the linker, does not use external configuration files for that. ldconfig is for the loader, ld.so. Create a makefile if you want to set values for the linker somewhere.

    0 讨论(0)
  • 2021-02-19 10:20
    1. You can use linker script, and add '/usr/local/lib' to search_dir. see this Linker_Scripts to get more details.

    2. add /usr/local/lib to GCC_EXEC_PREFIX shell environment, and try it again. more details search print-search-dirs in "man" of g++.

    just suggestion, it has not yet tried.

    0 讨论(0)
  • 2021-02-19 10:41

    Specifying -L switches in your makefile is a common way to deal with this problem, but you can actually make system-wide changes by modifying the default GCC spec file, which can be used to specify additional options to be passed to the compiler, linker, etc. I've done this in the past to address your specific problem, but it was a long time ago, so I can't give you a specific example, unfortunately.

    0 讨论(0)
提交回复
热议问题