error LNK2019: unresolved external symbol

OS Vista 64 Bits
CPU AMD 955 four cores
Visual Studio 2008

How do I fix the “error LNK2019: unresolved external symbol”

Thank you in Advance

Build Log Build started: Project: cudaOpenMP, Configuration: Debug|x64
Command Lines Creating temporary file “d:\CUDA\Exercises\test_mp\NVIDIA CUDA SDK\projects\cudaOpenMP\x64\Debug\RSP00001040366052.rsp” with contents
[
/OUT:“…/…/bin/win64/Debug/cudaOpenMP.exe” /VERSION:1 /INCREMENTAL:NO /LIBPATH:“D:\CUDA\lib” /LIBPATH:“…/…/common/lib” /LIBPATH:“D:\CUDA\Exercises\test_mp\NVIDIA CUDA SDK\common\lib” /MANIFEST /MANIFESTFILE:“x64\Debug\cudaOpenMP.exe.intermediate.manifest” /MANIFESTUAC:“level=‘asInvoker’ uiAccess=‘false’” /DEBUG /PDB:“x64\Debug/cudaOpenMP.pdb” /SUBSYSTEM:CONSOLE /OPT:NOICF /DYNAMICBASE:NO /MACHINE:X64 cudart.lib cutil64D.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

“.\x64\Debug\cudaOpenMP.cu.obj”
]
Creating command line “link.exe @“d:\CUDA\Exercises\test_mp\NVIDIA CUDA SDK\projects\cudaOpenMP\x64\Debug\RSP00001040366052.rsp” /NOLOGO /ERRORREPORT:PROMPT”
Output Window Linking…
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaThreadExit referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaGetLastError referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaFree referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaConfigureCall referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaMemcpy referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaMemset referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaMalloc referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaGetDevice referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaGetErrorString referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaSetDevice referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaGetDeviceProperties referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaGetDeviceCount referenced in function main
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaSetupArgument referenced in function __device_stub__Z17kernelAddConstantPii
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol __cudaRegisterFunction referenced in function __sti____cudaRegisterAll_45_tmpxft_00001714_00000000_6_cudaO
penMP_cpp1_ii_940c3a36
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol __cudaRegisterFatBinary referenced in function __sti____cudaRegisterAll_45_tmpxft_00001714_00000000_6_cudaO
penMP_cpp1_ii_940c3a36
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol __cudaUnregisterFatBinary referenced in function __cudaUnregisterBinaryUtil
cudaOpenMP.cu.obj : error LNK2019: unresolved external symbol cudaLaunch referenced in function “enum cudaError __cdecl cudaLaunch(char *)” (??$cudaLaunch@D@@YA?AW4cudaError@@PEAD@Z)
…/…/bin/win64/Debug/cudaOpenMP.exe : fatal error LNK1120: 17 unresolved externals
Results Build Time 0:00
Build log was saved at “file://d:\CUDA\Exercises\test_mp\NVIDIA CUDA SDK\projects\cudaOpenMP\x64\Debug\BuildLog.htm”
cudaOpenMP - 18 error(s), 0 warning(s)

Hi. I am running with the same problem. It is almost impossible to get all necessary settings correct within Visual Studio. I got this problem whan I replaced a version of cuda.rules with version 2.3 Cuda.Rules and tried to rebuild necessary dependencies for CUDA-project. It is most probably a missing path or other setup alike somewhere. If you success to fing the correct place and parameter, please let us know!

I wonder what kind of dimmed-vision nerds there are in NVIDIA cuda labs as they are not able to publish a straight forward cookbook how to set up the VS environment in each revision of CUDA. I have been strugling endlessly with incorrect setups found from this same forum, weird indications like “invalid device function” etc. which all turned out to be a consequence of improper parameters and build rules. Finding the reason was just pure luck on fourth week of frustrating testing. No good. Conclusion: if you start using CUDA with Visual Studio, you will need several weeks to learn all necessary tricks and setups with the environment, not related to coding CUDA at all. Considering other solutions is really sensible. External Image

I’m also having a similar problem. To be honest I think you’re being a bit harsh on CUDA though, if it were an MS product it’d probably be really east to use with VS. I’m having to use VS because of where I work and getting it to work is a pain. Usually I work under Linux and I can tell you that everything CUDA just works, right out the box…

OK, I finally solved this. It was very simple in the end…

My app was not linking to cudart.lib, the CUDA runtime library. I added cudart.lib to my additional libraries in my “start-up” project, which is not my CUDA project, and now it works.

