Visual Studio 2013 not using include path - visual-studio

I have a simple empty Visual Studio 2013 C/C++ project to which added two files:
MyCode.cpp
MyCode.h
Inside MyCode.cpp, I have as the first line,
#include "mex.h"
mex.h is a MATLAB file located in C:\Program Files\MATLAB\MATLAB Compiler Runtime\v717\extern\include
I have gone to Project Properties -> C/C++ -> General and added "C:\Program Files\MATLAB\MATLAB Compiler Runtime\v717\extern\include" to my "Additional Include Directories".
And yet, VS never finds the file!
File 'mex.h' not found in current source file's directory or in build system paths.
It seems that the build system paths are not being updated with my additional include path.
I've tried using relative paths as well, deleting the .sdf file, and closing/reopening Visual Studio. It simply won't add the path.
For reference, this works fine in Visual Studio 2010.
Help!

Related

External/Additional include and source directories in Visual Studio 2022

In order to use external code (QGeoView in this case) I copied the demo code (main.cpp, mainwindow.cpp, the .ui file, etc.) into my Visual Studio project root alongside the QGeoView lib directory.
This alone left me with compiler errors like "Cannot open include file: 'QGeoVies/QGVMap.h'" which I resolved by adding the lib/include directory to the 'Additional Include Directories' in the C/C++ -> General menu in the project properties.
Now I obviously get linker errors since the source files that belong to the just added headers aren't compiled yet.
Where exactly can I add the additional source directory (project root/lib/source in my case) for Visual Studio to find and compile the source files?

How to properly update visual studio sources files/directories

My cpps and headers files were messy on visual studio, then I organized it manually on the directories.
The problem is visual studio still trying to compile over the old files names and directories that I have already changed, I'm getting a lot of
C1083: No such file or directory and
MSB8027: Two or more files with the name of ...
But I deleted them and I want to visual studio recognizes it.
What should I do?
Thanks

PVS Studio not working with MSVS not installed in default location

Due to disk size constraints, I installed MSVS 2017 to D:\Program Files\Visual Studio.
I then installed PVS-Studio v6.14. When I tried to run it, I get the following error messages:
Error was encountered while opening project 'MIDI2LR.vcxproj'. 0
Exception message: 0
Could not find a part of the path 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC'. 0
It also appears that PVS-Studio did install its extensions into the D:\Program Files\Visual Studio\Common7\IDE\Extensions\3ci0fu2p.p0x directory, so it appears that the installer found the executable.
How do I point PVS-Studio to the correct directories?
If I have understood correctly, we are talking about /Builds/VisualStudio2017/MIDI2LR.vcxproj from your repository (develop branch). If you're talking about another project, please specify it. The information is based on the analysis of the project I mentioned before.
Does this project compile on your machine? If a project does not compile, PVS-Studio does not guarantee the analysis. Otherwise, the analysis should be performed correctly. I also note that for the compilation you have to have the components Visual C++ Build Tools 2015 installed (in this context we use the contents of the directory C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC).
In this case, such behavior occurs because of your project's file structure – the PlatformToolset property is set with a value v140 before the import of Microsoft.Cpp.Default.props, thus this import is performed based on this toolset. This causes MSBuild to use the compiler from Visual C++ 2015, and not from Visual C++ 2017.
To compile using the compiler from VS2017 (V141 toolset), you need to modify the project file (see example of a console application project file that is created in Visual Studio 2017). Then the compilation should be done with a correct compiler and the analysis with PVS-Studio performed correctly.

can't build old VS2010 project with VS2013. (build tool for VS2010 cannot be found.)

I have installed VS2013 on my computer about 2 years ago(and removed VS2010 I guess) and today I tried to open my old VS2010 project (MV1.sln) that I used to work with about 5 years ago.
When I tried to open it, it just says "more than one project in the solution was not loaded correctly. refer to the output window"(translated from Korean). The output window says
D:\My_Path\MV1\MV1.vcxproj : error : can't read project file "MV1.vcxproj"
D:\My_Path\MV1\MV1.vcxproj(34,5): can't find imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\CUDA 4.0.props". Check if the path specified in <import> declaration is correct and file exists in the disk.
So I checked the MV1.vcxproj file's line 34 which reads
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 4.0.props" />
which seems to be correct path because the value $(VCTargetsPath) is being used before line 34 in the same file and I can easily guess it points to C:\Program Files (x86)\MSBuild (I can see Microsoft.Cpp.props folder and BuildCustomizations\CUDA 4.0.props file referred to in the .vcxproj file)
I had CUDA4.0.props file which specifies include path and library path for CUDA4.0 under C:\Program Files (x86)\Microsoft Visual Studio 10.0 (I kept those files there at that time) but copied it to the location specified in vcxproj file to make it appear there.
I found some similar questions and answers but they seem to be different from my case. What can be the most correct method other than making a new project and copying and specifying everything one-by-one?
I found the file name should have a space in 'CUDA 4.0.props' so I changed the file name(MSBuild/Microsoft.Cpp/V120/BuildCustomizations/CUDA 4.0.targets) , then it complained about CUDA 4.0.targets file missing, so I copied MSBuild/Microsoft.Cpp/v4.0/BuildCustomizations/CUDA 4.0.targets (it was there since 5 years ago) to MSBuild/Microsoft.Cpp/v4.0/V120/BuildCustomizations/CUDA 4.0.targets. Now I can see the files in the project browser but when I build the project, it says
error MSB8020: The build tools for Visual Studio 2010 (Platform
Toolset = 'v100') cannot be found. To build using the v100 build
tools, please install Visual Studio 2010 build tools. Alternatively,
you may upgrade to the current Visual Studio tools by selecting the
Project menu or right-click the solution, and then selecting "Upgrade
Solution...". C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets 64 5 MV1
But in my VS2013 I don't see such "Upgrade Solution" or upgrade menu. So I looked for method to change the toolset and found
Visual Studio 2013 error MS8020 Build tools v140 cannot be found and seleted VS2013 and it tries to build now.
(though I have fix some errors cannot link external symbol _CUDAInit.. etc.)

How to include <cuda_runtime.h> in .cpp file

I have problem to include <cuda_runtime.h> in .cpp file. Error: Cannot include file: cuda_runtime.h: No such file or directory.
I am trying to complie code from Rob Farber ( http://www.drdobbs.com/architecture-and-design/222600097?pgno=1 ).
I have compiled few cuda codes before but <cuda_runtime.h> was allways included in .cu file.
I am using VS 2008 Express.
Q: Do I have to link VS somehow different so it knows where to look for <cuda_runtime.h>?
In Visual Studio 2008, add the path of the include files in Visual C++ directories.
"Installation Path"\NVIDIA GPU Computing Toolkit\CUDA\"version"\include\
Here is the procedure:
In Visual Studio 2008, go to
- Tools -> Options -> Projects And Solutions -> Visual C++ Directories.
- Select include files from the drop down list named "Show Directories For".
- Add new item by clicking the yellow button below the drop down list.
- Paste the include fles path here.
- Verify the correctness of path by clicking the check button on left of yellow button
- Click ok and restart visual studio.
Now Visual Studio 2008 will know where the include file is located.
Instead of setting up a hard-coded path - which you will most likely have when locating CUDA installation on your machine - you can also add cudart.lib as additional dependency for the linker.
Right click on the project > Properties > Linker > Input > Additional Dependencies. Add cudart.lib there.

Resources