Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何在生成时修改.dylib的安装名称_Macos_Shared Libraries_Autoconf_Install Name Tool - Fatal编程技术网

Macos 如何在生成时修改.dylib的安装名称

Macos 如何在生成时修改.dylib的安装名称,macos,shared-libraries,autoconf,install-name-tool,Macos,Shared Libraries,Autoconf,Install Name Tool,我在Mac OS X(107.1)上为C++构建命令行标志库。构建过程如下所示: $ ./configure --prefix=output $ make $ make install 我想在生成时更改生成的共享库的安装名称,以后不要使用install\u name\u tool 默认情况下,生成的共享库的输出路径为libgflags.dylib: $ otool -L ./output/libgflags.dylib $ ./output/libgflags.dylib: /tmp

我在Mac OS X(107.1)上为C++构建命令行标志库。构建过程如下所示:

$ ./configure --prefix=output
$ make
$ make install 
我想在生成时更改生成的共享库的安装名称,以后不要使用
install\u name\u tool

默认情况下,生成的共享库的输出路径为
libgflags.dylib

$ otool -L ./output/libgflags.dylib
$ ./output/libgflags.dylib:
    /tmp/gflags-1.5/output/lib/libgflags.0.dylib (compatibility version 2.0.0, current version 2.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0) 
ld(1)
的手册页有一个
-install\u name
选项,可用于在链接时更改动态库的安装名称

例如,对于虚拟程序:

$ g++ -dynamiclib temp.cc -install_name /tmp/temp.dylib -o temp.dylib
$ otool -L temp.dylib 
temp.dylib:
    /tmp/temp.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)
但是,我无法将此命令行选项与
/configure
脚本一起使用。我已尝试手动设置
CFLAGS
变量,但这会导致错误:

$ CFLAGS="-install_name /tmp/desired/location/libgflags.dylib" ./configure
checking for a BSD-compatible install... /opt/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/vibhav/Code/install_name_test/gflags-1.5':
configure: error: C compiler cannot create executables

那么,我是否可以更改由
configure
make
生成的.dylib的安装名称而不使用
install\u name\u tool
。因此,如果要将“-install_name/tmp/temp.dylib”传递给链接器,则需要调用以下命令:

g++ -Wl,-install_name,/tmp/temp.dylib ...

一种可能的方法是手动编辑config.status。但在我尝试这么做之前,
install\u name\u tool-id
救了我的命。

我不明白你想做什么。为什么不能简单地运行
/configure--prefix/tmp/desired/location
?这是一个有效的问题。由于各种原因,我无法将
--prefix
设置到该位置,包括我的构建位置与应用程序的“安装”位置不同。我只想在使用
configure
时传递相应的链接器标志。我仍然不清楚您的场景。您能解释一下标准的
/configure--prefix/where&&make&&makeinstall
对于您的安装是如何错误的吗?为什么构建位置很重要?(当然,您应该使用绝对前缀。)您是否试图在不安装的情况下链接到
libglflags
?(在这种情况下,您应该使用
libtool
将您的应用程序链接到
libflag.la
,并让libtool发挥其神奇作用,链接到未安装的库。)在将库复制到最终位置之前,是否要将库安装到临时位置?(这是DESTDIR变量的工作。)苹果的人建议使用
-headerpad\u max\u install\u names
来编译和链接。然后,当您
makeinstall
时,您使用
install\u name\u工具
更新记录,使其指向完全限定的路径名(即
/usr/local/lib/libfoo.dylib
)。Nick X基本上回答了相同的问题,但他没有提到苹果的建议或
-headerpad\u max\u install\u name