Simple really. Why doesn’t the build rule do this automatically. It’s such a minor thing yet it causes a lot of problems as far as I can tell. This thread is just one of many I’ve come accross on the subject. Now it’s one of the first to have a solution :)

1 Like

I have a similar problem as follows:

错误 2 error LNK2019: æ— æ³•è§£æžçš„å¤–éƒ¨ç¬¦å· “public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)” (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z),该符号在函数 “public: __thiscall std::_Locinfo::_Locinfo(class std::basic_string<char,struct std::char_traits,class std::allocator > const &)” (??0_Locinfo@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z) 中被引用 shrUtils32D.lib

错误 3 error LNK2001: æ— æ³•è§£æžçš„å¤–éƒ¨ç¬¦å· “public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)” (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) shrUtils32D.lib

错误 4 fatal error LNK1120: 1 ä¸ªæ— æ³•è§£æžçš„å¤–éƒ¨å‘½ä»¤ …/…/bin/win32/EmuDebug/deviceQuery.exe

I try to add “cudart.lib” to the project, and I found other libs like “cudartemu.lib cutil32D.lib shrUtils32D.lib” is already included. Then the problem still happen. I think the problem is derived from “shrUtils32D.lib”, but I don’t know how to solve. :"> please take some suggestions, thank you very much.

To Jason and all others having compiler issues with Visual Studio:
As a newb, I experienced these issues too. I found a wizard that sets up stuff correctly for using CUDA in Visual Studio.

It works great for me, and lets me focus on writing code, rather than bother with setting up the environment. You can download the wizard here:
[url=“CUDA VS Wizard - Browse Files at SourceForge.net”]CUDA VS Wizard - Browse Files at SourceForge.net

There is also a forum thread on this wizard:
[url=“http://forums.nvidia.com/index.php?showtopic=83054”]http://forums.nvidia.com/index.php?showtopic=83054[/url]

Thank you very much^^, that’s an easy way to do it. :rolleyes:

I had this happen to me on vista 64. Install the win32 cuda toolkit and the linking problem goes away.

I had this happen to me on vista 64. Install the win32 cuda toolkit and the linking problem goes away.

What do you mean by “start up” project. How is it different from your normal project? I really need help with this. Can you let me know where the startup project is located in VS and how to configure it.

1 Like

This thread is a year old but I had this same issue, and its real frustrating finding a thread unfinished, so I will finish it. I found that by putting cudart.lib in the additional dependencies solved the problem. Additional dependencies can be found: project properties >> Linker >> input.

@Pearlmam, I had the same issue, and you made the resolution easy after reading through all the posts here, guess I should have started at the bottom

I’m trying to write a simple code for getting some information from my GPU (NVidia Geforce 760 GTX) such as temperature using NVAPI.
I started with CUDA sample codes. Maybe you see these sample codes provided by NVidia. I copied one of the sample codes (‘CUDA Samples\v6.5\0_Simple\vectorAdd’) to write in this sample. I copied all of ‘.h’ files of NVAPI to ‘CUDA Samples\v6.5\common\inc’ and copied ‘nvapi.lib’ to ‘CUDA Samples\v6.5\common\lib\Win32’ and copied ‘nvapi64.lib’ to ‘CUDA Samples\v6.5\common\lib\x64’.
I preformed these copies to ‘C:\Program Files\CUDA\v6.5\include’ and ‘C:\Program Files\CUDA\v6.5\lib’.

But when I build my code I received these errors:

Error 28 error LNK2019: unresolved external symbol NvAPI_GPU_GetThermalSettings referenced in function...
Error 29 error LNK2019: unresolved external symbol NvAPI_GPU_GetFullName referenced in function...
and some similar errors.

As I stated, I copied these nvapi*.h and nvapi*.lib files to include and lib folders of cuda sample codes. All of the cuda sample codes was being build in those folders correctly. I copied one of the sample codes (vecAdd) and added my new codes (including temperature management codes) to that project.

My main question is that why this task does not work? I didn’t create any new project. I used from prepared project files that worked correctly and I copied include and lib files.

Besides, after reading your comment, I added address of extracted folders of nvapi to Linker → General → Additional Library Dependencies. This is shown in picture below.
External Media

Please also take a look at the picture below: I wrote just three lines of my desired code (inside vecAdd code), and build it. There is no error, although I used two datatypes from nvapi library. But when I add some other codes, I will be faced with the mentioned error.
External Media

Please help me
Thanks

The question is answered here: [url]c++ - error LNK2019: unresolved external symbol NvAPI_GPU_GetThermalSettings referenced in - Stack Overflow

you are right, adding cudart.lib solved the issue.
this is a serious issue with nvidia, they should give crisp tutorial to start with MS VC++…

thanks