Including Text Files in Build of Visual Studio 2013 Solution - visual-studio

I want a text file to be included in the build, so I used Add->Existing Item to load it into the solution. However, I can't open it in a ifstream unless I use an absolute path to the original file. I set Excluded from Build to No and Item Type to Text. For a relative path to file.txt, I tried "file.txt", "../file.txt", "/file.txt" but none of them work. I don't know if it's my syntax that's wrong, or if it's just not included in the build, or both.
The program is in C++.
I came across some old answers that mentioned an option to specify additional directories in the build, but I don't see it in Visual Studio 2013.

Related

How to rename build output file in Visual Studio 2019

So I just made some c++ application, using NotificationIcon sample from Microsoft as a reference, and thus I'm stuck with the NotificationIcon.exe output file. The name is really lame and I'd like to change it. I've tried renaming the exe, renaming the solution, the project - whatever else - and my programm just exited with code 0x00 after building. What else should I try?
I tried to do the same thing, but there were a few steps I had to follow in VS2019 just to get set up. If you are not in a similar state, the rest of the answer might not apply.
Downloading the sample: I had to install the Windows 7 SDK, as the download page didn't seem to exist anymore. I'm not sure if you found it elsewhere, in which case you might be starting from different sources.
Converting the .vcproj file to .vcxproj. Visual Studio no longer supports .vcproj, and opening the solution triggered this conversion automatically.
Now, once I have a .vcxproj file, there are two routes to setting the name of the exe:
Right-click the project in VS, click Properties, and find the Target Name field. This defaults to $(ProjectName) so I would have expected that renaming the .vcxproj would have renamed the .exe file.
Edit the .vcxproj file directly, adding <TargetName>Foo</TargetName> into the section that starts with <PropertyGroup Label="Globals">

Where can I find the complete schemas for Visual Studio 2005 and 2008 project files?

The only thing I could find so far were those two pages
http://msdn.microsoft.com/en-US/library/y4sy8216(v=vs.80).aspx
http://msdn.microsoft.com/en-US/library/y4sy8216(v=vs.90).aspx
Along with the respective "descriptions".
However, they are far from complete as is evidenced by the missing descriptions for elements underneath the Tool element.
So then I found the descriptions for VCProjectEngine in the VS installation folder:
C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.VCProjectEngine.xml
but it's unclear whether the names of the object properties is a 1:1 mapping to those inside the resulting .vcproj file?
Things appear to be a little more straightforward for newer VS versions (MSBuild based), but not completely.
There are none that describe the whole project file. The thing is that many tags work by convention, many tasks can be declared and named inline by simply calling out to the task assembly.
So even though for the basic structure a XSD exists, there is none that describes every possible way a project file can be setup not can you validate the project file without loading the tasks and have them validate their own snippets.

Including an external library in Visual Studio 2010 project

I'm new to visual studio and can't seem to find an answer to this anywhere.
I'm working on a project in VC++ with VS2010. I have another project that builds into a .lib file set up as a reference, but can't figure out how to actually include the headers. Google has proved useless. Please help!
Generally this is done by adding the directory where the include files live to the project's "Additional Include Directories" property (in the "C/C++ | General" property page).
Note that the location can be a relative path if the different projects will always be at the same file system level relative to one another, or they can use VS macros or environment variables.

Using Boost and Visual Studio

I did see some similar questions about this - but I couldn't piece together what I needed.
I'm using boost in a project in Visual Studio 9, and I'm unable to get it to recognize all the header files that I'm trying to include. I'd installed Boost using the Windows installer that also places the binaries on my machine.
In Visual Studio, I modified the Project->Properties->Linker->Additional Libarary Dependencies to include the folder "mypath\boost_1.44\lib", which contains the binaries - but I still can't get VS to recognize my Boost header files. Please help!
Cheers.
edited to clarify some text
You need to modify the project properties to add header locations for the boost headers as well. If you want a global setting, this is how you do it:
Tool->Options->Projects and Settings->VC++ Directories. Then on the right hand side, Open the dropbox labeled "Show Directories For" and pick "Include Files".
Add a new line for your boost header path.
This is a screenshot from VS2008 - it is similar in VS2010 and VS2005.
Additionally, you can also set these directories on a per-project basis by modifying each project's specific properties.

How can I get the exact compiler command line from visual studio?

I have to port the build of a DLL from building in Visual Studio to another build system. The DLL solution wasn't made by me and it's got lots of modified command line switches etc. I've copied the compiler/linker options from Visual Studio's
Project Properties -> Config Properties -> C/C++ -> Command Line
Project Properties -> Config Properties -> Linker -> Command Line
However, when I build the DLL from my other build tool (and I've also tried a simple batch file) the DLL is a slightly different size and causes a crash sometimes when the DLL is used (which the one built by vis studio doesn't do).
So my question is:
Is there a better way to see the exact command line than what's in vis studio properties page?
Does Vis Studio do any crazy magic beyond what's happening on the command line (I hope the answer to this is no!) :-)
Something to keep in mind is that command-line options can be set per-source file too, not just per-project, which may be what you're missing.
One way to see everything that's going on is to look at the build log. At the end of the build in the Output view, you should see a line like:
Build log was saved at "file path".
Ctrl-click the file path in the output view and it will load the log file, and you should see all of the command lines for each file.
Update:
This answer was for Visual Studio 2008. You no longer get the link in the output window in newer versions of Visual Studio. Instead you have to navigate to the build directory for your project to see the log file. See here:
https://msdn.microsoft.com/en-us/library/jj651643.aspx
Actually that link is slightly wrong. The log file has a .log extension rather than .txt.

Resources