Embedding Python in a Visual Studio 2012 C++ Project - c++

I included the usage of python scripts for my c++ project in Visual Studio 2010 like described in the CodeProject article: http://www.codeproject.com/Articles/11805/Embedding-Python-in-C-C-Part-I
This was working fine until I tried to compile my project with Visual Studio 2012. To compile it with 2012 if 2010 is NOT installed it's required to change the platform toolset from v100 to v110. After changing the toolset the included "pyconfig.h" gives some include error, because the file "basetsd.h" is not found (with python 2.7 and 3.3 the same). The pyconfig shows some #ifdef what is working for VS10 (and I think down to VS6) but the file for VS12 seems to be missing:
#if defined(_MSC_VER) && _MSC_VER >= 1200
/* This file only exists in VC 6.0 or higher */
#include <basetsd.h>
#endif
If I add some include path (Windows Toolkit) or delete the include command it compiles until the linker cannot find or open the "kernel32.lib". However, if I add a lib path for some kernel32.lib all python commands will unresolved.
How to get that work? What's wrong with Python and VS2012?

Perhaps your version of "Python.h" is only compatible with Visual Studio 2010. I attached a link of "Python.h" that claims to be for VS2012, try it out and let us know if it solves your issue.
http://pytools.codeplex.com/releases

It's running now with the following lib paths:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib;C:\Python27\libs
But I still don't understand it...

Related

CUDA: Triple Angle Brackets gives me an error in Visual Studio [duplicate]

