编译错误ld:在MacOSX中找不到-lgcc_ext的库

时间:2014-06-27 18:57:29

标签: python macos matplotlib theano

  1. 我正在尝试复制pyLearn2文档中的教程示例。当我运行python make_dataset.py时,在示例中,我收到此错误:

    11:17 $ python make_dataset.py
    
    /Users/user/pylearn2/pylearn2/utils/image.py:16: UserWarning: Unable to import matplotlib. Some features unavailable. Original exception: dlopen(/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backends/_macosx.so, 2): Symbol not found: __cg_jpeg_resync_to_restart
    

    引用自:/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO

    预计于:/usr/local/lib/libjpeg.8.dylib

    我可以在命令行中导入matplotlib和python中的图像。有人可以帮我理解抱怨的内容以及如何解决错误吗?

  2. 另一个问题(可能与上述问题有关,也可能与之无关)是链接错误

    使用以下命令行进行编译时出现问题:

    g++ -dynamiclib -g -O3 -fno-math-errno -Wno-unused-label -Wno-unused-variable -Wno-write-strings -march=core-avx-i -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -maes -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=core-avx-i -D NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -m64 -fPIC -undefined dynamic_lookup -I/Library/Python/2.7/site-packages/numpy-1.9.0.dev_297f54b-py2.7-macosx-10.9-intel.egg/numpy/core/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -o /Users/user/.theano/compiledir_Darwin-13.2.0-x86_64-i386-64bit-i386-2.7.5-64/tmpBdy9w9/49d70155ef39a124cbfa83c600416644.so /Users/user/.theano/compiledir_Darwin-13.2.0-x86_64-i386-64bit-i386-2.7.5-64/tmpBdy9w9/mod.cpp -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib
    
    ld: library not found for -lgcc_ext.10.5
    
    collect2: error: ld returned 1 exit status
    
    Exception: ('The following error happened while compiling the node', InplaceDimShuffle{x,0}(mean), '\n', 'Compilation failed (return status=1): ld: library not found for -lgcc_ext.10.5. collect2: error: ld returned 1 exit status. ', '[InplaceDimShuffle{x,0}(mean)]')
    

    我在Mac OSX Mavericks上运行pyLearn2。我不确定如何修复错误:库似乎在我的系统中的几个地方:

    /usr/local/Cellar/gcc47/4.7.3/lib/gcc/x86_64-apple-darwin13.0.0/4.7.3/libgcc_ext.10.5.dylib
    /usr/local/Cellar/gfortran/4.8.2/gfortran/lib/libgcc_ext.10.5.dylib
    /usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.7.3/libgcc_ext.10.5.dylib
    

    我不确定要链接哪一个以及我应该如何链接。

    我已更改(添加)DYLD_LIBRARY_PATH的路径,这些路径无法解决问题。

    非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

看起来one possible solution是手动创建.dylib文件的链接:

  

sudo ln -sf   /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib   /opt/local/lib/libGL.dylib

     

sudo ln -sf   /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib   /opt/local/lib/libpng.dylib

     

sudo ln -sf   /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib   /opt/local/lib/libtiff.dylib

     

sudo ln -sf   /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib   /opt/local/lib/libjpeg.dylib

     

为什么这样做?因为无论出于何种原因,当Apple要求时   libJPEG.dyld,无论系统搜索到什么   /opt/local/lib/libjpeg.dyld因为搜索不区分大小写。   对于Unix操作系统。去搞清楚。上面的行将强制任何   程序寻找libjpeg.dyld重定向到Apple的   libJPEG.dyld。

另一位用户建议setting DYLD_FALLBACK_LIBRARY_PATH

  

您也可以使用DYLD_FALLBACK_LIBRARY_PATH。我不得不用它来   避免Apple的libJPEG妨碍那些期望的应用程序   libjpeg端口。有关详细信息,请参阅dlopen()的手册页。