Install geos on Visual Studio using VCPKG [duplicate] - c++

I checked out a copy of a C++ application from SourceForge (HoboCopy, if you're curious) and tried to compile it.
Visual Studio tells me that it can't find a particular header file. I found the file in the source tree, but where do I need to put it, so that it will be found when compiling?
Are there special directories?

Visual Studio looks for headers in this order:
In the current source directory.
In the Additional Include Directories in the project properties (Project -> [project name] Properties, under C/C++ | General).
In the Visual Studio C++ Include directories under Tools → Options → Projects and Solutions → VC++ Directories.
In new versions of Visual Studio (2015+) the above option is deprecated and a list of default include directories is available at Project Properties → Configuration → VC++ Directories
In your case, add the directory that the header is to the project properties (Project Properties → Configuration → C/C++ → General → Additional Include Directories).

Actually, on my windows 10 with visual studio 2017 community, the path of the C++ header are:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt
The 1st contains standard C++ headers such as <iostream>, <algorithm>. The 2nd contains old C headers such as <stdio.h>, <string.h>. The version number can be different based on your software.

If the project came with a Visual Studio project file, then that should already be configured to find the headers for you. If not, you'll have to add the include file directory to the project settings by right-clicking the project and selecting Properties, clicking on "C/C++", and adding the directory containing the include files to the "Additional Include Directories" edit box.

There seems to be a bug in Visual Studio 2015 community. For a 64-bit project, the include folder isn't found unless it's in the win32 bit configuration Additional Include Folders list.

There exists a newer question what is hitting the problem better asking How do include paths work in Visual Studio?
There is getting revealed the way to do it in the newer versions of VisualStudio
in the current project only (as the question is set here too) as well as
for every new project as default
The second is the what the answer of Steve Wilkinson above explains, what is, as he supposed himself, not the what Microsoft would recommend.
To say it the shortway here: do it, but do it in the User-Directory at
C:\Users\UserName\AppData\Local\Microsoft\MSBuild\v4.0
in the XML-file
Microsoft.Cpp.Win32.user.props
and/or
Microsoft.Cpp.x64.user.props
and not in the C:\program files - directory, where the unmodified Factory-File of Microsoft is expected to reside.
Then you do it the way as VisualStudio is doing it too and everything is regular.
For more info why to do it alike, see my answer there.

Tried to add this as a comment to Rob Prouse's posting, but the lack of formatting made it unintelligible.
In Visual Studio 2010, the "Tools | Options | Projects and Solutions | VC++ Directories" dialog reports that "VC++ Directories editing in Tools > Options has been deprecated", proposing that you use the rather counter-intuitive Property Manager.
If you really, really want to update the default $(IncludePath), you have to hack the appropriate entry in one of the XML files:
\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets\v100\Microsoft.Cpp.Win32.v100.props
or
\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets\v100\Microsoft.Cpp.X64.v100.props
(Probably not Microsoft-recommended.)

It looks for files in the directory mentioned in options" cwd, you can include all sub directory under a path as shown below.
it will create a single output file.
it will compile all files together in the directory specified in cwd
project Structure:
moduelTest
-header_files
- util.h
-source_files
- util.c
- main.c

Related

How to configure addition library folders for Visual Studio 2013?

I have legacy, non Visual Studio project. Its structure is:
-root_folder
-root_folder/folder1
-root_folder/folder1/main.cpp
-root_folder/folder1/fun.cpp
-root_folder/folder2
-root_folder/folder2/bar.cpp
-root_folder/folder2/foo.h
.... many different folders
I work with project under folder1.
root_folder/folder1/main.cpp:
#include <folder2/foo.h>
....
I have the error: Error can not open source file "folder2/foo.h>".
Of course, I added the folder root_folder in Project -> properties -> c/c++ section -> additional include directories.
I cannot change this source code, so I need right configure project settings.
Also, I have one more problem. Visual studio does not show my folders structure. It just show folder Source Files, which contains all thousands files.
Visual Studio looks in "VC++ Directories" -> "Include Directories" for the include files specified in angle brackets.
You need to add you path there:
https://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&k=k%28VS.ToolsOptionsPages.Projects.VCDirectories%29&rd=true
P.S. Just noticed that this answer was given earlier, and rejected.
However, it most certainly works; tested with VS2013.

LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'

I'm a novice C++ developer. I encontered the error message indicates "LINK :fatal error LNK1104: cannot open file 'MSVCRTD.lib'" while I'm trying to debug every single project in Microsoft Visual C++ 2010 Express. I searched on Stack overflow and Google for any possible resolution, but I couldn't find exact and precise answer. What I have understood is that the "msvcrtd.lib" file should be in "\Microsoft Visual Studio 10.0\VC\lib", but that file is not there in my case. What should I do?
For the poor souls out there who are struggling with this, after an hour of research I found a solution for my Visual Studio Enterprise 2017:
First, lets find where is your library file located:
With windows explorer, go to your directory where Visual Studio is installed, (default: C:\Program Files (x86)\Microsoft Visual Studio) and do a search for msvcrtd.lib
I found mine to be in here:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.15.26726\lib\onecore\x86
Quick Fix (for one project only):
Right click on your project, click on properties, navigate to Linker, add that path to Additional Library Directories
Permanent Fix (for all projects)
Open a project
navigate to View > Property Manager (it could be under Other Windows)
Expand all folders and multi select all "Microsoft.cpp.Win32.user" & "Microsoft.cpp.64.user"
Right click and go to properties
Navigate to VC++ Directories
Add the path to default Library Directories
Go to your project properties, select Linker from left. Add this to "Additional Library Directories":
"(Your Visual Studio Path)\VC\lib"
For example:
C:\Program Files\Microsoft Visual Studio 10.0\VC\lib
I came across this problem when compiling a sample app using VS2017
Hope this will help
There is a check box that says "Inherit from parent or project defaults" in some of the property dialogs in Project Properties. Make sure that check box is checked for your Include and Library directories property windows and of course for your Additional Dependencies window.
If you use VS2017, please read it. Or just ignore this answer...It may be invalid for other VS version.
Do not trust anyone who told you to add lib path.
Here's suggestions:
[BEST] You just need to install these via VS_installer (most of us just need x86/x64 version below)
VC++ 2017 version version_numbers Libs for Spectre [(x86 and x64) | (ARM) | (ARM64)]
Visual C++ ATL for [(x86/x64) | ARM | ARM64] with Spectre Mitigations
Visual C++ MFC for [x86/x64 | ARM | ARM64] with Spectre Mitigations
[NAIVE] or disable Spectre Option for every Solution
(Why We are so hard to global disable it)
[LAUGH] Or never use VS2017
This is VisualStudioTeam's fault and Microsoft is guilty.
Why?
You can't make a global configuration to disable /QSpectre, and IDK when and why VS2017 enable it in one day. So the best way is install Spectre? ahhha?
For VS 2019, Spectre Mitigation is enabled by default.
So the right way to fix the issue would be to install VC++ Libs for Spectre.
But, to quickly resolve the issue, you may disable Spectre Mitigation
Project Properties -> C/C++ -> Code Generation -> Spectre Mitigation -> Disabled
https://devblogs.microsoft.com/cppblog/spectre-mitigations-in-msvc/
I ran into this issue. The file existed on my machine, it was in the search path. I was stumped as the error result is really unhelpful. In my case I had turned on Spectre mitigation, but had not downloaded the runtime libs for Spectre. Once I did the download all was right with the world. I had to get this installed on my CI build servers also, as these libs are not installed with VS by default.
I have solved this problem, you need install all spectre lib.
Vistual Studio Installer->Modify->Component->Any spectre lib.
This solution can be adapted to any project.
For me this issue happens after installing the (Windows Driver Kit): https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
Uninstalling it fixes the problem. Just posting here as a related issue for people looking for solutions: After installing WDK VC++ is broken
Scenario:
Windows 10 with Visual Studio 2017 (FRESH installation).
'C' project (LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib').
Resolve:
Run 'Visual Studio Installer'.
Click button 'Modify'.
Select 'Desktop development with C++'.
From "Installation details"(usually on the right-sidebar) select:
4.1. VC++ 2015.3 v14.00(v140) toolset for desktop.
Version of 'toolset' in 4.1. is just for example.
Click button 'Modify', to apply changes.
Right-click 'SomeProject' -> 'Properties' ->
'Linker' ->
'General' ->
'Additional Library Directories': $(VCToolsInstallDir)\lib\x86
(!!! for x64 project: 'Additional Library Directories': $(VCToolsInstallDir)\lib\x64 !!!)
it is also worth checking that MSVCRTD.lib file is present in "C:\Program Files\Microsoft Visual Studio 10.0\VC\lib" for x64 and in C:\Program Files(x86)\Microsoft Visual Studio 10.0\VC\lib for 32 bit. Sometimes VS might not be installed properly OR these files might get deleted accidentally.
I just had this error, in my case rebuilding the project while doing nothing else worked for me.
Here's my situation
Visual studio crashed and I had to re-install and my new installation path is different than the previous one. then I had this error
the error showed that the library is located at
D:\program\Microsoft Visual Studio\...
while it should be
D:\program files\Microsoft Visual Studio\...
as I said I just rebuilt it and it worked for me and if you have a multi-solution project you have to rebuild the whole-solution
I solved the problem by adding #using <mscorlib.dll> in the main file
This indicates that Visual Studio wasn't able to find the lib (Library) directory which contains msvcrtd.lib.
IMPORTANT: This lib directory also contains linkers required during the compilation process.
So, all you need to do is override the Library Directory location. You can do so with the help of Environment Variables.
I referred to this StackOverflow Post for help. As per the answer posted, the Environment Variable LIB refers to the path where the Linker Libraries are located. Why is this method better? Because this will apply to all the projects instead of just a particular project. Also, you don't need to download anything extra. It just works...
Follow the steps below to achieve this:
STEP-1: Search for "msvcrtd.lib" in the search bar.
STEP-2: Click "Open File Location" (available in context menu)
STEP-3: Copy the address of the directory from the address bar.
STEP-4: Search "Environment" in the taskbar and click on "Edit the system environment variables".
STEP-5: Click on "Environment Variables..." button.
STEP-6: Under "System variables" section, click on "New..." button. A dialog would pop up.
STEP-7: In the dialog box, enter the following:
Variable name: LIB
Variable value: [The directory you copied in "STEP-3"]
And press "OK"
Now, you are all done!
The above answer was not quite accurate for me. I have VS2010 Ultimate installed and the file in question is not in my Visual Studio 10.0\VC folder. Rather I found it in the Visual Studio 9.0\VC folder. So if that's the case for anyone, follow the lead to change the Linker but use the Visual Studio 9.0\VC folder instead. It worked for me.
For Visual Studio 2017
Go to your project properties, select Linker from left. Add this to "Additional Library Directories":
C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\lib
I got a slightly different error
LNK1104 cannot open file 'MSVCURTD.lib'
Note it is msvcUrtd (not msvcrtd), but the file is not found on my system.
Solved it by setting the following options:
Project Properties
General
Character Set: Not Set
Common Language Runtime Support: Common Language Runtime Support (/clr)
Hope that helps.
In VS2017 (Community/Enterprise/Ultimate/Professional):
Add the path(s) of the folder(s) which include your desired ".lib" file(s) in the following path in VS:
(Right Click)Project(in Solution Explorer)->Properties->Configuration Properties->Linker->General->Additional Library Directories
If there are more than one ".lib" file use ';' to separate them otherwise click on the edit box corresponds to "Additional Library Directories" then click on "" in drop down menu and add all desired ".lib" files in newly opened window one by one and in a easy to handle manner.
I ran into this using Visual Studio 2017. I tried the solutions suggested here with explicitly adding paths to where the 'MSVCRT.lib' file was located. But I felt this probably wasn't the correct approach because previously for the past several weeks this had not been a problem with my project.
After trial and error, I discovered that if I left an empty or blank value in the Linker --> Input section, it would give me the error about LNK1104: cannot open file 'MSVCRT.lib'. Eventually I figured out that I should leave this value there instead.
On the Visual Studio project, right-Clicking on the project item in the Solution explorer panel (not the Solution itself, which is the topmost item), then select Properties. From there do the following:
Linker --> Input : %(AdditionalDependencies)
This additional information might be helpful, if you got into the situation the same way I did. I have discovered that I should not put any non-system library paths in the Linker --> Input section. With my project I was trying to compile with external .lib files. Previously I had a value in this input section like: $(ProjectDir)lib; %(AdditionalDependencies) but this lead to other problems. I discovered the correct place (it seems so far) to put paths for referencing external .lib files in a C/C++ project in Visual Studio 2017 is here:
VC++ Directories --> Library Directories : $(ProjectDir)lib; $(LibraryPath)
Note the $(LibraryPath) value will include extra values such as inherited from parents. My folder project contained a folder called 'lib' which is why I had the first value there before the semicolon.
I have included the following path
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x86
and
C:\local\boost_1_64_0\lib64-msvc-14.1
To
project properties-> linker-> Additional Directories
Click here : Image shows linking of boost and MSVC2017

C++: How to add a library in Netbeans (DarkGDK + DirectX SDK)

I'm trying to learn how to make games with DarkGDK. But I have to write in Visual Studio.
I don't like Visual Studio. Its suggestions (Ctrl-Space for Completion) are bad (in my opinion) and the compiler is broken (See my previous questions).
So I want to migrate to Netbeans, with MSys and MinGW. But I'm not able to use the DarkGDK
library in Netbeans. I added two include folders:
C:\Program Files\The Game Creators\Dark GDK\Include
C:\Program Files\Microsoft DirectX SDK (August 2007)\Include
After adding this include directories, I can #include <DarkGDK.h>.
But he shows a warning: "There are unresolved includes inside <DarkGDK.h>"
And when I try to compile: main.cpp:9:21: warning: DarkGDK.h: No such file or directory
In Visual Studio are Include files and Library files. And in Netbeans, there is only Include Directories when I go to Tools -> Options -> C/C++ -> Code Assistance.
So, my question is: "How can I add the Library files in Netbeans"?
Or does any-one did this yet and knows how to do this.
Personally I found the include directories in Tools -> Options don't work. You need to right click on your project and go to properties -> C++ Compiler and add your include directories. Then from properties -> Linker to add your library directories and libraries.

What is the diff b/w Includes in VC++ Directories options and Additional include directories in C++ -> General in Visual Studio

I tried adding the include directories in the VC++ Directories -> Include Directories option in Tools -> Options but when compiling I get error - "Can't find file or directory" . Once I add to the Project properties -> Configuration properties -> C++ -> General -> Additional include directories , I could compile successfully.
So why does Visual Studio have a Include Directories option. Why is it used for ?
(I'm using Visual studio 2010 Beta 1 )
Visual Studio team recently explained differences of VS 2010 regarding include directories to earlier versions in their blog.
You should find your answer here: http://blogs.msdn.com/vsproject/archive/2009/07/07/vc-directories.aspx
Include directory under tools is common for all projects. This is where your includes for the Windows SDK is listed which is almost used by all the projects. The include directory under C++ tab is specific to that project. This is where you list all your custom project include files.
I think you mean "VC++ Directories" in Tools->Options->Projects.
The directories listed here are visible in the entire VS environment (common to all projects). That is it consists of the path to use when searching for executable files while building a VC++ project.
So ,
you cannot specify paths relative to
the location of project files. One
should avoid this option IMHO.
Listing the paths in project setting
also makes it more configurable as
these directiories are considered
when compiling through command-line
also. Most major projects have
automated builds through command-line,
so they would fail to build if the
directories are not listed in the
project properties.
http://msdn.microsoft.com/en-us/library/t8096eby(VS.100).aspx
Please refer to this document.

Where does Visual Studio look for C++ header files?

I checked out a copy of a C++ application from SourceForge (HoboCopy, if you're curious) and tried to compile it.
Visual Studio tells me that it can't find a particular header file. I found the file in the source tree, but where do I need to put it, so that it will be found when compiling?
Are there special directories?
Visual Studio looks for headers in this order:
In the current source directory.
In the Additional Include Directories in the project properties (Project -> [project name] Properties, under C/C++ | General).
In the Visual Studio C++ Include directories under Tools → Options → Projects and Solutions → VC++ Directories.
In new versions of Visual Studio (2015+) the above option is deprecated and a list of default include directories is available at Project Properties → Configuration → VC++ Directories
In your case, add the directory that the header is to the project properties (Project Properties → Configuration → C/C++ → General → Additional Include Directories).
Actually, on my windows 10 with visual studio 2017 community, the path of the C++ header are:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt
The 1st contains standard C++ headers such as <iostream>, <algorithm>. The 2nd contains old C headers such as <stdio.h>, <string.h>. The version number can be different based on your software.
If the project came with a Visual Studio project file, then that should already be configured to find the headers for you. If not, you'll have to add the include file directory to the project settings by right-clicking the project and selecting Properties, clicking on "C/C++", and adding the directory containing the include files to the "Additional Include Directories" edit box.
There seems to be a bug in Visual Studio 2015 community. For a 64-bit project, the include folder isn't found unless it's in the win32 bit configuration Additional Include Folders list.
There exists a newer question what is hitting the problem better asking How do include paths work in Visual Studio?
There is getting revealed the way to do it in the newer versions of VisualStudio
in the current project only (as the question is set here too) as well as
for every new project as default
The second is the what the answer of Steve Wilkinson above explains, what is, as he supposed himself, not the what Microsoft would recommend.
To say it the shortway here: do it, but do it in the User-Directory at
C:\Users\UserName\AppData\Local\Microsoft\MSBuild\v4.0
in the XML-file
Microsoft.Cpp.Win32.user.props
and/or
Microsoft.Cpp.x64.user.props
and not in the C:\program files - directory, where the unmodified Factory-File of Microsoft is expected to reside.
Then you do it the way as VisualStudio is doing it too and everything is regular.
For more info why to do it alike, see my answer there.
Tried to add this as a comment to Rob Prouse's posting, but the lack of formatting made it unintelligible.
In Visual Studio 2010, the "Tools | Options | Projects and Solutions | VC++ Directories" dialog reports that "VC++ Directories editing in Tools > Options has been deprecated", proposing that you use the rather counter-intuitive Property Manager.
If you really, really want to update the default $(IncludePath), you have to hack the appropriate entry in one of the XML files:
\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\PlatformToolsets\v100\Microsoft.Cpp.Win32.v100.props
or
\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\PlatformToolsets\v100\Microsoft.Cpp.X64.v100.props
(Probably not Microsoft-recommended.)
It looks for files in the directory mentioned in options" cwd, you can include all sub directory under a path as shown below.
it will create a single output file.
it will compile all files together in the directory specified in cwd
project Structure:
moduelTest
-header_files
- util.h
-source_files
- util.c
- main.c