3

I am compiling a dynamic library containing cpp with cu files with Visual Studio 2013, and I get such errors during linking:

proj_generated_cufile.cu.obj : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj
libcpmt.lib(ios.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj

I am not using any additional libraries, and I have already tried to set the Runtime Library in the project preferences -> C/C++ -> Code generation to "Multi-Threaded DLL (/MD)" and under CUDA C/C++ -> Host to "Multi-Threaded DLL (/MD)" or to "inherit from host".

I am generating the project with cmake (with cuda_add_library).

Can it be, that the problem is, that I am trying to compile a dynamic library? What contradicts this assumption is that when I am compiling only the cpp files the compilation succeeds.

Thank you for any suggestion!

A. Tuzko
  • 31
  • 1
  • 4
  • http://stackoverflow.com/q/14714877/681865 – talonmies Aug 23 '16 at 13:49
  • Thank you, but I am not linking any additional libraries. – A. Tuzko Aug 23 '16 at 13:55
  • But you are - the VS C++ runtime library, and that is where the build settings mismatch is occurring – talonmies Aug 23 '16 at 14:31
  • 3
    Oh I have found the problem, the CUDA_PROPAGATE_HOST_FLAGS was set to OFF in the cmake file.... Thank you guys, and sorry. – A. Tuzko Aug 23 '16 at 15:05
  • In my case, I had to use MDd/MD flags instead of MT/MTd flags in cmake, compile and generate again along with CUDA_PROPAGATE_HOST_FLAGS = 1. Changing to Multi-Threaded DLL (/MD) or Multi-Threaded Debug DLL (/MDd) in Visual Studio was not propagating host flags. – Saleh Jul 11 '18 at 06:37

1 Answers1

2

I think , one was linked against the CRT DLL (/MD) and the other was linked statically (/MT).

Cherkesgiller
  • 520
  • 4
  • 17