저는 cuda 프로그래밍을 처음 접했고, 프로그램을 작성하려고하며 cuda를 사용하는 .cu 기능이 있습니다. 나는이 프로젝트에 호응하며이 프로젝트는 거대합니다. 프로젝트의 *의 .cpp 파일은cuda_add_executable 명령을 사용하여 Cmake 오류가 발생했습니다.
SUBDIRS(
src/ThirdParty/Matrice
)
set(SRC_CPP_FILES
Operation.cpp
Operator.cpp
ThirdParty/mt97.cpp
Mesh.cpp
...
)
...
files.cmake 스크립트를 사용하여 프로젝트에 추가하고이 프로젝트의 CmakeList.txt가 기록됩니다
project(PILOT_plugin)
#set(CMAKE_MODULE_PATH
# ${${MY_PROJECT_NAME}_SOURCE_DIR}/CMake
# ${CMAKE_MODULE_PATH}
# )
MACRO_CREATE_MITK_CTK_PLUGIN(
EXPORT_DIRECTIVE PLANNING_EXPORTS
EXPORTED_INCLUDE_SUFFIXES src
#MODULE_DEPENDS QmitkExt Qmitk
MODULE_DEPENDS MitkQtWidgetsExt MitkQtWidgets MitkMapperExt MitkSceneSerialization
)
# Check the architecture and set CMAKE_LIBRARY_ARCHITECTURE accordingly
#if(UNIX)
# if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# set(CMAKE_LIBRARY_ARCHITECTURE "x86_64-linux-gnu")
# endif()
#endif()
function(echo_all_cmake_variable_values)
message(STATUS "")
get_cmake_property(vs VARIABLES)
foreach(v ${vs})
message(STATUS "${v}='${${v}}'")
endforeach(v)
message(STATUS "")
endfunction()
#echo_all_cmake_variable_values()
SET(QT_USE_QTSQL TRUE)
find_package(Boost COMPONENTS serialization filesystem system REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
set(VTK_CMAKE_DIR ${PILOT_SUPERBUILD_BINARY_DIR}/MITK-superbuild/VTK-src/CMake)
add_subdirectory(${PILOT_plugin_SOURCE_DIR}/src/ThirdParty/vtkbioeng ${PILOT_plugin_SOURCE_DIR}/src/ThirdParty/vtkbioeng/Build)
add_subdirectory(${PILOT_plugin_SOURCE_DIR}/src/ThirdParty/ompl)
include_directories(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIR} ${PILOT_plugin_SOURCE_DIR}/src/CGoGN/include /usr/include/libxml2 ${PILOT_plugin_SOURCE_DIR}/src/ThirdParty/vtkbioeng ${PILOT_plugin_SOURCE_DIR}/src/ThirdParty/ompl/src)
add_dependencies(${PROJECT_NAME} ompl vtkBioeng)
#find_path(CGOGN_LIB_DIR cgogn ${PILOT_plugin_SOURCE_DIR}/src/CGoGN/lib/Release)
#message(STATUS ${CGOGN_LIB_DIR})
#link_directories(${PILOT_plugin_SOURCE_DIR}/src/CGoGN/lib/Release)
#set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${PILOT_plugin_SOURCE_DIR}/src/CGoGN/lib/Release)
#set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${CGOGN_LIB_DIR})
#list(APPEND ALL_LIBRARY_DIRS ${PILOT_plugin_SOURCE_DIR}/src/CGoGN/lib/Release)
if(EXISTS ${PILOT_plugin_SOURCE_DIR}/src/CGoGN/lib/Release/libcgogn.a)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} gsl mat ${Boost_LIBRARIES} PythonQt ${PYTHON_LIBRARIES} ompl vtkBioeng ${PILOT_plugin_SOURCE_DIR}/src/CGoGN/lib/Release/libcgogn.a z)
else()
TARGET_LINK_LIBRARIES(${PROJECT_NAME} gsl mat ${Boost_LIBRARIES} PythonQt ${PYTHON_LIBRARIES} ompl vtkBioeng)
endif()
#TARGET_LINK_LIBRARIES(${PROJECT_NAME} mat ${Boost_LIBRARIES} PythonQt ${PYTHON_LIBRARIES} cgogn z)
#echo_all_cmake_variable_values()
add_definitions(-DBOOST_NO_CXX11_RVALUE_REFERENCES)
내 지식에 따르면 내가 명령 아래에 추가해야합니다 .cmake 파일 또는 cmakeLists.txt!
find_package(CUDA REQUIRED)
add_definitions(-D_FORCE_INLINES)
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --gpu-architecture sm_21 -std=c++11)
cuda_add_executable(PILOT_plugin
testcuda.cu)
'PILOT_plugin'
는 프로젝트의 이름이고 .CU 파일 내 CUDA 파일입니다. 하지만 '[cmake_check_build_system] 오류 1'이납니다. CmakeError.log 파일에서 아무것도 이해하지 못합니다.이는 cmakeError.log
Determining if the Q_WS_WIN exist failed with the following output:
Change Dir: /home/.../CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec2072448143/fast"
make[3]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTryCompileExec2072448143.dir/build.make CMakeFiles/cmTryCompileExec2072448143.dir/build
make[4]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/.../CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec2072448143.dir/CheckSymbolExists.cxx.o
/usr/bin/c++ -I/usr/include/qt4 -o CMakeFiles/cmTryCompileExec2072448143.dir/CheckSymbolExists.cxx.o -c /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx
/home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx: In function ‘int main(int, char**)’:
/home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:8:19: error: ‘Q_WS_WIN’ was not declared in this scope
return ((int*)(&Q_WS_WIN))[argc];
^
CMakeFiles/cmTryCompileExec2072448143.dir/build.make:57: recipe for target 'CMakeFiles/cmTryCompileExec2072448143.dir/CheckSymbolExists.cxx.o' failed
make[4]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[4]: *** [CMakeFiles/cmTryCompileExec2072448143.dir/CheckSymbolExists.cxx.o] Error 1
Makefile:118: recipe for target 'cmTryCompileExec2072448143/fast' failed
make[3]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[3]: *** [cmTryCompileExec2072448143/fast] Error 2
File /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:
/* */
#include <QtCore/qglobal.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef Q_WS_WIN
return ((int*)(&Q_WS_WIN))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the Q_WS_QWS exist failed with the following output:
Change Dir: /home/.../CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec3895328539/fast"
make[3]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTryCompileExec3895328539.dir/build.make CMakeFiles/cmTryCompileExec3895328539.dir/build
make[4]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/.../CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec3895328539.dir/CheckSymbolExists.cxx.o
/usr/bin/c++ -I/usr/include/qt4 -o CMakeFiles/cmTryCompileExec3895328539.dir/CheckSymbolExists.cxx.o -c /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx
/home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx: In function ‘int main(int, char**)’:
/home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:8:19: error: ‘Q_WS_QWS’ was not declared in this scope
return ((int*)(&Q_WS_QWS))[argc];
^
CMakeFiles/cmTryCompileExec3895328539.dir/build.make:57: recipe for target 'CMakeFiles/cmTryCompileExec3895328539.dir/CheckSymbolExists.cxx.o' failed
make[4]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[4]: *** [CMakeFiles/cmTryCompileExec3895328539.dir/CheckSymbolExists.cxx.o] Error 1
Makefile:118: recipe for target 'cmTryCompileExec3895328539/fast' failed
make[3]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[3]: *** [cmTryCompileExec3895328539/fast] Error 2
File /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:
/* */
#include <QtCore/qglobal.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef Q_WS_QWS
return ((int*)(&Q_WS_QWS))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the Q_WS_MAC exist failed with the following output:
Change Dir: /home/.../CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec816771383/fast"
make[3]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTryCompileExec816771383.dir/build.make CMakeFiles/cmTryCompileExec816771383.dir/build
make[4]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/.../CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec816771383.dir/CheckSymbolExists.cxx.o
/usr/bin/c++ -I/usr/include/qt4 -o CMakeFiles/cmTryCompileExec816771383.dir/CheckSymbolExists.cxx.o -c /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx
/home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx: In function ‘int main(int, char**)’:
/home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:8:19: error: ‘Q_WS_MAC’ was not declared in this scope
return ((int*)(&Q_WS_MAC))[argc];
^
CMakeFiles/cmTryCompileExec816771383.dir/build.make:57: recipe for target 'CMakeFiles/cmTryCompileExec816771383.dir/CheckSymbolExists.cxx.o' failed
make[4]: *** [CMakeFiles/cmTryCompileExec816771383.dir/CheckSymbolExists.cxx.o] Error 1
make[4]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
Makefile:118: recipe for target 'cmTryCompileExec816771383/fast' failed
make[3]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[3]: *** [cmTryCompileExec816771383/fast] Error 2
File /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.cxx:
/* */
#include <QtCore/qglobal.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef Q_WS_MAC
return ((int*)(&Q_WS_MAC))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/.../CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec3000733177/fast"
make[3]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTryCompileExec3000733177.dir/build.make CMakeFiles/cmTryCompileExec3000733177.dir/build
make[4]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/.../CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3000733177.dir/CheckSymbolExists.c.o
/usr/bin/cc -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=unknown-pragmas -Wno-error=strict-overflow -Wno-unused-local-typedefs -Wno-array-bounds -fdiagnostics-show-option -fstack-protector-all -o CMakeFiles/cmTryCompileExec3000733177.dir/CheckSymbolExists.c.o -c /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec3000733177
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3000733177.dir/link.txt --verbose=1
/usr/bin/cc -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=unknown-pragmas -Wno-error=strict-overflow -Wno-unused-local-typedefs -Wno-array-bounds -fdiagnostics-show-option -fstack-protector-all CMakeFiles/cmTryCompileExec3000733177.dir/CheckSymbolExists.c.o -o cmTryCompileExec3000733177 -rdynamic
CMakeFiles/cmTryCompileExec3000733177.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x29): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec3000733177.dir/build.make:88: recipe for target 'cmTryCompileExec3000733177' failed
make[4]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[4]: *** [cmTryCompileExec3000733177] Error 1
Makefile:118: recipe for target 'cmTryCompileExec3000733177/fast' failed
make[3]: *** [cmTryCompileExec3000733177/fast] Error 2
make[3]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
File /home/.../CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef pthread_create
return ((int*)(&pthread_create))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/.../CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTryCompileExec2524936657/fast"
make[3]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/make -f CMakeFiles/cmTryCompileExec2524936657.dir/build.make CMakeFiles/cmTryCompileExec2524936657.dir/build
make[4]: Entering directory '/home/.../CMakeFiles/CMakeTmp'
/usr/bin/cmake -E cmake_progress_report /home/.../CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec2524936657.dir/CheckFunctionExists.c.o
/usr/bin/cc -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=unknown-pragmas -Wno-error=strict-overflow -Wno-unused-local-typedefs -Wno-array-bounds -fdiagnostics-show-option -fstack-protector-all -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec2524936657.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.0/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec2524936657
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec2524936657.dir/link.txt --verbose=1
/usr/bin/cc -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=unknown-pragmas -Wno-error=strict-overflow -Wno-unused-local-typedefs -Wno-array-bounds -fdiagnostics-show-option -fstack-protector-all -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec2524936657.dir/CheckFunctionExists.c.o -o cmTryCompileExec2524936657 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTryCompileExec2524936657.dir/build.make:88: recipe for target 'cmTryCompileExec2524936657' failed
make[4]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[4]: *** [cmTryCompileExec2524936657] Error 1
Makefile:118: recipe for target 'cmTryCompileExec2524936657/fast' failed
make[3]: Leaving directory '/home/.../CMakeFiles/CMakeTmp'
make[3]: *** [cmTryCompileExec2524936657/fast] Error 2
이유는 .CU 프로젝트에 파일을 추가 할 수 있습니까? 주요 프로젝트는 gcc를 사용하여 컴파일합니다. .cu 파일을 기본 프로젝트에 추가하고 nvcc를 사용하여 컴파일 할 수있는 다른 방법이 있습니까?
PS : 나는 간단한 프로젝트를 만들고 위와 CmakeLists.txt가 잘 작동에 같은 일을하지만, 내가 어떤 도움이 많이 감사합니다이 거대한 프로젝트 에 .CU를 추가 할 수없는 이유를 이해 해달라고하면
당신이 맞습니다, 나는 최신 버전의 Cmake를 사용하고 있으며 위의 새로운 기능도 멋지게 보입니다. 그러나 그것을 새로운 명령으로 바꾸는 것은 작동하지 않습니다!. 이 프로그램은 .cu 파일없이 잘 실행됩니다. 그러므로, 나는 그 문제가 Qt4에서 온 것이라고 생각하지 않는다. 전에 말했듯이 Cmake의 동일한 버전으로 간단한 프로그램이 잘 작동합니다. thanks – Ehsan
게시 된 CMake 로그 파일의 오류 중 cuda와 관련된 오류가 없습니다. 위에서 설명한 스타일로 CUDA_NVCC_FLAGS 대신 CMAKE_CUDA_FLAGS를 사용하여 CUDA 플래그를 전달해야합니다. 콘솔의 실제 오류 메시지가 없으면 이보다 더 큰 도움이되지 않습니다. –