Hi, I am a new-guy in CUDA and I have a problem when I tried to build a CUDA-SDK sample for myself.
The information of the software and hardware I used is listed as follows:
CUDA-toolkit version 4.0.17
CUDA-SDK version 4.0.17
Cmake version 2.8.5
Visual Studio 2008 with SP1
Windows 7 64-bit
GeForce GTS 250
The sample code I tried to build is "bandwidthTest".
I wrote the CMakeLists by using the module FindCUDA.cmake.
Actually the compiling was OK,
but several LINK ERROR existed.
I also found I could not find CUDA Runtime API when I checked the project property.
When I added the compiling rules, CUDA Runtime API could be seen.
But the link error still existed.
I listed the building output of VS2008 as follows.
I also uploaded the source codes.
Could anyone give me some hints to fix this problem?
Thanks very much.
The following is the building output of VS2008:
(Because I am using a Japanese OS, Japanese characters exist in the output.
It may be a little difficult for the understanding. Sorry! )
1>------ ビルド開始: プãƒã‚¸ã‚§ã‚¯ãƒˆ: ZERO_CHECK, 構æˆ: Release x64 ------
1>Checking Build System
1>CMake does not need to re-run because D:/Codes/temp/CUDA/BandTester/Bin64/CMakeFiles/generate.stamp is up-to-date.
1>ビルドãƒã‚°ã¯ "file://d:\Codes\temp\CUDA\BandTester\Bin64\ZERO_CHECK.dir\Release\BuildLog.htm" ã«ä¿å˜ã•ã‚Œã¾ã—ãŸã€‚
1>ZERO_CHECK - エラー 0ã€è¦å‘Š 0
2>------ ビルド開始: プãƒã‚¸ã‚§ã‚¯ãƒˆ: BandTester, 構æˆ: Release x64 ------
2>Building NVCC (Device) object Release/BandTester_generated_bandwidthTest.cu.obj
2>bandwidthTest.cu
2>bandwidthTest.cu
2>bandwidthTest.cu
2>tmpxft_00001904_00000000-3_bandwidthTest.cudafe1.gpu
2>tmpxft_00001904_00000000-8_bandwidthTest.cudafe2.gpu
2>bandwidthTest.cu
2>tmpxft_00001904_00000000-3_bandwidthTest.cudafe1.cpp
2>tmpxft_00001904_00000000-14_bandwidthTest.ii
2>Note: including windows.h
2>Note: including math.h
2>Note: including assert.h
2>Note: including windows.h
2>Note: including math.h
2>Note: including assert.h
2>リンクã—ã¦ã„ã¾ã™…
2>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ) ã¯æ—¢ã« shrUtils64.lib(shrUtils.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@XZ) ã¯æ—¢ã« shrUtils64.lib(shrUtils.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: class std::locale::facet * __cdecl std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QEAAPEAV123@XZ) ã¯æ—¢ã« shrUtils64.lib(shrUtils.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPEAV12@@Z) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base )" (?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl)(void))" (?_AtModuleExit@@YAXP6AXXZ@Z) ã¯æ—¢ã« msvcprt.lib(locale0_implib.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPEAV_Locimp@12@XZ) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(locale0.obj) : error LNK2005: _Fac_tidy ã¯æ—¢ã« msvcprt.lib(locale0_implib.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@facet@locale@std@@CAXPEAV123@@Z) ã¯æ—¢ã« msvcprt.lib(locale0_implib.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPEAV12@@Z) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPEAV_Locimp@12@XZ) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(xlock.obj) : error LNK2005: "public: __cdecl std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QEAA@H@Z) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>libcpmt.lib(xlock.obj) : error LNK2005: "public: __cdecl std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QEAA@XZ) ã¯æ—¢ã« msvcprt.lib(MSVCP90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(setlocal.obj) : error LNK2005: _configthreadlocale ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(invarg.obj) : error LNK2005: _invalid_parameter_noinfo ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(lconv.obj) : error LNK2005: localeconv ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(tidtable.obj) : error LNK2005: _encode_pointer ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(tidtable.obj) : error LNK2005: _decode_pointer ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(stricmp.obj) : error LNK2005: _stricmp ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(mlock.obj) : error LNK2005: _unlock ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(mlock.obj) : error LNK2005: _lock ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(winxfltr.obj) : error LNK2005: _XcptFilter ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _amsg_exit ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _initterm_e ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: exit ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _cexit ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(atox.obj) : error LNK2005: atoi ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0init.obj) : error LNK2005: __xi_a ã¯æ—¢ã« MSVCRT.lib(cinitexe.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0init.obj) : error LNK2005: __xi_z ã¯æ—¢ã« MSVCRT.lib(cinitexe.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0init.obj) : error LNK2005: __xc_a ã¯æ—¢ã« MSVCRT.lib(cinitexe.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0init.obj) : error LNK2005: __xc_z ã¯æ—¢ã« MSVCRT.lib(cinitexe.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(crt0.obj) : error LNK2005: mainCRTStartup ã¯æ—¢ã« MSVCRT.lib(crtexe.obj) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LIBCMT.lib(errmode.obj) : error LNK2005: __set_app_type ã¯æ—¢ã« MSVCRT.lib(MSVCR90.dll) ã§å®šç¾©ã•ã‚Œã¦ã„ã¾ã™ã€‚
2>LINK : warning LNK4098: defaultlib 'MSVCRT' ã¯ä»–ã®ãƒ©ã‚¤ãƒ–ラリã®ä½¿ç”¨ã¨ç«¶åˆã—ã¦ã„ã¾ã™ã€‚/NODEFAULTLIB:library を使用ã—ã¦ãã ã•ã„。
2>LINK : warning LNK4098: defaultlib 'LIBCMT' ã¯ä»–ã®ãƒ©ã‚¤ãƒ–ラリã®ä½¿ç”¨ã¨ç«¶åˆã—ã¦ã„ã¾ã™ã€‚/NODEFAULTLIB:library を使用ã—ã¦ãã ã•ã„。
2>D:\Codes\temp\CUDA\BandTester\Bin64\Release\BandTester.exe : fatal error LNK1169: 1 ã¤ä»¥ä¸Šã®è¤‡æ•°å›žå®šç¾©ã•ã‚Œã¦ã„るシンボルãŒè¦‹ã¤ã‹ã‚Šã¾ã—ãŸã€‚
2>ビルドãƒã‚°ã¯ "file://d:\Codes\temp\CUDA\BandTester\Bin64\BandTester.dir\Release\BuildLog.htm" ã«ä¿å˜ã•ã‚Œã¾ã—ãŸã€‚
2>BandTester - エラー 37ã€è¦å‘Š 2
========== ビルド: 1 æ£å¸¸çµ‚了ã€1 失敗ã€0 æ›´æ–°ä¸è¦ã€0 スã‚ップ ==========
try putting this macro in a file called compiler_config.cmake, including it, calling it and see if it works. Works for me, but mileage may vary. Better yet try getting a hold of James Bigler on the cmake users group.
macro( compiler_config )
if( LINUX_BUILD )
else()
OPTION( USE_CUSTOM_COMPILER_SETTINGS "" ON )
if( USE_CUSTOM_COMPILER_SETTINGS )
# This is such an awful idea (global compiler settings)
SET( THREAD_DEBUG_OPT /MDd CACHE STRING "" FORCE )
# SET( THREAD_DEBUG_OPT /MTd CACHE STRING "" FORCE )
SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR " CACHE STRING "" FORCE )
SET( CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG ${THREAD_DEBUG_OPT} /Zi /Ob0 /Od /Gm " CACHE STRING "" FORCE )
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG ${THREAD_DEBUG_OPT} /Zi /Ob0 /Od " CACHE STRING "" FORCE )
SET( CMAKE_C_FLAGS_DEBUG "/D_DEBUG /MDd /Zi /Ob0 /Od " CACHE STRING "" FORCE )
SET (CMAKE_C_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od " CACHE STRING "" FORCE )
SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG" CACHE STRING "" FORCE )
SET (CMAKE_CXX_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "" FORCE )
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG" CACHE STRING "" FORCE )
SET (CMAKE_C_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000" CACHE STRING "" FORCE )
SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "/MD /O1 /Ob1 /D NDEBUG" CACHE STRING "" FORCE )
SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "" FORCE )
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG" CACHE STRING "" FORCE )
SET (CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib " CACHE STRING "" FORCE )
SET( CMAKE_EXE_LINKER_FLAGS_INIT /MACHINE:x64 CACHE STRING "" FORCE )
message( "CMAKE_EXE_LINKER_FLAGS_INIT = ${CMAKE_EXE_LINKER_FLAGS_INIT}" )
debug_message( "CMAKE_EXE_LINKER_FLAGS_INIT = ${CMAKE_EXE_LINKER_FLAGS_INIT}" )
debug_message( "CMAKE_CXX_FLAGS_DEBUG = " ${CMAKE_CXX_FLAGS_DEBUG} )
debug_message( "THREAD_DEBUG_OPT = " ${THREAD_DEBUG_OPT} )
debug_message( "THREAD_RELEASE_OPT = " ${THREAD_RELEASE_OPT} )
debug_message( "CMAKE_CXX_FLAGS_DEBUG = " ${CMAKE_CXX_FLAGS_DEBUG} )
debug_message( "CMAKE_CXX_FLAGS_MINSIZEREL = " ${CMAKE_CXX_FLAGS_MINSIZEREL} )
debug_message( "CMAKE_CXX_FLAGS_RELEASE = " ${CMAKE_CXX_FLAGS_RELEASE} )
debug_message( "CMAKE_CXX_FLAGS_RELWITHDEBINFO = " ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} )
debug_message( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS} )
debug_message( "CMAKE_MODULE_LINKER_FLAGS = " ${CMAKE_MODULE_LINKER_FLAGS} )
debug_message( "CMAKE_SHARED_LINKER_FLAGS = " ${CMAKE_SHARED_LINKER_FLAGS} )
else()
message( 'custom windows build disabled' )
endif()
endif()
endmacro()