在Mac OS X(64位)上构建具有Java支持的OpenCV [英] Building OpenCV with Java Support on Mac OS X (64-bit)
问题描述
以下 http://docs上的指示.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html ,我遇到了这个问题:
make -j8
...
...
链接CXX共享库../../lib/libopencv_java244.dylib
ld:未知选项:-whole-archive
clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)
make [2]: * [lib/libopencv_java244.dylib]错误1
make [1]:* [modules/java/CMakeFiles/opencv_java.dir/all]错误2
make:*** [all]错误2
有什么建议吗?
我确实遇到了完全相同的问题!经过一番挖掘,我发现链接器ld在Unix和OS X中具有不同的标志.因此,错误:
ld: unknown option: -whole-archive
要修复,可以编辑文件modules/java/CMakeLists.txt
以使用OS X标志. (搜索-whole-archive
)
原文:
target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive ${__extradeps} ${OPENCV_LINKER_LIBS})
新功能:
foreach(_dep ${__deps})
target_link_libraries(${the_module} -Wl,-force_load "${_dep}")
endforeach()
我将查看是否可以将这些更改放入存储库中. :)
-编辑-
我最初的回答有点错误(但部分正确!);我已经更改了上面的答案. -force_load仅适用于一个存档,因此适用于foreach.同样,它也应转到链接器,即-Wl.有关详细信息,请参见拉动请求,有关最新代码的git pull.>
Following directions from http://docs.opencv.org/2.4.4-beta/doc/tutorials/introduction/desktop_java/java_dev_intro.html, I am running into the this:
make -j8
...
...
Linking CXX shared library ../../lib/libopencv_java244.dylib
ld: unknown option: -whole-archive
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: * [lib/libopencv_java244.dylib] Error 1
make[1]: * [modules/java/CMakeFiles/opencv_java.dir/all] Error 2
make: *** [all] Error 2
Any suggestions?
I had literally the exact same problem! With some digging, I found that the linker ld has different flags in Unix and OS X. Thus the error:
ld: unknown option: -whole-archive
To fix, you can edit the file modules/java/CMakeLists.txt
to use the OS X flags. (search for -whole-archive
)
Original:
target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive ${__extradeps} ${OPENCV_LINKER_LIBS})
New:
foreach(_dep ${__deps})
target_link_libraries(${the_module} -Wl,-force_load "${_dep}")
endforeach()
I'm going to see if I can get these changes into the repo. :)
--Edit--
My original answer was slightly wrong (but partly right!); I've changed the answer above. -force_load only works for one archive, thus the foreach. As well, it should go to the linker, thus the -Wl. See pull request 741 for details and git pull for up-to-date code.
这篇关于在Mac OS X(64位)上构建具有Java支持的OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!