如何将 MacPort 的 libiconv 替换为 Mac 默认的 64 位版本?

发布于 2024-12-15 09:51:23 字数 747 浏览 6 评论 0原文

MacPorts 安装了“libiconv @1.14_0+universal”作为我系统的依赖项。这恰好是 32 位版本,当我尝试编译名为 Simon Listens 的语音识别软件时,它开始引起问题。 在谷歌搜索时,我发现 Mac 实际上附带了 默认情况下为 64 位 libiconv,我能够在我的系统上找到上述文件:

$ find /usr/lib -name libiconv*
/usr/lib/libiconv.2.4.0.dylib
/usr/lib/libiconv.2.dylib
/usr/lib/libiconv.dylib

为了使用系统库,我可以采用的最快方法想到的方法是卸载 MacPort 的 libiconv 版本,以便系统的库最终会被选为后备库,因为它必须已经在 PATH 楼下的某个位置出现(我的猜测)。

但由于依赖关系而失败了:

$ sudo port uninstall libiconv @1.14_0+universal
Unable to uninstall libiconv @1.14_0+universal, the following ports depend on it:
...

所以现在我的问题是如何告诉 MacPort 替换其依赖关系图以指向并使用我系统上已有的库?

MacPorts installed "libiconv @1.14_0+universal" as a dependency on my system. This happens to be a 32-bit flavor and it started causing issue when I tried to compile a voice recognition software called Simon Listens.
While googling I found out that that Mac actually ships with a 64-bit flavor of libiconv by default and I was able to locate the said files on my system:

$ find /usr/lib -name libiconv*
/usr/lib/libiconv.2.4.0.dylib
/usr/lib/libiconv.2.dylib
/usr/lib/libiconv.dylib

In order to use the system library, the quickest way I could think of was to uninstall MacPort's version of libiconv so that the system's library would end up getting selected as a fallback as it has to present (my guess) somewhere downstairs on the PATH already.

But that failed due to dependecies:

$ sudo port uninstall libiconv @1.14_0+universal
Unable to uninstall libiconv @1.14_0+universal, the following ports depend on it:
...

So now my question is how can I tell MacPort to replace its dependency graph to point to and use the library already on my system?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黑寡妇 2024-12-22 09:51:23

避免 MacPorts libiconv 问题的另一种方法是针对新的版本构建 simon MacPorts 系统加上自定义的必要软件包,例如 cyrus-sasl2、zlib、portaudio 和 kdesdk4位置,例如 /opt/macports-simon

以下代码在运行 Mac OS X 10.6.8 的计算机上适用于我:

# compile simon on Mac OS X 10.6.8 using MacPorts for the installation of zlib, portaudio and kdesdk4
# http://www.simon-listens.org
# http://sourceforge.net/projects/speech2text/

# get a root shell
sudo -H -i  

# prevent idle sleep
pmset -a force sleep 0 displaysleep 0 disksleep 0

mv -i /opt/local /opt/local-off
mv -i /usr/local /usr/local-off

cd /tmp
mkdir buildsimon || exit 1
cd buildsimon || exit 1

# create custom /opt/macports-simon to install zlib, portaudio and kdesdk4
# cf. http://guide.macports.org/#installing.macports.source.multiple
MP_PREFIX='/opt/macports-simon'
unset PATH
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
curl -L -O https://distfiles.macports.org/MacPorts/MacPorts-2.0.4.tar.bz2
tar -xjf MacPorts-2.0.4.tar.bz2
cd MacPorts-2.0.4 || exit 1
./configure --prefix="${MP_PREFIX}" --with-applications-dir="${MP_PREFIX}/Applications"
make
make install

cd /tmp/buildsimon

unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"

# get the Portfiles and update the system
port -v selfupdate

# install cyrus-sasl2
port -f uninstall cyrus-sasl2
port clean --all cyrus-sasl2
port extract cyrus-sasl2
cd "$(port dir cyrus-sasl2)"/work/cyrus-sasl-2.1.23
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s config/ltconfig
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s saslauthd/config/ltconfig
cd /tmp/buildsimon
port -f -s install cyrus-sasl2
otool -L /opt/macports-simon/lib/libsasl2.dylib

port -f install zlib
port -f install portaudio
port -f install kdesdk4

port installed zlib portaudio kdesdk4 cyrus-sasl2

# enable dbus with launchd
# http://www.freedesktop.org/wiki/Software/dbus
# open -e dbus-1.5.8/README.launchd
launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist 
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
sudo -u _mysql mysql_install_db5
sudo port load mysql5-server

# todo: how to configure simon to use /opt/macports-simon directly?
ln -isv "${MP_PREFIX}" /usr/local

cd /tmp/buildsimon

# http://sourceforge.net/projects/speech2text/
curl -L -O http://netcologne.dl.sourceforge.net/project/speech2text/simon/0.3.0/simon-0.3.0.tar.bz2
tar -xjf simon-0.3.0.tar.bz2 
cd simon-0.3.0 || exit 1

# Note that /usr/local got symlinked to "${MP_PREFIX}" above!
unset PATH
export PATH='/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin'


# the following commands are taken from simon-0.3.0/build.sh

mkdir build 2> /dev/null
cd build || exit 1
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..

