I\'m trying to specify rpath in my binary. My makefile looks like this-
CC=gcc
CFLAGS=-Wall
LDFLAGS= -rpath=\'../libs/\'
main: main.c
gcc -o main ma
If you set the variables, you should probably use them. It's silly not to, especially when make won't magically set those variables for you! :)
main: main.c
$(CC) $(CFLAGS) $(LDFLAGS) -o main main.c
Another problem is LDFLAGS
, it should be
LDFLAGS="-Wl,-rpath,../libs/"
The usual gcc switch for passing options to linker is -Wl,
, and it is needed because gcc itself may not understand the bare -rpath
linker option. While some builds of various versions of gcc accept -rpath
, I have never seen it documented in gcc man pages or info pages. For better portability, -Wl,-rpath
should be preferred.