Shared Library Path as Executable Directory

前端 未结 2 839
醉话见心
醉话见心 2021-02-04 09:14

I have an application that is broken into several libraries for purposes of code reuse. On Windows all I have to do is put the .dll files in the same path as the executable and

2条回答
  •  伪装坚强ぢ
    2021-02-04 10:00

    You need $ORIGIN in your RPATH, via an appropriate option to ld or other Darwin tool. See this and this.

    Remember that the $ has to really end up in the path, so you need to quote or escape it in the link command line.

    Update: You can see what the linker actually put into your executable with

    readelf -d /path/to/exe | grep RPATH
    

    Here is what the output should look like:

     0x0000000f (RPATH)              Library rpath: [$ORIGIN]
    

提交回复
热议问题