I'm rather unfamiliar with programming tools in Windows but have been forced to use VC++ 2010 Express for a project recently. We have been working on a piece of software that we didn't start and now we are reaching the finish line. Only problem is that I want to be able to set the executable icon.
Since the project is written mostly in SDL we have set the titlebar icon using the SDL_WM_SetIcon call as recommende on several sites but I still can't find any references to how to set the executable icon. All my google searches has turned up results about Visual Studio 2010 and Visual C++ 2008, neither of which seems appicable.
Since VC++ 2010 Express lacks resource editor but not resource compiler this can be done by manually creating a resource.rc file in the project directory (same as where your .vcxproj files are located), also drop in your .ico version of your icon in the same directory.
In resource.rc add the following line:
IDI_APP ICON "icon.ico"
And add the file, in VC++, to the Resource Files.
Doing this in VC++ should result in something like this to be added to your .vcxproj:
<ItemGroup>
<ResourceCompile Include="resource.rc" />
</ItemGroup>
And to your vcxproj.filters:
<ItemGroup>
<ResourceCompile Include="resource.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
I ran into a similar situation recently with the Express edition.
I came up with a different way to approach this (see gif).
Posting it here in case someone runs into similar problem.
Related
The following dialog prompts me to upgrade the platform toolset and Windows SDK version of files generated for VS2017 when opening it in VS2019:
How can I suppress this and have the action being taken to be No Upgrade?
After all I can still opt to do that later on via the context menu when right clicking a project in the Solution Explorer:
devenv.com from Visual Studio 2019 has:
/Upgrade Upgrades the project or the solution and all projects in it.
A backup of these files will be created as appropriate. Please
see Help on 'Visual Studio Conversion Wizard' for more
information on the backup process.
... what I'd like is essentially the opposite, though. And I'd also like for that setting to persist.
Note: while the screenshots were taken with Visual Studio 2019, earlier Visual Studio versions (notably since 2012) show this behavior as these appear to be the ones to support multiple platform toolsets and Windows SDKs in parallel. Therefore I am also tagging visual-studio.
Searching the options I came up emptyhanded when looking for:
action
retarget
target
upgrade
sdk
platform
toolset
You can suppress this dialog per-project by editing the project file, ProjectName.vcxproj.
It is an XML file. You can edit it with any text editor. Inside the <Project> tag, add the following lines:
<PropertyGroup Label="Globals">
<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
</PropertyGroup>
Source: https://learn.microsoft.com/visualstudio/extensibility/visual-cpp-project-extensibility#disable-project-upgrade
Hi have a problem with VisualStudio 2010 and the QT5 plugin, it seems that VisualStudio doesnt recognize the QT Library (despite i have installed the plugin and followed the whole procedure).
This is what I see:
https://www.dropbox.com/s/yyzvfev0zoj8x9n/visualstrudel.jpg
So the IDE highlights the QT stuff like if the files were not present, and Intellisense is not working. But, If I compile the application, it compiles without error and works like a charm.
What could be the cause of the highlight/Intellisense issue?
You cannot launch Visual Studio 2010 directly.
You will need to launch the QT 5.0.1 for Desktop(MSVC 2010) command line from Program Files->Qt 5.0.1->5.0.1
After which you will need to run the vcvarsall.bat and devenv after.
x:\program files(x86)\Microsoft Visual Studio 10.0.\VC\vcvarsall.bat
x:\program files(x86)\Microsoft Visual Studio 10.0.\Common7\IDE\devenv.exe
This is applicable to VS2012 and Qt4.5.0, though I believe Qt version does not matter.
I am not sure if it is the same/similar to VS2010, but I stumbled upon this post while looking the answer to the same question for VS2012.
Here is what you can do:
Right-click the project in your solution and select Properties.
Select Configuration Properties -> VC++ Directories.
Edit Include Directories entry.
Add $(QTDIR)\include\QtCore and any other (required by your project) Qt folders to the list (it depends what Qt headers you are using).
This has to be done to every project in your solution that uses Qt, unfortunately.
Now, there is another note:
We were transferring our solution from VS2005 to VS2012 and that problem happened to me when I converted the solution 2005->2012 BEFORE setting the QTDIR environment variable.
When I re-converted the solution again (AFTER *QTDIR* variable was created) the problem didn't appear. So make sure you have this variable before you open/convert your solution for the first time.
Based on the previous note, I believe that some information related to the issue is stored in one of the following files: .sdf and/or .v11.suo.
So closing VS, deleting these files and opening VS again might help. Just back them up before you do it - I haven't tried it myself (I just re-imported the whole solution which generated these files anew).
I've added a new build target to my C++ Visual Studio project (vcxproj).
This target runs a custom tool when the project is built. The tool processes specific files on the solution according to the ContentType and ItemType I specified.
This works well with project actions such as "Build" and "Clean".
Now I would like to support an action equivalent to "compile", i.e. right click on a file in the Solution Explorer and select to process this specific file with my custom tool (the same way "compile" runs "CL" for "C/C++ Code" file types).
I know I could add a Visual Studio macro to do this. This is not a good solution for me because it's harder to deploy for many users.
A better solution is to customize the vcxproj (or files imported by it).
I wonder if it's possible to add a "compile" like action in the menu (or change the "compile" behavior for file types other than "C/C++ Code") through msbuild targets scripts or PropertyPageSchema.
UPDATE: I've started a discussion on MSDN forum. Got some answers from a Microsoft moderator that helped clearing up some things, but the problem is still unsolved.
UPDATE (2016), for VS2015
AvailableItemName seems to solve this on VS2015. For example, I have a custom target to process Excel files.
On the targets file:
<ItemGroup>
<PropertyPageSchema Include="$(SolutionDir)\ExcelOptions.xml" />
</ItemGroup>
<ItemGroup>
<AvailableItemName Include="Excel">
<Targets>ProcessExcel</Targets>
</AvailableItemName>
</ItemGroup>
On the options file:
<FileExtension Name=".xls" ContentType="Excel"/>
<ContentType Name="Excel" DisplayName="Excel File" ItemType="Excel"/>
<ItemType Name="Excel" DisplayName="Excel File"/>
Now Compile is accessible on the Solution Explorer context menu after selecting an excel file, and CTRL-F7 works as well (for files that can be edited on VS, not for excel files)
Visual Studio drives me crazy and I am suspecting I am doing something wrong.
This is what I do: I installed Visual Studio (Pro '08) a long time ago, I installed the Windows SDK (Win 7 x64), someone emails me a project, it fails to build.
Invariably, it can not find windows.h. While it is easy enough to include C:\Program Files\Microsoft SDKs\Windows\v7.0\Include in the project settings of every single project, I feel that this may not be the proper way to do it. Is there a way to somehow make Visual Studio globally aware of these files?
I also tried to include the above directory in the path variable but that didn't change anything.
Also, it will randomly find windows.h but not winresrc.h in the same directory.
Edit:
It was a problem with my machine. Somehow, Visual Studio thought that my Windows SDK was in the wrong place. See accepted answer and comments for the fix.
#RichieHindle solution is now deprecated as of Visual Studio 2012. As the VS studio prompt now states:
VC++ Directories are now available as a user property sheet that is added by default to all projects.
To set an include path you now must right-click a project and go to:
Properties/VC++ Directories/General/Include Directories
Screenshot:
This answer only applies to ancient versions of Visual Studio - see the more recent answers for modern versions.
You can set Visual Studio's global include path here:
Tools / Options / Projects and Solutions / VC++ Directories / Include files
To resume the working solutions in VisualStudio 2013 and 2015 too:
Add an include-path to the current project only
In Solution Explorer (a palette-window of the VisualStudio-mainwindow), open the shortcut menu for the project and choose Properties, and then in the left pane of the Property Pages dialog box, expand Configuration Properties and select VC++ Directories.
Additional include- or lib-paths are specifyable there.
Its the what Stackunderflow and user1741137 say in the answers above.
Its the what Microsoft explains in MSDN too.
Add an include-path to every new project automatically
Its the question, what Jay Elston is asking in a comment above and what is a very obvious and burning question in my eyes, what seems to be nonanswered here yet.
There exist regular ways to do it in VisualStudio (see CurlyBrace.com), what in my experience are not working properly. In the sense, that it works only once, and thereafter, it is no more expandable and nomore removable.
The approach of Steve Wilkinson in another close related thread of StackOverflow, editing the Microsoft-Factory-XML-file in the ‘program files’ - directory is probably a risky hack, as it isnt expected by Microsoft to meet there something foreign. The effect is potentally unpredictable. Well, I like rather to judge it risky not much, but anyway the best way to make VisualStudio work incomprehensible at least for someone else.
The what is working fine compared to, is the editing the corresponding User-XML-file:
C:\Users\UserName\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props
or/and
C:\Users\UserName\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.x64.user.props
For example:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<IncludePath>C:\any-name\include;$(IncludePath)</IncludePath>
<LibraryPath>C:\any-name\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup />
<ItemGroup />
</Project>
Where the directory ‘C:\any-name\include’ will get prepended to the present include-path and the directory ‘C:\any-name\lib’ to the library-path. Here, we can edit it ago in an extending and removing sense and remove it all, removing thewhole content of the tag .
Its the what makes VisualStudio itself, doing it in the regular way what CurlyBrace describes. As said, it isnt editable in the CurlyBrace-way thereafter nomore, but in the XML-editing-way it is.
For more insight, see Brian Tyler#MSDN-Blog 2009, what is admittedly not very fresh, but always the what Microsoft is linking to.
If you are only trying to change the include paths for a project and not for all solutions
then in Visual Studio 2008 do this:
Right-click on the name of the project in the Solution Navigator. From the popup menu select Properties. In the property pages dialog select Configuration Properties->C/C++/General. Click in the text box next to the "Additional Include Files" label and browse for the appropriate directory. Select OK.
What annoys me is that some of the answers to the original question asked do not apply to the version of Visual Studio that was mentioned.
To use Windows SDK successfully you need not only make include files available to your projects but also library files and executables (tools).
To set all these directories you should use WinSDK Configuration Tool.
This answer will be useful for those who use a non-standard IDE (i.e. Qt Creator).
There are at least two non-intrusive ways to pass additional include paths to Visual Studio's cl.exe via environment variables:
Set INCLUDE environment variable to ;-separated list of all include paths. It overrides all includes, inclusive standard library ones. Not recommended.
Set CL environment variable to the following value: /I C:\Lib\VulkanMemoryAllocator\src /I C:\Lib\gli /I C:\Lib\gli\external, where each argument of /I key is additional include path.
I successfully use the last one.
You need to make sure and have the following:
#include <windows.h>
and not this:
#include "windows.h"
If that's not the problem, then check RichieHindle's response.
I've been using C/lex for a long time and would like to use F#/fslex now.
I'm comparably well off in C# and in the process of learning F#.
The only thing is that I can't see any project example or template where fslex is properly included in the Visual Studio build process.
Does anyone know where I can find one?
Lots of Greetings!
Volker
Unfortunately, there is no built-in item template for .fsl files, because FsLex is a part of PowerPack (so Visual Studio cannot expect that it will be installed). It would be definitely useful to have some template that could be installed with PowerPack!
Anyway, if you're looking for a sample project that uses FsLex (and has .fsl files as part of the project), then you can take a look at the F# source code (distribtued with the Visual Studio 2008 MSI/ZIP package). The project that contains .fsl is FSharp.Compiler.fsproj and on my installation, it can be found in C:\Programs Files\FSharp-1.9.9.9\source\fsharp\FSharp.Compiler. Surprisingly, it includes a lexer for the F# language itself :-).
To add FsLex item to the MSBUILD project (which is also Visual Studio project), it uses the following:
<FsLex Include="..\lex.fsl">
<OtherFlags>--lexlib Internal.Utilities.Text.Lexing</OtherFlags>
<Link>lex.fsl</Link>
</FsLex>
<Compile Include="lex.fs" />
In case you also needed FsYacc, here is an example (also from FSharp.Compiler.fsproj):
<FsYacc Include="..\pars.fsy">
<Module>Microsoft.FSharp.Compiler.Parser</Module>
<Open>Microsoft.FSharp.Compiler</Open>
<OtherFlags>--internal --lexlib Internal.Utilities.Text.Lexing
--parslib Internal.Utilities.Text.Parsing</OtherFlags>
<Link>pars.fsy</Link>
</FsYacc>
<Compile Include="pars.fs" />
Note that you need the FsYacc/FsLex command to invoke the custom tool, but also the Compile command which tells the compiler to include the produced fs file when building the project.
I'm using the free VS Shell until I finally threaten myself enough to finally buy the full VS, and unless I'm doing something wrong, (and I probably am) none of the normal solutions seem to work for me. What I do is add the following pre-build events to the project properties:
"C:\Program Files (x86)\FSharpPowerPack-2.0.0.0\bin\fslex.exe" "$(ProjectDir)\Lexer.fsl"
"C:\Program Files (x86)\FSharpPowerPack-2.0.0.0\bin\fsyacc.exe" "$(ProjectDir)\Parser.fsy" --module Parser
That seems to work well enough for me. Errors all go to the output window. If you're on a 32-bit machine, you would remove the (x86) from those paths.
Doing a little research it looks like they need to be separate. I found the following at this blog post ( http://blogs.msdn.com/chrsmith/archive/2008/01/18/fslex-Sample.aspx ) by Chris Smith:
Although you can add an F# Lex Specification file from the Visual Studio Add-In, to run fslex you will need to break to the command line. Fslex.exe is located in your F# distribution’s ‘bin’ directory.
Hope that helps.