Since a few weeks back I keep getting "malformed object" errors when building OpenCV or Pcl on OSX with CUDA libraries on (For some reason this doesn't happen when CUDA is disabled). During install phase the following error message is displayed (for different command #s):
从几周前开始,我在OSX上构建OpenCV或Pcl时,总是会出现“错误的对象”错误(因为某些原因,当CUDA被禁用时,这不会发生)。在安装阶段,将显示以下错误消息(对于不同的命令#s):
install_name_tool: object: libopencv_cudev.3.0.0.dylib malformed object (load command 19 cmdsize is zero)
install_name_tool:对象:libopencv_cudev.3.0.0。dylib malform对象(load命令19 cmdsize为0)
Although the build and install process finishes, the resulting libraries are malformed and can be linked but not loaded by other projects.
尽管构建和安装过程完成了,但是生成的库是畸形的,可以链接,但不能被其他项目加载。
Additional info: My system is OSX Maverick 10.9.2, I use system libraries and tools as much as possible (clang, libjpeg etc.) and Macports for most other libraries that OpenCV etc. depend on (cmake etc.). Although the error seems to be linked to CUDA-related builds it probably isn't since manual compilation of small CUDA-projects works fine.
附加信息:我的系统是OSX Maverick 10.9.2,我尽可能多地使用系统库和工具(clang, libjpeg等),以及其他OpenCV所依赖的其他库的Macports (cmake等等)。尽管这个错误似乎与cuda相关的构建联系在一起,但它可能并不是因为手工编译小型cuda项目的工作很好。
2 个解决方案
#1
2
I actually solved this problem but thought it might be nice to share and to document the solution:
我实际上已经解决了这个问题,但我认为分享和记录解决方案可能很好:
Problem:
问题:
Bug in cmake 2.8.12+ - http://public.kitware.com/Bug/view.php?id=14707
cmake 2.8.12+ - http://public.kitware.com/Bug/view.php?id=14707。
Explanation as far as I got it:
我得到的解释是:
This problem is not at all related to CUDA or mixed toolchains as I first thought. The reason for why this problem appears in the CUDA-builds is because in those specific builds install_name_tool is run to change the RPATH of CUDA libraries. The error is due to cmake corrupting the binaries and libs by adding two identical LC_RPATHs
- it seems to come from when two link_directories()
are resolved to the same final path (different macro resolutions). When install_name_tool is run on libs that have two identical LC_RPATHs
, it then seems to corrupt them.
这个问题与我第一次想到的CUDA或混合工具链无关。为什么这个问题出现在CUDA-build中是因为在那些特定的build install_name_tool中,会运行来更改CUDA库的RPATH。错误是由于cmake通过添加两个相同的lc_rpath来损坏二进制文件和libs——它似乎来自于两个link_directory()被解析为相同的最终路径(不同的宏分辨率)。当install_name_tool在有两个相同的lc_rpath的libs上运行时,它似乎会损坏它们。
Solutions:
解决方案:
- Guaranteed to work (tested): downgrade to cmake 2.8.11
- 保证工作(测试):降级为cmake 2.8.11。
- Likely to work: Upgrade to cmake post this commit: http://cmake.org/gitweb?p=cmake.git;a=commit;h=08141a5
- 可能要工作:升级到cmake post这个提交:http://cmake.org/gitweb?p=cmake.git;a=commit;h=08141a5。
Step-by-step, solution 1 for Macports users:
Macports用户的解决方案1:
cd some_folder_that_you_keep_source_folders_in
sudo port uninstall cmake
svn co -r 110530 http://svn.macports.org/repository/macports/trunk/dports/devel/cmake
cd cmake
sudo port install
#2
0
I had similar problem in a different project and managed to mitigate it by adding the following like to the CMakeLists.txt file:
我在一个不同的项目中遇到了类似的问题,并通过向CMakeLists添加如下内容来减轻它。txt文件:
SET(CMAKE_SKIP_RPATH TRUE)
集(CMAKE_SKIP_RPATH真实)
Does it work for your case?
这对你的案子有用吗?
#1
2
I actually solved this problem but thought it might be nice to share and to document the solution:
我实际上已经解决了这个问题,但我认为分享和记录解决方案可能很好:
Problem:
问题:
Bug in cmake 2.8.12+ - http://public.kitware.com/Bug/view.php?id=14707
cmake 2.8.12+ - http://public.kitware.com/Bug/view.php?id=14707。
Explanation as far as I got it:
我得到的解释是:
This problem is not at all related to CUDA or mixed toolchains as I first thought. The reason for why this problem appears in the CUDA-builds is because in those specific builds install_name_tool is run to change the RPATH of CUDA libraries. The error is due to cmake corrupting the binaries and libs by adding two identical LC_RPATHs
- it seems to come from when two link_directories()
are resolved to the same final path (different macro resolutions). When install_name_tool is run on libs that have two identical LC_RPATHs
, it then seems to corrupt them.
这个问题与我第一次想到的CUDA或混合工具链无关。为什么这个问题出现在CUDA-build中是因为在那些特定的build install_name_tool中,会运行来更改CUDA库的RPATH。错误是由于cmake通过添加两个相同的lc_rpath来损坏二进制文件和libs——它似乎来自于两个link_directory()被解析为相同的最终路径(不同的宏分辨率)。当install_name_tool在有两个相同的lc_rpath的libs上运行时,它似乎会损坏它们。
Solutions:
解决方案:
- Guaranteed to work (tested): downgrade to cmake 2.8.11
- 保证工作(测试):降级为cmake 2.8.11。
- Likely to work: Upgrade to cmake post this commit: http://cmake.org/gitweb?p=cmake.git;a=commit;h=08141a5
- 可能要工作:升级到cmake post这个提交:http://cmake.org/gitweb?p=cmake.git;a=commit;h=08141a5。
Step-by-step, solution 1 for Macports users:
Macports用户的解决方案1:
cd some_folder_that_you_keep_source_folders_in
sudo port uninstall cmake
svn co -r 110530 http://svn.macports.org/repository/macports/trunk/dports/devel/cmake
cd cmake
sudo port install
#2
0
I had similar problem in a different project and managed to mitigate it by adding the following like to the CMakeLists.txt file:
我在一个不同的项目中遇到了类似的问题,并通过向CMakeLists添加如下内容来减轻它。txt文件:
SET(CMAKE_SKIP_RPATH TRUE)
集(CMAKE_SKIP_RPATH真实)
Does it work for your case?
这对你的案子有用吗?