Linking Errors

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!

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?

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.

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!

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