Skip to main content
Moved my site.
Source Link
ttsiodras
  • 628
  • 7
  • 14

If you want to avoid LD_LIBRARY_PATH, you can also do this, during linking:

gcc -o exename -L/path/to/dynamiclib/ -lnameofLib \
    -Wl,-R/path/to/dynamiclib/ sourceCode1.c ...

The -Wl,... is used to pass extra commands to the linker, and in this case, with -R you tell the linker to store this path as the "default search path" for the .so.

I keep notes of many small tips like this one, at my site:

http://users.softlab.ntua.gr/~ttsiod/tricks.htmlhttps://www.thanassis.space/tricks.html

If you want to avoid LD_LIBRARY_PATH, you can also do this, during linking:

gcc -o exename -L/path/to/dynamiclib/ -lnameofLib \
    -Wl,-R/path/to/dynamiclib/ sourceCode1.c ...

The -Wl,... is used to pass extra commands to the linker, and in this case, with -R you tell the linker to store this path as the "default search path" for the .so.

I keep notes of many small tips like this one, at my site:

http://users.softlab.ntua.gr/~ttsiod/tricks.html

If you want to avoid LD_LIBRARY_PATH, you can also do this, during linking:

gcc -o exename -L/path/to/dynamiclib/ -lnameofLib \
    -Wl,-R/path/to/dynamiclib/ sourceCode1.c ...

The -Wl,... is used to pass extra commands to the linker, and in this case, with -R you tell the linker to store this path as the "default search path" for the .so.

I keep notes of many small tips like this one, at my site:

https://www.thanassis.space/tricks.html

Source Link
ttsiodras
  • 628
  • 7
  • 14

If you want to avoid LD_LIBRARY_PATH, you can also do this, during linking:

gcc -o exename -L/path/to/dynamiclib/ -lnameofLib \
    -Wl,-R/path/to/dynamiclib/ sourceCode1.c ...

The -Wl,... is used to pass extra commands to the linker, and in this case, with -R you tell the linker to store this path as the "default search path" for the .so.

I keep notes of many small tips like this one, at my site:

http://users.softlab.ntua.gr/~ttsiod/tricks.html