cmake,gcc,cuda和-m32 [英] cmake, gcc, cuda and -m32
问题描述
我想出CUDA不工作在64位模式在我的mac(或者不能得到它运行到目前为止)。因此,我决定编译32位的所有内容。
I figured out that CUDA does not work in 64bit mode on my mac (or couldn't get it running so far). Therefore I decided to compile everything for 32bit.
我使用cmake 2.8并添加了以下选项
I use cmake 2.8 and added the following options
add_definitions(-Wall -m32)
set(CUDA_64_BIT_DEVICE_CODE OFF)
set(CMAKE_MODULE_LINKER_FLAGS -m32)
但是当它尝试链接它时,它会做这样的:
However when it tries to link it it does something like this:
/usr/bin/c++ -mmacosx-version-min=10.6 -Wl,-search_paths_first -headerpad_max_install_names CMakeFiles/SimpleTestsCUDA.dir/BlockMatrix.cpp.o CMakeFiles/SimpleTestsCUDA.dir/Matrix.cpp.o ./SimpleTestsCUDA_generated_SimpleTests.cu.o ./SimpleTestsCUDA_generated_BlockMatrix.cu.o -o SimpleTestsCUDA /usr/local/cuda/lib/libcudart.dylib /usr/local/cuda/lib/libcuda.dylib
其中失败了很多文件不是必需的架构警告从ld。现在,如果我手动添加-m32到上面的命令它工作。但是我不知道如何教授cmake添加-m32到每个gcc(或ld)调用。到目前为止它为nvcc和gcc,但不是链接..
Which fails with a lot of "file is not of required architecture" warnings from ld. Now if I add manually -m32 to the command above it works. However I have no idea how to teach cmake to add -m32 to every gcc (or ld) invocation. So far it does it for nvcc and gcc, but not for linking..
推荐答案
如果设置env var LDFLAGS
在运行cmake之前,它将工作:
If you set the env var LDFLAGS
before you run cmake on the project it will work as well:
export LDFLAGS=-m32
cmake ../source
这篇关于cmake,gcc,cuda和-m32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!