I'm trying to install CUDA, but I get a message saying "No supported version of visual studio was found". I think that this is because I am using Visual Studio 2017 (Community), and CUDA currently only supports up to Visual Studio 2015. Unfortunately, Microsoft will not allow me to download old versions of Visual Studio without paying a subscription fee.
Is there a way I can get around the compatibility issue with VS 2017, or can I not use CUDA?
If you want to install CUDA 8.0 with Visual Studio 2017 you need to install additional components for Visual Studio 2017.Click on the Start Menu and type Visual Studio Installer. Open Visual Studio InstallerOpen Individual components tab and select VC++ 2015.3 v140 toolset
under Compilers, build tools and runtimes.
You also need to install .NET Framework 3.5 if you didn't have it installed. Nvda.Build.CudaTasks.v8.0.dll assembly dependents on MS .NET Framework 3.5.
Open Classical Control Panel, go to Programs and features and press Turn Windows features on or off. Check .NET Framework 3.5 and press OK.
Download full CUDA toolkit distribution and extract it somewhere on your disk.
If you didn't have CUDA toolkit installed, do it now. If you have only Visual Studio 2017 installed, unselect Visual Studio integration checkbox.
Now you want to receive the "No supported version of the visual studio was found" error.
But in order to successfully build Cuda toolkit projects in Visual Studio 2017, you also need to follow steps 5 and 6.
Go to the CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions folder in your extracted distribution, copy all the files and paste them to C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\v140\BuildCustomizations:
In the last step, you will need to edit your Cuda projects to recognize NVidia's build tasks from Visual Studio 2017. Open your .vcxproj file in a text editor and find all occurrences of CUDA 8.0.props. Replace the macro at the beginning of the string with $(VCTargetsPath14) so that XML snippet would look as follows:
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath14)\BuildCustomizations\CUDA 8.0.props" /></ImportGroup>
Don't forget to edit the custom targets path at the end of the file:
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath14)\BuildCustomizations\CUDA 8.0.targets" /></ImportGroup>
Make sure to double check your path conifuration!
If you use nvcc from command prompt you might not be calling cl.exe from Visual Studio folder!
Now you can build your Cuda project from Visual Studio 2017.
Parts of this solution are from Oleg Tarasov blog.
At the moment, Microsoft still seems to be making VS2015 Update 2 community edition available. You have to join the "dev essentials" program, but it seems to be free.
I was able to download the installer from here recently.
Update: CUDA 9 RC was made available yesterday at developer.nvidia.com to registered developers, and it has support for VS 2017.
Thank you everyone for your help. I just wanted to supplement this post with the last pieces of the puzzle. CUDA v9.0 RC is looking for VS2017 to identify as 1910 but the latest update actually identifies as 1911. To fix open .../CUDA/v9.0/include/crt/host_config.h and change this line:
#if _MSC_VER < 1600 || _MSC_VER > 1910
to this:
#if _MSC_VER < 1600 || _MSC_VER > 1911
You may also have to add the following to your CMakeLists:
list(APPEND CUDA_NVCC_FLAGS --cl-version=2017)
For people seeing this latter.
First, try to just install CUDA 10 (CUDA Toolkit 10.0).
If it still doesn't work without any mods make sure that you have as many VC++ toolsets as you see on the list. Check out this video, stop at 8:41 and compare the lists.
If for some reason you have to use CUDA 9.0 - 9.2 you will need to jump some hoops:
For cmd builds set vcvars_ver=14.11 - see this answer
For IDE builds set Platform Toolset (in project properties - General) to
Visual Studio 2017 (v141)) or
Visual Studio 2015 (v140))
If you have very customized cmd based build, hunt #if _MSC_VER (in .../CUDA/.../include/crt/host_config.h) and remove trailing || _MSC_VER > ...
In order to get working Cuda compiler nvcc in windows shell you need to do following
install proper toolset version from individual component for VS 2017 - VC++ 2017 version 15.4 v.14.11 toolset
Run in windows shell following "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.11
You can compile nvcc code without errors from windows shell
I ran into the same issue using CUDA 9.1 and VS2017 Enterprise.
After changing the VC++ compiler to v140 (instead of 141) everything runs fine.
Already had flags
#if _MSC_VER < 1600 || _MSC_VER > 1911
But it wouldn't stop showing the error.
No idea why, but trying to run it on VS2015 lead to errors about v141 not being installed... so because of some twisted logic I tried to not use v141 where it was installed... and everything worked!!
Leaving this here as it may help someone else in the same situation. (although I really don't understand the why, how, when, who or what of the solution.
Latest update (correct as of 06/12/2018) latest Cuda version is 9.2 and latest Visual Studio version is 2017.7 do NOT work together. The instructions provided in solution above don't work. Here is what worked for me:
Uninstall Visual Studio.
Uninstall Visual Studio Installer
Download Visual Studio 2017.6 (note that Microsoft is known to change links and revisions without notice) https://learn.microsoft.com/en-us/visualstudio/productinfo/installing-an-earlier-release-of-vs2017
Launch installer
Go to Individual Components. Click on Windows 10 SDK 10.0.15063
enter image description here
Download cuda Toolkit from the official website: https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal
You may need to download patch.
I wanted to edit my CUDA programs using a text editor (i.e. Sublime) and compile them from the command prompt but I ran into an nvcc compiler error. I installed Visual Studio 2017 with Windows 10 OS but after compiling, it said "only version of VS 2012, 13, 15 and 17 are allowed." So what I did was to intall VC++ 2015 toolkit from the installation package of the VS 2017 installer (refer to the image of the top post). I didnt go through his entire process instead, I only copied the path of my cl.exe file from the newly created VS 14.0 folder to the environment variable. The .exe can be found here:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
Hope this helps!
Just as update. My compatibility is:
Cuda version 11.2
Visual Studio Community 2019

visual studio 2017, d3dx9.h No such file or directory

I'm trying to compile mpc-hc. Compilation instructions say to use VS2015, but I went for VS2017 instead.
What package should I install to get Direct3D9 headers?

Visual Studio 2013 can't located header files when using the VS 2010 platform toolset

Yesterday I had to reinstall Visual Studio 2010 on a computer with both VS 2012 and VS 2013, because I needed to compile older code. The Visual Studio 2010 installation caused header file issues, as described here . I followed the details provided in the answers, and got VS 2010 to install properly.
Now, when I run the VS 2010 version of msbuild, it compiles C++ code flawlessly. All the header files are properly installed in c:\program files (x86)\Microsoft Visual Studio 10.0\VC\include .
However, when I open a project in Visual Studio 2013, and set the Platform Toolset to v100 (which is VS 2010), it can't find the header files! Although they are right there!
This was originally a VS 2013 project, and I changed the platform toolset to VS 2010. This did not change the Include Directories property of the project, which was $(VC_IncludePath).
This macro is not defined by VS 2010, so the compiler can't find the include files.

I can't include <iostream> in Visual C++ 2010 Express Edition

Few months ago I installed Visual Studio 2012 Ultimate.
Beacuse of some school projects, I had to install Visual C++ 2010 Express Edition.
Now, when I try to compile a project in Visual C++ 2010, I cannot include any usual header
like <iostream>, <cmath>, etc. The folder the compiler searches is C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include.
But all these include files are located in C:\Program Files\Microsoft Visual Studio 11.0\VC\include.
Can someone please explain me what is about with these two paths (what are the differences)
and how to solve the #include <iostream> problem.
From the details you share, I understand that /Microsoft Visual Studio 10.0/VC/include directory doesn't contain the standard header files.
The include directory $(VCInstallDir) in VS 2010 is probably pointing at /Microsoft Visual Studio 10.0/VC. Since, the include folder is empty you don't get to compile your code.
As far as I know, this problem occurs when people install VS2012 and 2010 afterwards. My guess some problem occurs with registries and VS2010 Setup doesn't install header files properly.
You might have 4 options:
Using Visual Studio Tools->Visual Studio Command Prompt, change the $(VCInstallDir) such that it points to "/Visual Studio 11.0/include"
If you know someone who has VS2010(same edition as yours) working properly, copy their "/VC/include" directory to yours.
Uninstall both VS2012 and VS2010 ( full uninstall as described here: http://archive.msdn.microsoft.com/vs2010uninstall) Clean the registries and install VS2010 again.
Make a fresh Windows installation and install VS2010 afterwards.
Sadly only option 4 worked in my case. Option 2 worked too, but I got other problems in another project. Good luck.
I got the same problem. A fresh Windows and VC++ 2010 Express install on a virtual machine solved the problem.

How do I get crtdbg.h file?

I am using MinGW GCC + Eclipse on Windows, and I have run into this error:
C:\Program Files\ITG Derivatives LLC\api_clear-2.0.2.48\include/windows/csassert.h:12:20: fatal error crtdbg.h No such file or directory
What is the crtdbg.h file? How can I get it and solve this problem?
I ran into this exact same issue, but with Visual Studio Community Edition 2019.
The solution was to download the Windows 10 SDK using the Visual Studio installer. Once I did that the next compile worked fine.
The header file "crtdbg.h" is part of the Windows 10 SDK kit. I believe you will find crtdbg.h located here C:\Program Files... or C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\crtdbg.h depending on your setup and version.
<crtdbg.h> is a Microsoft Visual C++ specific header. You may be able to work around this problem using a stub similar to the following:
#ifdef _MSC_VER
#include <crtdbg.h>
#else
#define _ASSERT(expr) ((void)0)
#define _ASSERTE(expr) ((void)0)
#endif
Note that this will disable any asserts in the code you are compiling against, and still won't help you if the code you're compiling uses more advanced features inside crtdbg.h, such as memory leak detection. If these features are in use, you will need to compile the code with MSVC++ rather than MinGW.
I ran into this exact same issue, but with Visual Studio Code.
First start/restart VS Installer and install the Win10 SDK.
Then restart your computer and the needed heasers are available.
I am from Go--g-- search here.
After installing Visual Studio 2019 preview(2022 preview), I have faced the same.
Opening Developer Command Prompt and after going to a particular folder,
cl test.cpp gave above error.
Resolve :
After installing Visual Studio 2022 preview or any other version, do reboot the system.
After rebooting, I could successfully, run the cl command, and compiled a test program without any of the above error.
I ran into this problem recently by trying to install LLVM/Visual Studio Code.
The Windows SDK installation is required for the clang compiler.
To install the Windwos SDK open/download the Visual Studio Installer and check the Windows 10 SDK in Desktop in development with C++
If you have the Windows SDK, and still have this error, go to project propreties -> VC++ -> Include Directories. then paste C:\Program Files (x86)\Windows Kits\10\Include(Version)\ucrt
Just note that I got the same error in Visual Studio 2022 installed on Win 10 Version 21H2. Solution was to install latest Windows 10 SDK from here and then restart the computer.
I ran into this problem, I tried updating the SDK through Visual Studio as mentioned above to no avail. One thing I did was used an old PC to download the SDK, transferred the contents via USB. Took the File directory that Visual Studio was looking in, and copied everything over from the downloaded SDK in the USB to that file path/directory as mentioned in Visual Studio.
Hope this helps.