如何在构建时修改

如何在构建时修改

本文介绍了如何在构建时修改.dylib的安装名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Mac OS上的C ++构建 google-gflags 命令行标志库X(10.7.1).构建过程如下:

I am building the google-gflags commandline flags library for C++ on Mac OS X (10.7.1). The build process is as such:

$ ./configure --prefix=output
$ make
$ make install

我想在生成时更改生成的共享库的安装名称,并且此后不使用install_name_tool.

I'd like to change the install name of the generated shared library at build time and not use install_name_tool afterwards.

默认情况下,生成的共享库libgflags.dylib的安装名称是输出路径:

By default, the install name of the generated shared library, libgflags.dylib, is the output path:

$ 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_name选项,可用于在链接时更改动态库的安装名称.

The man page for ld(1) has a -install_name option which can be used to change the install name of a dynamic library at link-time.

例如,使用虚拟程序:

$ 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变量,但这会导致错误:

But, I am unable to use this command line option with the ./configure script. I've tried manually setting the CFLAGS variable, but that results in a error:

$ 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

那么,我是否可以在不使用install_name_tool的情况下更改由configuremake生成的.dylib的安装名称?

So, is it possible for me to change the install name of .dylib generated by configure and make without using install_name_tool?

推荐答案

一种可能的方法是手动编辑config.status.但是在我尝试这样做之前,install_name_tool -id挽救了我的生命.

one possible approach would be editing the config.status manually. but before I try to do that, install_name_tool -id saved my life.

这篇关于如何在构建时修改.dylib的安装名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 11:50