2012-10-29 6 views
4

opencv 및 pygame을 사용하여 앱을 제작하려고합니다. 이 두 libs는 macports와 함께 설치되었습니다. 나는 또한 py2app를 macports python에 설치했다. 내가opencv/macports 앱에서 py2app 오류가 발생했습니다. headerpad_max_install_names 플래그로 opencv를 컴파일하는 방법은 무엇입니까?

from setuptools import setup 

setup(
    app = [ 
     '/full/path/to/my_script.py', 
    ], 
    options={ 
     "py2app":{ 
      'argv_emulation': True, 
     } 
    }, 
    setup_requires=['py2app'] 
) 

불행하게도 간단한 py2app 스크립트를 실행하고, py2app 다음과 같은 오류와 함께 실패합니다

는이 앱 번들을 만드는 것이 가능하다 "ValueError를 새로운 마하 - O 헤더 재배치 너무 크다" opencv 및 macports와 함께? 당신의 도움이

업데이트에 대한

감사 :

Shared libraries on OSX contain an absolute path to their location, and likewise all used libraries are also mentioned using an absolute path. Py2app uses macholib to rewrite those mentions to relative paths starting with '@executable_path'. For libraries that are located in /opt/local the new path requires more space than the old one, hence the error message. One way to ensure that there is enough space is the linker flag "headerpad_max_install_names". I don't know how to tell darwinports to add this flag when building opencv.

도 내가 pyInstaller 중에와 유사한 문제를했습니다 있습니다 : 여기

는 py2app의 developper입니다 처했을 ronaldoussoren의 답변입니다.

변경하지 않고 opencv Portfile을 수정하려고했습니다. 이 링커 플래그를 추가 할 위치를 알지 못합니다.

어떻게 고칠 수 있습니까?

업데이트 : 여기


업데이트

# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 
# $Id: Portfile 99165 2012-10-28 22:56:03Z [email protected] $ 

PortSystem      1.0 
PortGroup      cmake 1.0 

name       opencv 
version       2.4.2 
revision      2 
categories      graphics science 
license       BSD 
platforms      darwin 
maintainers      nomaintainer 

description      Intel(R) Open Source Computer Vision Library 

long_description    opencv is a library that is mainly aimed at real time \ 
           computer vision. Some example areas would be \ 
           Human-Computer Interaction (HCI), Object Identification, \ 
           Segmentation and Recognition, Face Recognition, Gesture \ 
           Recognition, Motion Tracking, Ego Motion, Motion \ 
           Understanding, Structure From Motion (SFM), and Mobile \ 
           Robotics. 

homepage      http://opencv.willowgarage.com/wiki/ 
master_sites     sourceforge:project/opencvlibrary/opencv-unix/${version} 
use_bzip2      yes 
distname      OpenCV-${version} 

checksums      rmd160 496964503629b0ff4432fbdd276837ab3f134411 \ 
           sha256 690023811e03e21df996291392fcf78e43e42ef557b9307503c74c74b4272c28 

depends_build-append   port:pkgconfig 

depends_lib-append    port:zlib \ 
           path:lib/libavcodec.dylib:ffmpeg \ 
           port:libpng \ 
           port:tiff \ 
           port:jasper \ 
           port:jpeg \ 
           port:bzip2 \ 
           port:openexr \ 
           port:ilmbase \ 
           port:eigen3 

patchfiles      patch-fix_dirname_case.diff \ 
           patch-install_name.diff 

configure.args-append   -DBUILD_NEW_PYTHON_SUPPORT=OFF \ 
           -DBUILD_EXAMPLES=ON \ 
           -DINSTALL_C_EXAMPLES=ON \ 
           -DBZIP2_LIBRARIES=${prefix}/lib/libbz2.dylib \ 
           -DZLIB_LIBRARY=${prefix}/lib/libz.dylib \ 
           -DWITH_OPENEXR=ON \ 
           -DWITH_1394=OFF \ 
           -DWITH_EIGEN=ON \ 
           -DEIGEN_INCLUDE_PATH=${prefix}/include/eigen3 \ 
           -DBUILD_JASPER=OFF \ 
           -DBUILD_JPEG=OFF \ 
           -DBUILD_PNG=OFF \ 
           -DBUILD_TIFF=OFF \ 
           -DBUILD_ZLIB=OFF 
configure.ldflags-append  "-Wl,-headerpad_max_install_names" 

# gcc-4.0 exits with a bus error 
if {${configure.compiler} == "gcc-4.0"} { 
    configure.compiler gcc-4.2 
    if {![file executable ${configure.cc}]} { 
     depends_build-append port:apple-gcc42 
     depends_skip_archcheck-append apple-gcc42 
     configure.compiler apple-gcc-4.2 
    } 
} 

platform darwin { 
    if {${os.major} <= 9} { 
     # Video Decode Acceleration Framework is not available 
     patchfiles-append  patch-highgui_CMakeLists.txt.diff 
    } 
} 

post-destroot { 
    xinstall -d ${destroot}${prefix}/lib/cmake 
    move ${destroot}${prefix}/share/OpenCV/OpenCVConfig-version.cmake \ 
     ${destroot}${prefix}/share/OpenCV/OpenCVConfig.cmake \ 
     ${destroot}${prefix}/lib/cmake/ 
} 

variant dc1394 description {Use libdc1394 for FireWire camera. Breaks compatibility with Apple iSight FireWire camera.} { 
    depends_lib-append   port:libdc1394 
    configure.args-delete  -DWITH_1394=OFF 
    configure.args-append  -DWITH_1394=ON \ 
           -DHAVE_1394=ON 
} 

variant qt4 description {Use qt4 backend for graphical interface.} { 
    PortGroup     qt4 1.0 
    configure.args-append  -DWITH_QT=ON 
} 

