I have an application that uses windows.h but I am tasked with removing the calls to Windows functions.
I am using Visual Studio Express 2010 and when I delete the #include "windows.h" line the code is still able to compile and I can right click and "Go To Definition" for all the variables associate with the windows include file.
I removed $(WindowsSdkDir)include; from the VC++ Directories in the Configuration Properties page but that didn't seem to make a difference. I believed that could be the case because windows.h can be found at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windows.h on my computer.
How do I completely break this link so Visual Studio can give me errors for all calls to that library?
Use the /showIncludes command switch to search for indirect includes of windows.h
http://msdn.microsoft.com/en-us/library/hdkef6tk.aspx
Related
I have a legacy project that used to be build in Visual C++ 2005 Express, and it depends on a certain third party DLL. As far as I can tell it doesn't come with a lib or header file.
The project compiles fine in Visual C++ 2005, here is a screenshot showing the DLL visible and browsable in the object explorer. The code can also use it without #include or anything like that, which is pretty weird.
Importing the project into Visual Studio 2019 works as well, the code can still use the DLL and it is listed under both the dependencies and the references:
I now want to achieve the same thing in a new project, but I cannot figure out how to register the DLL as a dependency. Things I found online and tried:
"Just include the header or lib file" doesn't work, I don't have one
LoadLibrary() and GetProcAddress() are awfully contrived and don't seem necessary because it's clearly possible without.
Create your own lib file doesn't work either, dumpbin doesn't show any symbols for my DLL: image
How do I register the DLL as a dependency? And where does Visual C++ 2005 get the list of methods in the DLL from is the first place?
I am attempting to compile a .cpp file on Visual Studio 2019 Preview 1 and the file windows.h is not present on the system. What do I have to do to make this file available to Visual Studio? The file being compiled contains include <windows.h>.
windows.h usually comes from Windows SDK installation. Like you discovered, some projects might even require a certain version of Windows SDK. Therefore, when such compilation errors happen, the first thing to do is to read carefully the source code documentation, which might indicate what is needed to install in advance.
Visual Studio 2017/2019 become more modular than previous releases, so missing a component is expected, and you can always go back to VS installer to find the suitable components to install.
Pulling out my hair on what should be a simple issue with using VC++ and being unable to access the default includes.
After installing Visual Studio 2015 RC, I can no longer build C/C++ projects. I receive "IntelliSense: cannot open source file '*.h'" errors for all the various standard library *.h files.
I confirmed that my files do exist in the default locations (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include), and if I right-click on my #include <cstdio> line in the editor I can choose "Open Document" and it even opens automatically in the editor.
My Include Directories string in the Project Settings is:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include;C:\Users\Kristopher\Libraries\Includes;$(VC_IncludePath);$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSDK_IncludePath);
Has anyone else run into this? I feel like I'm overlooking something simple.
Your IncludePath should not specify the Visual C++ and Windows SDK include paths directly. Instead, it should specify only the paths specific to your project and derive from the IncludePath defined in the common C++ MSBuild targets. E.g.,
<IncludePath>C:\Users\Kristopher\Libraries\Includes;$(IncludePath)</IncludePath>
To address your particular case: In Visual C++ 2015, the bulk of the C Runtime (CRT) has been refactored into a new Windows operating system component, the Universal CRT. Its headers and libraries are now in a different location and your project fails to include this include path into the IncludePath property. Specifically, you need to include $(UniversalCRT_IncludePath). For more details, see the article I wrote earlier this year, "Introducing the Universal CRT."
according to my another question , suppose that I have a .lib files and I don't know which .lib a specific function belongs to?
Somewhere I studied if I link all of that .libs this will not effect the size of my final project?
Because VC won't install .libs that are not used in the final?
Is it true?
Can you explain me the mechanism that VS uses to link libraries?
Edited section of my question based on #HansPassants comment. How can I see the contents of a .lib file using Dumpbin.exe
I have searched my Visual studio's install folder and found the file:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\dumpbin.exe
But when I double-click on it, I get the error:
Could you learn me how to use dumpbin.exe. e.g. how to introduce a .lib file to this .exe and then extract the contents of it?
Edited section of my question based on #Roger Rowland's comment
I runned dumpbin.exe from Microsoft Visual Studio 2010 command prompt and this is what I have reached for the agg.lib. How can I explore the contents of the .lib. I mean how can I understand a specific method is written in this .lib or in another?
How can I understand which .lib should I link in order not to get error when running a specific method?
Please learn me how to export contents of a .lib
This is what I have done already. The commands that I have entered are:
C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\> D:\JobList\Lib\GDAL_lib\x86\lib\agg.lib\EXPORTS
C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\> D:\JobList\Lib\GDAL_lib\x86\lib\agg.lib/EXPORTS
The screenshot of what I have tried up to now:
I'm trying to compile some code from a Windows API. It says that certain .lib and .h files must be included in the version of the Windows 7 SDK I am using. Visual Studio shows the .h files, but gives linker errors (L2019) when I try to build the project.
How can I check what version of the Win7 SDK I have, and how can I see if it includes the necessary .lib files?
Did you actually tell the linker that it should link the corresponding .lib file? The project templates only link the most popular .lib files, kernel32.lib, user32.lib etc. If you use an "unusual" API function then you must also tell the linker to link the import library.
Project + Properties, Linker, Input, Additional Dependencies. If you don't know what .lib is needed then look in the SDK documentation for the API function. The .lib file is listed at the bottom of the article.
Another thing you can do is use a #pragma in your source code to tell the linker to link with a .lib. For example:
#include <shlwapi.h>
#pragma comment(lib, "shlwapi.lib") // NOTE: need to link this .lib to get shell functions
Possible solution: Go to "C:\Program Files\Microsoft SDKs\Windows" and see if there is a version installed (or if that path exists at all).