CUDA: LNK2005 Linker Errors

The Problem

When building a Visual Studio solution which has CUDA source files (*.cu), LNK2005 linker errors of the following kind might be seen:

LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRT.lib(MSVCR90.dll)

What does it mean?

This indicates a mismatch between the kind of C runtime library used by the CUDA Build Rule and that used for the rest of the Visual C++ project.

How to fix it?

This problem can be fixed by making both of these use the same kind of C runtime library. For example, if the Visual C++ project is compiled using Multi Threaded DLL (/MD) and the CUDA build rule has Multi Threaded (/MT), then change the CUDA build rule to use /MD too.


Tried with: CUDA 3.2 and Visual Studio 2008

3 thoughts on “CUDA: LNK2005 Linker Errors

  1. I have problem with LNK 2005 when I am trying to compile DLL file. This article seems to help me but I need to ask one simple question: Where CUDA build rule can be changed to /MD?

    I was looking for it in Custom Build Rules –> Cuda Build Rule v3.0.0 –> Modify Rule File –> Cuda Build Rule –> Nodify Build Rule but I did not find it.

    Would you be so kind and help me?



    1. I found it:
      Project –> Property –> CUDA Build Rule v3.0.0 –> General –> Runtime Library
      Project –> Property –> CUDA Runtime API –> Host –> Runtime Library

      Thanks for artice it was very helpful !!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.