Jump to content

  • Log In with Google      Sign In   
  • Create Account

Wonder Boy

Member Since 18 Jun 2012
Offline Last Active Mar 18 2013 11:42 AM

#4951565 [SOLVED] My game doesn't detect libpng in its directory (game packaging)

Posted by on 21 June 2012 - 07:29 PM

I have to include '-rpath' flag with a specified directory in the command above so the directory will be searched at the runtime.

For example:
search the same dir as executable dir: -Wl,-rpath,.
search "libs" directory inside directory where is located executable: -Wl,-rpath,libs/

So now my command looks like this:
g++ *.cpp -I/my_include_dir/ -L/my_lib_dir/ -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL -lpthread -ldl -lfreetype -lz -Wl,-rpath,. -o build/tictactoe32 -m32

Useful commands:
Check which libraries will be loaded by the executable at runtime:
ldd <binary>
Check which directories will be searched for libraries:
readelf -d <binary> | grep RPATH

http://www.techytalk.info/c-cplusplus-library-programming-on-linux-part-one-static-libraries/ (3 parts)
in terminal: man ld