# append ${MP_PREFIX}/lib/libiconv.dylib to gcc command in link.txt file
printf '%s\n' H '/\/usr\/bin\/gcc/s|\(.*\)|\1 '"${MP_PREFIX}"'/lib/libiconv.dylib|' wq | 
   ed -s julius/julius/CMakeFiles/juliusexe.dir/link.txt

# replace gcc option ' -bundle ' with ' -dynamiclib '
egrep -Ilsr -Z -e ' -bundle ' . | 
   xargs -0 -n 1 /bin/sh -c 'printf "%s\n" H "g/ -bundle /s// -dynamiclib /g" wq | /bin/ed -s "${1}"' argv0

make

touch ./julius/gramtools/mkdfa/mkfa-1.44-flex/* 
make 
make install
# ldconfig    # not needed on Mac OS X
kbuildsycoca4 
echo -e "**** Build completed ****\n\nThe executable file \"simon\" is now ready and has been installed.\n\nIssue \"simon\" to start it."

unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"

otool -L "${MP_PREFIX}/bin/simon"

simon

mv -i /opt/local-off /opt/local 
mv -i /usr/local-off /usr/local 

Another approach to avoid MacPorts libiconv issues would be to build simon against a fresh MacPorts system plus the necessary packages such as cyrus-sasl2, zlib, portaudio and kdesdk4 in a custom location, e. g. /opt/macports-simon.

The following code worked for me on my machine running Mac OS X 10.6.8:

# compile simon on Mac OS X 10.6.8 using MacPorts for the installation of zlib, portaudio and kdesdk4
# http://www.simon-listens.org
# http://sourceforge.net/projects/speech2text/

# get a root shell
sudo -H -i  

# prevent idle sleep
pmset -a force sleep 0 displaysleep 0 disksleep 0

mv -i /opt/local /opt/local-off
mv -i /usr/local /usr/local-off

cd /tmp
mkdir buildsimon || exit 1
cd buildsimon || exit 1

# create custom /opt/macports-simon to install zlib, portaudio and kdesdk4
# cf. http://guide.macports.org/#installing.macports.source.multiple
MP_PREFIX='/opt/macports-simon'
unset PATH
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
curl -L -O https://distfiles.macports.org/MacPorts/MacPorts-2.0.4.tar.bz2
tar -xjf MacPorts-2.0.4.tar.bz2
cd MacPorts-2.0.4 || exit 1
./configure --prefix="${MP_PREFIX}" --with-applications-dir="${MP_PREFIX}/Applications"
make
make install

cd /tmp/buildsimon

unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"

# get the Portfiles and update the system
port -v selfupdate

# install cyrus-sasl2
port -f uninstall cyrus-sasl2
port clean --all cyrus-sasl2
port extract cyrus-sasl2
cd "$(port dir cyrus-sasl2)"/work/cyrus-sasl-2.1.23
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s config/ltconfig
printf '%s\n' H '/\(darwin\[15\]\)/s//\1./g' wq | sudo ed -s saslauthd/config/ltconfig
cd /tmp/buildsimon
port -f -s install cyrus-sasl2
otool -L /opt/macports-simon/lib/libsasl2.dylib

port -f install zlib
port -f install portaudio
port -f install kdesdk4

port installed zlib portaudio kdesdk4 cyrus-sasl2

# enable dbus with launchd
# http://www.freedesktop.org/wiki/Software/dbus
# open -e dbus-1.5.8/README.launchd
launchctl load -w /Library/LaunchDaemons/org.freedesktop.dbus-system.plist 
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
sudo -u _mysql mysql_install_db5
sudo port load mysql5-server

# todo: how to configure simon to use /opt/macports-simon directly?
ln -isv "${MP_PREFIX}" /usr/local

cd /tmp/buildsimon

# http://sourceforge.net/projects/speech2text/
curl -L -O http://netcologne.dl.sourceforge.net/project/speech2text/simon/0.3.0/simon-0.3.0.tar.bz2
tar -xjf simon-0.3.0.tar.bz2 
cd simon-0.3.0 || exit 1

# Note that /usr/local got symlinked to "${MP_PREFIX}" above!
unset PATH
export PATH='/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin'


# the following commands are taken from simon-0.3.0/build.sh

mkdir build 2> /dev/null
cd build || exit 1
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..

# append ${MP_PREFIX}/lib/libiconv.dylib to gcc command in link.txt file
printf '%s\n' H '/\/usr\/bin\/gcc/s|\(.*\)|\1 '"${MP_PREFIX}"'/lib/libiconv.dylib|' wq | 
   ed -s julius/julius/CMakeFiles/juliusexe.dir/link.txt

# replace gcc option ' -bundle ' with ' -dynamiclib '
egrep -Ilsr -Z -e ' -bundle ' . | 
   xargs -0 -n 1 /bin/sh -c 'printf "%s\n" H "g/ -bundle /s// -dynamiclib /g" wq | /bin/ed -s "${1}"' argv0

make

touch ./julius/gramtools/mkdfa/mkfa-1.44-flex/* 
make 
make install
# ldconfig    # not needed on Mac OS X
kbuildsycoca4 
echo -e "**** Build completed ****\n\nThe executable file \"simon\" is now ready and has been installed.\n\nIssue \"simon\" to start it."

unset PATH
export PATH="${MP_PREFIX}/bin:/bin:/sbin:/usr/bin:/usr/sbin"

otool -L "${MP_PREFIX}/bin/simon"

simon

mv -i /opt/local-off /opt/local 
mv -i /usr/local-off /usr/local 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文