1

I have been trying to link the custom library to my cpp files using the following comamnd

g++ xx.cpp -I .../mydir/ -lfoo

where foo located in ../mydir and added this directory in LD_LIBRARY_PATH and executed ldconfig command and can find this directory listed when i execute the command

/sbin/ldconfig -v | grep -v "^"$'\t' | sed "s/:$//g"

however ld (linker script) lists the other directories which are not in ldconfig which i found by executing the following command

# ld -lfoo --verbose

I found linker search Dir commands directories using the following command

$ gcc -m64 -Xlinker --verbose 2>/dev/null | grep SEARCH | sed 's/SEARCH_DIR("=\?([^"]+)"); */\1\n/g' | grep -vE '^$'

I moved the custom lib to /usr/lib which is in search path dir's and get incompatible error during linking .

would appreciate if any leads to appending a directory to search path dir's of linker script.

pari
  • 185
  • 1
  • 1
  • 10
  • I am able to get through incompatible moving custom library to /usr/lib by compiling it as 32 bit application, however I am still curious to know if there is way to append directories to search dir of linker script of GNU – pari Aug 14 '18 at 04:10
  • Whenever I see a question like this... It is sad Linux still has not fixed the library path problems after 25 years or so. BSDs, OS X, Solaris and even Microsoft managed to fix it. Only the Linux folks claim linking to the wrong library at runtime is the dominant use case. – jww Aug 14 '18 at 04:45
  • *"I moved the custom lib to /usr/lib which is in search path dir's and get incompatible error during linking..."* - You may need to place it at `/usr/lib64`. Fedora and friends use `/usr/lib64` instead of `/usr/lib`. What distro are you using? – jww Aug 14 '18 at 04:47
  • custom library was 32 bit application , compiling it as 32 bit application using -m32 option with g++ worked for me – pari Aug 15 '18 at 08:54

0 Answers0