variant python26 conflicts python27 description {Add Python 2.6 bindings} { 
    depends_lib-append   port:python26 \ 
           port:py26-numpy 
    configure.args-delete  -DBUILD_NEW_PYTHON_SUPPORT=OFF 
    configure.args-append  -DINSTALL_PYTHON_EXAMPLES=ON \ 
           -DBUILD_NEW_PYTHON_SUPPORT=ON \ 
           -DPYTHON_EXECUTABLE=${prefix}/bin/python2.6 \ 
           -DPYTHON_LIBRARY=${prefix}/lib/libpython2.6.dylib \ 
           -DPYTHON_INCLUDE_DIR=${frameworks_dir}/Python.framework/Versions/2.6/Headers \ 
           -DPYTHON_PACKAGES_PATH=${frameworks_dir}/Python.framework/Versions/2.6/lib/python2.6/site-packages 
} 

variant python27 conflicts python26 description {Add Python 2.7 bindings} { 
    depends_lib-append   port:python27 \ 
           port:py27-numpy 
    configure.args-delete  -DBUILD_NEW_PYTHON_SUPPORT=OFF 
    configure.args-append  -DINSTALL_PYTHON_EXAMPLES=ON \ 
           -DBUILD_NEW_PYTHON_SUPPORT=ON \ 
           -DPYTHON_EXECUTABLE=${prefix}/bin/python2.7 \ 
           -DPYTHON_LIBRARY=${prefix}/lib/libpython2.7.dylib \ 
           -DPYTHON_INCLUDE_DIR=${frameworks_dir}/Python.framework/Versions/2.7/Headers \ 
           -DPYTHON_PACKAGES_PATH=${frameworks_dir}/Python.framework/Versions/2.7/lib/python2.7/site-packages 
    configure.ldflags-append "-Wl,-headerpad_max_install_names" 
} 

variant tbb description {Use Intel TBB} { 
    depends_lib-append   port:tbb 
    configure.args-append  -DWITH_TBB=ON \ 
           -DHAVE_TBB=ON \ 
           -DTBB_INCLUDE_DIRS=${prefix}/include \ 
           -DOPENCV_LINKER_LIBS="-ltbb -ltbbmalloc" 
} 

livecheck.type     sourceforge 
livecheck.name     opencvlibrary 
livecheck.regex     /OpenCV-(\[0-9a-z.\]+)${extract.suffix} 
내 Portfile

경우 : macport 팀은이 문제에 근무하지만 불행히도 자신의 수정은 내 문제가 해결되지 않습니다. 당신은 configure.args-append 라인 근처 어딘가에 OpenCV의 Portfile에

configure.ldflags-append "-Wl,-headerpad_max_install_names"

를 추가 할 필요가 http://trac.macports.org/ticket/36841

+0

가 제공 대답에 대한 몇 가지 피드백을 제공하시기 바랍니다. – Vortexfive

+0

죄송합니다. 아직 테스트 할 시간이 없었습니다. 다른 사람들은 뜨거운 감자. :) 나는 가능한 한 피드백을 줄 것이다. – luc

+0

시스템에 재배포 가능 번들 또는 시작 프로그램 만 만들려고합니까? 후자의 경우, 별칭 라이브러리에 _-A_ py2app 옵션을 사용할 수 있습니다. 'python setup.py py2app -A' – anddam

답변

4

참조하십시오. (Documentation)

이 문제가 해결되기를 바랍니다. 그렇지 않으면 OpenCV의 모든 종속성을 해당 플래그로 컴파일해야 할 수도 있습니다. 이는 많은 작업 일 수 있습니다. 이 경우에 https://trac.macports.org/ticket/29838을보고 싶은 경우 headerpad_max_install_names 플래그를 기본적으로 사용 가능하게 설정하십시오.

OpenCV의 다음 업데이트에서 포트 파일의 변경 사항을 보존하고 실행 취소하지 않으려면 Sneaky patching source with Macports의 지침을 따르십시오. 그러나 이렇게하면 OpenCV의 업데이트가 자동으로 설치되지 않습니다!

+0

불행히도, configure.ldflags-append "-Wl, -headerpad_max_install_names"는 문제를 해결하지 못합니다. 어쨌든, +1 그리고이 답변에 대한 많은 감사 – luc

+0

@luc : 알겠습니다. 죄송합니다. tbb 변종을 사용하지 않으면'configure.ldflags-append "-Wl, -headerpad_max_install_names"가'variant tbb description {Use Intel TBB} {...}'블록 외부에 있어야한다는 점에주의하고 싶습니다 (질문에서 Portfile 참조). – Vortexfive

+0

Portfile을 다시 수정했고 (질문에서 업데이트했습니다) 여전히 같은 오류가 있습니다. 당신의 도움에 감사드립니다. (현상금 상환에 합당합니다.) – luc

1

어제 py2app 개발자의 안내에 따라 해결책을 찾았습니다.

먼저 -Xlinker, -Wl 및. -headpad ... 플래그는 여전히 macports.conf에 계속 있지만, 나를 위해 문제를 해결하지 못했습니다. 나를위한 열쇠는 macports 파일 깊이를 늘리고 빌드 디렉토리 파일 깊이를 줄이는 것이 었습니다. 특히, --prefix =/opt/localdepth/localdepth/localdepth/localdepth/local을 사용하여 macports를 설치하고/opt/build에서 빌드합니다. 이제 py2app가 성공적으로 실행됩니다.

은 참조 : 당신을 위해 작동하지 않는 경우 https://bitbucket.org/ronaldoussoren/py2app/issue/93/mach-o-header-may-be-too-large-to-relocate https://trac.macports.org/ticket/38163