How to specify RPATH in a makefile?

你离开我真会死。 提交于 2019-11-29 23:57:29

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!