如何告诉Homebrew我确实满足安装pygame所需的sdl_ttf库依赖?
我刚开始用brew,之前用得挺顺利的。现在我想安装pygame,但在一个叫sdl_ttf
的依赖上卡住了。我现在用的是OS X 10.9(Mavericks)。总之,我已经自己下载并成功安装了这个包,但brew还是一直在要求这个依赖,并且安装失败。
从我的角度来看,我已经安装了这个依赖,所以brew应该让我继续进行。一个办法是“说服”brew我已经有这个依赖了。另一个办法是帮brew重新安装这个依赖,让它满意。我对make了解不多,但brew似乎在libtool: link: clang
这一部分出错了。如果我能把 -lpng15 改成 -lpng16,我觉得可能就能继续安装(但我也可能错了)。
尝试安装pygame(和sdl_ttf依赖):
brew install pygame
==> Installing dependencies for pygame: sdl_ttf, pixman, harfbuzz, homebr
==> Installing pygame dependency: sdl_ttf
==> Downloading http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.11.ta
Already downloaded: /Library/Caches/Homebrew/sdl_ttf-2.0.11.tar.gz
==> ./configure --prefix=/usr/local/Cellar/sdl_ttf/2.0.11 --disable-sdltest
==> make install
/bin/sh ./libtool --tag=CC --mode=link clang -g -O2 -I/usr/local/Cellar/freetype/2.5.2/include/freetype2 -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/usr/local/include/SDL -DHAVE_OPENGL -no-undefined -release 2.0 -version-info 10:1:10 -o libSDL_ttf.la -rpath /usr/local/Cellar/sdl_ttf/2.0.11/lib SDL_ttf.lo -L/usr/local/Cellar/freetype/2.5.2/lib -lfreetype -lz -lbz2 -lpng15 -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa
libtool: link: clang -dynamiclib -o .libs/libSDL_ttf-2.0.0.dylib .libs/SDL_ttf.o -L/usr/local/Cellar/freetype/2.5.2/lib -lfreetype -lz -lbz2 -lpng15 -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework -Wl,Cocoa -install_name /usr/local/Cellar/sdl_ttf/2.0.11/lib/libSDL_ttf-2.0.0.dylib -compatibility_version 11 -current_version 11.1 -Wl,-single_module
ld: library not found for -lpng15
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libSDL_ttf.la] Error 1
我记得lpng15这个问题,因为之前我也遇到过一个缺少的库,叫libpng15,而不是libpng16。我觉得我的直觉是对的——当我下载了SDL2_ttf-2.0.12的源代码并运行了./configure、make、make install时,它用了lpng16,而不是上面提到的lpng15:
SDL2_ttf-2.0.12的成功(非brew)make输出:
make
/bin/sh ./libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.0.12\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -I. -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -MT SDL_ttf.lo -MD -MP -MF .deps/SDL_ttf.Tpo -c -o SDL_ttf.lo SDL_ttf.c
libtool: compile: gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.0.12\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -I. -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -MT SDL_ttf.lo -MD -MP -MF .deps/SDL_ttf.Tpo -c SDL_ttf.c -fno-common -DPIC -o .libs/SDL_ttf.o
libtool: compile: gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.0.12\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -I. -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -MT SDL_ttf.lo -MD -MP -MF .deps/SDL_ttf.Tpo -c SDL_ttf.c -o SDL_ttf.o >/dev/null 2>&1
mv -f .deps/SDL_ttf.Tpo .deps/SDL_ttf.Plo
/bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -no-undefined -release 2.0 -version-info 10:2:10 -o libSDL2_ttf.la -rpath /usr/local/lib SDL_ttf.lo -L/opt/local/lib -lfreetype -lz -lbz2 -lpng16 -L/usr/local/lib -lSDL2
libtool: link: gcc -dynamiclib -o .libs/libSDL2_ttf-2.0.0.dylib .libs/SDL_ttf.o -L/opt/local/lib -lfreetype -lz -lbz2 -lpng16 -L/usr/local/lib -lSDL2 -install_name /usr/local/lib/libSDL2_ttf-2.0.0.dylib -compatibility_version 11 -current_version 11.2 -Wl,-single_module
libtool: link: dsymutil .libs/libSDL2_ttf-2.0.0.dylib || :
libtool: link: (cd ".libs" && rm -f "libSDL2_ttf.dylib" && ln -s "libSDL2_ttf-2.0.0.dylib" "libSDL2_ttf.dylib")
libtool: link: ar cru .libs/libSDL2_ttf.a SDL_ttf.o
libtool: link: ranlib .libs/libSDL2_ttf.a
libtool: link: ( cd ".libs" && rm -f "libSDL2_ttf.la" && ln -s "../libSDL2_ttf.la" "libSDL2_ttf.la" )
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.0.12\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -I. -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -MT showfont.o -MD -MP -MF .deps/showfont.Tpo -c -o showfont.o showfont.c
showfont.c:302:47: warning: format specifies type 'short' but the argument has
type 'int' [-Wformat]
TTF_FontHeight(font), text->h);
^~~~~~~
1 warning generated.
mv -f .deps/showfont.Tpo .deps/showfont.Po
/bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -o showfont showfont.o libSDL2_ttf.la -L/opt/local/lib -lfreetype -lz -lbz2 -lpng16 -L/usr/local/lib -lSDL2
libtool: link: gcc -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -o .libs/showfont showfont.o ./.libs/libSDL2_ttf.dylib -L/opt/local/lib -L/usr/local/lib -lfreetype -lz -lbz2 -lpng16 -lSDL2
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DPACKAGE=\"SDL2_ttf\" -DVERSION=\"2.0.12\" -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -I. -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -MT glfont.o -MD -MP -MF .deps/glfont.Tpo -c -o glfont.o glfont.c
glfont.c:386:47: warning: format specifies type 'short' but the argument has
type 'int' [-Wformat]
TTF_FontHeight(font), text->h);
^~~~~~~
1 warning generated.
mv -f .deps/glfont.Tpo .deps/glfont.Po
/bin/sh ./libtool --tag=CC --mode=link gcc -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -o glfont glfont.o libSDL2_ttf.la -Wl,-framework,OpenGL -L/opt/local/lib -lfreetype -lz -lbz2 -lpng16 -L/usr/local/lib -lSDL2
libtool: link: gcc -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -o .libs/glfont glfont.o -Wl,-framework -Wl,OpenGL ./.libs/libSDL2_ttf.dylib -L/opt/local/lib -L/usr/local/lib -lfreetype -lz -lbz2 -lpng16 -lSDL2
看看最后那部分——它用了lpng16,可能是基于运行的配置:
libtool: link: gcc -g -O2 -I/opt/local/include/freetype2 -I/usr/local/include/SDL2 -D_THREAD_SAFE -DHAVE_OPENGL -o .libs/glfont glfont.o -Wl,-framework -Wl,OpenGL ./.libs/libSDL2_ttf.dylib -L/opt/local/lib -L/usr/local/lib -lfreetype -lz -lbz2 -lpng16 -lSDL2
记得当brew运行这段代码时,它试图使用lpng15,但找不到:
ld: library not found for -lpng15
在这种情况下,安装过程继续顺利(但brew还是不知道,依然想要一开始提到的sdl_ttf
依赖):
make install输出:
make install
./install-sh -c -d '/usr/local/lib'
/bin/sh ./libtool --mode=install /usr/bin/install -c libSDL2_ttf.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libSDL2_ttf-2.0.0.dylib /usr/local/lib/libSDL2_ttf-2.0.0.dylib
libtool: install: (cd /usr/local/lib && { ln -s -f libSDL2_ttf-2.0.0.dylib libSDL2_ttf.dylib || { rm -f libSDL2_ttf.dylib && ln -s libSDL2_ttf-2.0.0.dylib libSDL2_ttf.dylib; }; })
libtool: install: /usr/bin/install -c .libs/libSDL2_ttf.lai /usr/local/lib/libSDL2_ttf.la
libtool: install: /usr/bin/install -c .libs/libSDL2_ttf.a /usr/local/lib/libSDL2_ttf.a
libtool: install: chmod 644 /usr/local/lib/libSDL2_ttf.a
libtool: install: ranlib /usr/local/lib/libSDL2_ttf.a
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
./install-sh -c -d '/usr/local/include/SDL2'
/usr/bin/install -c -m 644 SDL_ttf.h '/usr/local/include/SDL2'
./install-sh -c -d '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 SDL2_ttf.pc '/usr/local/lib/pkgconfig'
2 个回答
我觉得问题出在你升级了libpng,而你安装freetype的时候没有考虑到这一点,所以当你运行freetype-config --libs
时,它给出的结果不对。你可以试试运行brew update; brew upgrade; brew reinstall freetype
,这样应该能以正确的方式解决这个问题。
看起来 libpng15
可能被 libpng16
替代了。我建议你可以尝试创建一个链接,把 libpng16
指向 libpng15
(这样应该是向后兼容的)。
假设 libpng 在 /usr/local/lib
这个位置。
#create a link so any requests for lpng15 use lpng16 instead
sudo ln -s /usr/local/lib/lpng16.so /usr/local/lib/lpng15.so
确保你确认一下这个库在你电脑上的实际位置(我没有 OS X 的机器来测试)。
编辑 根据你在 /usr/local/lib
的输出,试试下面的命令 - 它会把任何缺失的 libpng15 文件链接到 libpng16。
sudo ln -s /usr/local/lib/libpng16.a /usr/local/lib/libpng15.a
sudo ln -s /usr/local/lib/libpng16.dylib /usr/local/lib/libpng15.dylib