Note: The Listed platform will permanently shut down December 31, 2026. Your data published on Listed will still be available in your personal Standard Notes account. Learn more

Linking .so Shared Object File with Relative Path in GCC (G++)

These options must be together for finding the .so files:

  • -Wl,-rpath,RELATIVE_PATH_FROM_DOT
  • -LRELATIVE_PATH_FROM_DOT
  • -l:DSO_FILE_NAME

For example:

  • g++ -shared -o file.so file.cpp -fPIC -Wl,-rpath,. -L. -l:mylib.so
  • g++ -shared -o file.so file.cpp -fPIC -wl,-rpath,./libs -L./libs -l:mylib.so

The -Wl,-rpath and -L must be together, and the -l must come with colon
after to specify the exact file name.


You'll only receive email when they publish something new.

More from 19331933
All posts