# Linking Errors

**URL:** <https://forums.developer.nvidia.com/t/linking-errors/6406>\
**Category:** CUDA Programming and Performance\
**Created:** [November 18, 2008, 12:04am UTC](https://forums.developer.nvidia.com/t/linking-errors/6406 "2008-11-18T00:04:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiberius](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tiberius](https://forums.developer.nvidia.com/u/Tiberius)\
**Post date:** [November 18, 2008, 12:04am UTC](https://forums.developer.nvidia.com/t/linking-errors/6406/1 "2008-11-18T00:04:46Z")

</div>

All,

I keep trying some simple tutorials, but I keep running into linking errors. I am using VS Studio 2005 on XP x64. I start by generating a new static library project using the CUDA Wizard. I then add a win32 console project to the solution. I use the configuration manager to create 64 bit versions of both projects. I link in the static library. Everything compiles and links correctly at this point, and I see the correct output from the “Hello CUDA” program generated by the wizard.

As soon as I try to do something more complicated, I see the following errors:  
1\>LIBCMT.lib(setlocal.obj) : error LNK2005: \_configthreadlocale already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(tidtable.obj) : error LNK2005: \_encode\_pointer already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(tidtable.obj) : error LNK2005: \_decode\_pointer already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(invarg.obj) : error LNK2005: \_invalid\_parameter\_noinfo already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(lconv.obj) : error LNK2005: localeconv already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(trnsctrl.obj) : error LNK2005: \_\_CxxFrameHandler3 already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(hooks.obj) : error LNK2005: “void \_\_cdecl terminate(void)” (?terminate@@YAXXZ) already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(typinfo.obj) : error LNK2005: “public: void \_\_cdecl type\_info::\_type\_info\_dtor\_internal\_method(void)” (?\_type\_info\_dtor\_internal\_method@type\_info@@QEAAXXZ) already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(typinfo.obj) : error LNK2005: “private: \_\_cdecl type\_info::type\_info(class type\_info const &)” (??0type\_info@@AEAA@AEBV0@@Z) already defined in MSVCRT.lib(ti\_inst.obj)  
1\>LIBCMT.lib(typinfo.obj) : error LNK2005: “private: class type\_info & \_\_cdecl type\_info::operator=(class type\_info const &)” (??4type\_info@@AEAAAEAV0@AEBV0@@Z) already defined in MSVCRT.lib(ti\_inst.obj)  
1\>LIBCMT.lib(\_file.obj) : error LNK2005: \_\_iob\_func already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(crt0dat.obj) : error LNK2005: \_amsg\_exit already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(crt0dat.obj) : error LNK2005: \_initterm\_e already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(crt0dat.obj) : error LNK2005: exit already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(crt0dat.obj) : error LNK2005: \_exit already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(crt0dat.obj) : error LNK2005: \_cexit already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(mlock.obj) : error LNK2005: \_unlock already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(mlock.obj) : error LNK2005: \_lock already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(winxfltr.obj) : error LNK2005: \_XcptFilter already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(errmode.obj) : error LNK2005: \_\_set\_app\_type already defined in MSVCRT.lib(MSVCR80.dll)  
1\>LIBCMT.lib(crt0init.obj) : error LNK2005: \_\_xi\_a already defined in MSVCRT.lib(cinitexe.obj)  
1\>LIBCMT.lib(crt0init.obj) : error LNK2005: \_\_xi\_z already defined in MSVCRT.lib(cinitexe.obj)  
1\>LIBCMT.lib(crt0init.obj) : error LNK2005: \_\_xc\_a already defined in MSVCRT.lib(cinitexe.obj)  
1\>LIBCMT.lib(crt0init.obj) : error LNK2005: \_\_xc\_z already defined in MSVCRT.lib(cinitexe.obj)

My searches indicate that this usually happens if you modify settings such that you are attempting to link both the threaded and non-threaded versions of the C runtime. I do not add any files, and I do not modify any compiler settings after successfully performing the “Hello CUDA” test. Unless something is being modified automatically, this does not seem likely.

After it happened the first time, I thought I might have messed something up. I started from scratch, and it happened again… Does anybody have any ideas why this is happening?

Thanks!

---

<div class="post-metadata">

**Author:** ![kyzhao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kyzhao](https://forums.developer.nvidia.com/u/kyzhao)\
**Post date:** [November 18, 2008, 7:49am UTC](https://forums.developer.nvidia.com/t/linking-errors/6406/2 "2008-11-18T07:49:58Z")

</div>

close the solution and the open the solution againâ€¦â€¦it will be ok.

the error means the C runtime lib, C++ runtime lib and MS vc runtime lib are conflicting.

---

<div class="post-metadata">

**Author:** ![Tiberius](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tiberius](https://forums.developer.nvidia.com/u/Tiberius)\
**Post date:** [December 4, 2008, 11:12pm UTC](https://forums.developer.nvidia.com/t/linking-errors/6406/3 "2008-12-04T23:12:30Z")

</div>

> [@](#):
>
> close the solution and the open the solution againâ€¦â€¦it will be ok.
> 
> the error means the C runtime lib, C++ runtime lib and MS vc runtime lib are conflicting.

After a long time of not seeing the error, I am suddenly seeing it again. Unfortunately, closing and reopening the solution does not help. Any other suggestions?

I also notice that I can not many of the STL types in my library. Adding ofstream/ifstream, strings, etc immediately causes a similar linking issue. Is this normal?

---

<div class="post-metadata">

**Author:** ![kyzhao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kyzhao](https://forums.developer.nvidia.com/u/kyzhao)\
**Post date:** [December 5, 2008, 2:52am UTC](https://forums.developer.nvidia.com/t/linking-errors/6406/4 "2008-12-05T02:52:53Z")

</div>

runtime lib errors.

set the compiler link lib as the same with the main project.

right key on the project–\> properties → CUDA → Backends → Compiler Options: … here “/MT, /MTd, /MD, /MDd”, choose the right one depends on your project.

ps: Compiler Options: you can set the host C/C++ compiler commands here.

---

<div class="post-metadata">

**Author:** ![Tiberius](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Tiberius](https://forums.developer.nvidia.com/u/Tiberius)\
**Post date:** [December 5, 2008, 3:46am UTC](https://forums.developer.nvidia.com/t/linking-errors/6406/5 "2008-12-05T03:46:11Z")

</div>

For the moment, I worked around the issue by changing the static library to a dll. I was actually shocked at how easily that worked out… I will try your suggestion in the morning.

Thanks!

---

<div class="post-metadata">

**Author:** ![kyzhao](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@kyzhao](https://forums.developer.nvidia.com/u/kyzhao)\
**Post date:** [December 5, 2008, 4:57am UTC](https://forums.developer.nvidia.com/t/linking-errors/6406/6 "2008-12-05T04:57:45Z")

</div>

pleasure:) any problem with the wizard please let me know~~
