I have been trying to use the static CUDA Runtime included in CUDA 5.5, but facing some problems.
Following are the results of linking cudart_static.lib in different IDEs:
Visual Studio 2012:
Linker fails with the following error:
error LNK2038: mismatch detected for '_MSC_VER': value '1600'
doesn't match value '1700' in kernel.cu.obj
Seems like the static CUDA runtime has been compiled using VS2010.
Visual Studio 2010:
No Error. Links successfully.
Visual Studio 2008:
Links successfully with the following series of warnings:
cudart_static.lib(cuda_*.obj) : warning LNK4229: invalid directive '/FAILIFMISMATCH:_MSC_VER=1600' encountered; ignored
Also, in all the IDEs, when running in DEBUG configuration the linking fails with following error:
error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value
'0' doesn't match value '2' in kernel.cu.obj
Questions:
How to link the static CUDA runtime in Visual Studio 2012?
How to link the same in DEBUG configuration?
Regarding your first question:
1.How to link the static CUDA runtime in Visual Studio 2012?
From the release notes:
"The new static version of the cudart library shipped with the CUDA 5.5 Release
Candidate (RC) on Windows will not work with Microsoft Visual Studio 2008 (VC9.0) nor with Microsoft Visual Studio 2012 (VC 11.0). Starting with CUDA 5.5, the nvcc compiler will link against the static version of the cudart library by default, so
in order for the CUDA 5.5 RC to correctly work with Microsoft Visual Studio 2008 or 2012, please use the --cudart=shared option to nvcc to force linkage against the shared version of the cudart library. If an application is not relying on the nvcc
capability to automatically link to the cudart library, and is instead explicitly linking against cudart.lib, then that application will continue to link correctly as well."
Usage of the static library on windows for VS2012 and/or VS2008 is therefore unsupported at this time.
Regarding your second question:
2.How to link the same in DEBUG configuration?
The issue with debug mode has to do with how the cudart static library was built. Normal practice would be to include two static libraries, one for debug mode and one for release mode. As a workaround, you can try something like this (in VS 2010):
Project Pages...Configuration Properties...C,C++...Preprocessor...Preprocessor Definitions
Add "_ITERATOR_DEBUG_LEVEL=0"
Your mileage may vary.
Related
i have very old project who has been made in visual studio 2008 with windows xp 32 bit.
I am trying to run this project in windows 7 64 bit with visual studio 2017.
i dont know much details about the project.
i know that MFC MBCS pakage was use.
so now i am trying to compile it and got some compilation errors.
the main one is :
__int64' followed by 'int64' is illegal
in the stdint.h file.
the line that get the error is:
typedef long long int64_d
i check the project and there is no call or use of the stdint header.
i read that it can be because the code build with old version of c++ and now i try to compile with higher version then c++11.
any help will be very appraised.
Thank You!
Well i figure it out.
the problem was that i am using old libs and dlls(probably made by v100 toolset of VS 2010) ,
so i set the platform toolset to the same version of the visual studio that make those
libs and dlls - visual studio 2010 v100.
to do that go to :
right click on the project
properties
configuration properties
general
platform toolset
and set it to v100(or other version needed)
now it's work fine!
Visual Studio 2017 RC includes much tighter CMake integration, allowing one to skip the intermediate step of generating project/solution files and use CMake effectively as the project file itself. There is sufficient documentation from Microsoft for using these features with regular C++ files, and there is sufficient documentation on this website (example) for making CUDA and Cmake play nicely, when it comes to linking CUDA code to C++ code.
What I can't find information on is how to make CMake, Visual Studio 2017 RC, and CUDA 8.0 all play nicely. This is a difficult problem, because 2017RC has no integration for the CUDA SDK anyways, and I was hoping to use 2017RC so that my C++ interface to the CUDA code could use C++14 and/or C++17. I'm working on the beginning of a large project that will primarily involve writing a static CUDA library that is accessed through C++: so, I'd like to get the CMake to take care of compiling my CUDA sources into a static library, and for it to help with feeding the linking information to Visual Studio. So far, I haven't had any success with using FindCUDA's various features to accomplish this, but I'm assuming that's due to a misunderstanding on my part. I've read through the documentation on separable compilation from Nvidia, but that wasn't helpful for figuring out CMake.
Further, whenever I try to use CMake in VS2017RC, I still end up with the various vcxproj files that CMake likes to spit out. Is this due to an error on my part? How do I edit the build command arguments, or CMakeLists.txt, to get the functionality demonstrated here to work?
The very short (and only at the time of writing) answer is that you can't. CUDA 8 doesn't support VS2017. Only VS2015 is presently supported.
You can always find the compiler/IDE versions which the release version of CUDA supports here
Edit to add that the CUDA 9 release will add official support for VS2017.
All you need to do is set the CUDA_HOST_COMPILER variable to a supported compiler for example the visual studio 2015 compiler.
In my case this is:
C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe
As both runtime libraries are binary compatible you can use the 2015 compiler within CUDA and compile all the rest of the application with the 2017 compiler.
A VC++ 2008 win32 console application uses some MFC functions, it can run without problem in 'Debug' mode within the VC++ 2008 environment. Also, the debug executable can ran on any computer with full version of visual studio 2008 installed.
But that same debug executable won't run on systems that don't have the visual studio 2008 installed, it gives the following error message:
The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.
The initial search for this problem leads to MSN recommendation to install the VC++ 2008 x86 redistributable SP1. But this failed to resolve the problem.
Then, the win32 console application is recompiled for 'Release' mode and it gives the following error message:
fatal error C1189:#error: Building MFC application with /MD[d](CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
this error happens in afx.h header.
I tried to actually #define _AFXDLL in preprocessor, but it created new errors about unable to convert MFC type of string to char* etc
I also tried 'Use of MFC' settings: in static library and shared DLL, both create more errors
The thing is, the original program was created in VC++ 6.0 and it used a lot of MFC functions (especially string and CObject), but after recompile in VC++ 2008 in a win32 console app, it somehow can work in debug mode, but can't be stand-alone exe in release mode, which is kinda what I need to have a stand-alone exe that can run on newer windows (7 or 8)
Could anyone help. Thanks.
Yes. Don't build in Debug mode. Build for Release. You can't legally distribute the Debug DLLs. You can build a Release version with Debugging information in it--via PDB files.
This may also happen if your release build has dependencies against some debug libraries, link against non debug ones.
I have an integrated visual studio (2010) and Qt(4 visual studio addin) combination and just recently decided to add VTK5.I have managed to compile VTK as per the numerous instructions everywhere .However i tried to build a simple example from the VTK website but i get the Dll errors below.I have added include paths in visual studio but just can't compile .please direct me on what i should do next .
GeneratedFiles\Debug\moc_QVTKWidget.cpp(73): warning C4273: 'staticMetaObjectExtraData' : inconsistent dll linkage
E:/libs/vtk/vtk-5.10.1/VTK5.10.1/GUISupport/Qt/QVTKWidget.h(76) : see previous definition of 'private: static QMetaObjectExtraData const QVTKWidget::staticMetaObjectExtraData'
GeneratedFiles\Debug\moc_QVTKWidget.cpp(77): error C2491: 'QVTKWidget::staticMetaObject' : definition of dllimport static data member not allowed
I have been able to build a working environment following this guide, it is really helpful and well explained (and, as the more important thing, it uses VS2010, QT 4 and VTK 5): http://guitarcplusplus.blogspot.it/2013/02/itk-vtk-qt-on-window-7-64bit-and-visual.html.
I've been sent a sample app for a newly minted SDK, and I can't compile it - it won't compile at all in Visual Studio Express for reasons of ATL, and that seems to be the only version of VS 2010 that Microsoft still makes available. So I'm trying to compile it in VS 2012 Professional, but it gives me error LNK2038. From what I can gather e.g. from this thread, the problem is down to trying to use .lib files compiled for 2010 in the 2012 version. Since I'm not the one who compiled the .lib, and I don't have the code for it, and VS 2010 is inaccessible, I'm really not sure what to do about this unless the original authors recompile it. Any suggestions? Something basic I'm missing? Many thanks for any help.
Library files cannot be reused across different versions of the compiler. You will need to do one of the following:
Compile your project with the same version of the compiler used for creating the library files you have.
Obtain new library files from the owner of the code, compiled using the same compiler you are now using.
Obtain the source code for the libraries, and compile new versions of them yourself.
Rewrite the code you own to not depend on the libraries you cannot control, since your build environment does not allow for their use.