Console cpp project in Visual Studio - c++

What and how should I install in order to be able to create an ordinary console project in Visual Studio?
Here is what I have already installed and what options I have. The problem is that there is no option for creating an ordinary console project. Is it named somewhat different not just a console project in cpp?

Look under the "Installed" tab on the left side, not the "Online" tab you currently selected. You should find "Win32 Console Application" there.

I recommend to use 'Empty project' option for such purposes. Just type 'Empty' in the search field to find it.
In this case you have to manually add .cpp file, define a main function - and you will have simple console application with no Windows-specific overheads.

Related

What type of Visual Studio project should I use?

I am going to be making a project with OpenCV and (probably) Qt for GUI and I was just wondering what kind of project I should create in visual studio? Would it be the Win32 Project or Win32 Console Application or just an Empty Project? A lot of them are quite obvious as I am not making a Dll or makefile but do not know the difference between the others. Thanks in advance.
Which type of project you decide to pick in Visual Studio depends what will best fits your needs. Since I do not know your exact needs, the best answer I can give is explain the difference between the types of Project Options and give examples when you would choose to use the given project:
Win32 Project: A Win32 Project is one of the options Visual Studio provides to you, and if chosen will provide the user with template code that generates a "window", that window being just like any other window (browser window, folder window, etc), but one that your program controls.
Examples: Making a calculator, making an application that needs a window with buttons for the user to communicate with the program, etc.
Win32 Console Application: In this option, Visual Studio provides a Command Prompt interface where the user can input data and also where output can appear. Basically it's the black window where you can input commands and receive information of what is happening in your program.
Examples: When testing out code (it makes debugging easier in some cases), when the program really doesn't need to be too elaborate, etc.
There are other options available, thou these two were mentioned in your post and are probably the most popular among developers.
After installing Qt and maybe a Qt-VisualStudio-Plugin you have some new options when creating a New Project:
You should choose Qt Application in most cases. Not sure if you can use a GUI with Qt Console Application, but you'll get a terminal/console in that case.
After choosing project name, you can easily choose the Qt Modules you'll need. This adds them to your project settings, so you don't have to add the manually (but I guess you can do so later if you need more modules).
The project will create a .ui file which you can open/edit with QtDesigner. The project will perform all the moc and uic compile steps automatically and you don't have to add those things manually.
I think this is the easiest way to use the combination of Qt and Visual Studio.
Adding OpenCV to Visual Studio is easy:
Just add the include directories and the correct OpenCV libraries.
The question whether to use a consolse application or not depends on your needs.
Personally, I like printing development output to a console, but maybe you don't want that in your final project ;)

Select File or Folder in MFC VS2010

I have converted a MFC application which was run on VS2005 to VS2010
In there I've functionality to select either a file or folder from CSelectDialog and it worked fine.
But when I convert the project into VS2010 now I can select files only.
How can I get rid of that? I couldn't find any libraries that I can use for this.
Simply I want to select either a file or folder using MFC in VS2010
Don't consider this as a duplication of
https://stackoverflow.com/questions/15852106/how-to-use-open-file-dialog-to-select-either-a-file-or-a-folder-in-vc-mfc
or
How do you configure an OpenFileDialog to select folders?
Because those answers are not applicable to this.
The source has a lot of assumptions about the types and ids of child controls on the file dialog. And the assumptions are broken if the file dialog upgraded to vista style. You can use the bVistaStyle parameter in the constructor to disable the automatic upgrade.
SHBrowseForFolder with BIF_BROWSEINCLUDEFILES is the only documented way I know of to choose file and folder at once. You can also consider supporting Shell Data Transfer between Windows Explorer and your program (e.g. drag/drop, copy/paste).
It looks like you're using some code from CodeProject that may not be compatible with 2010. You should use the standard CFileDialog to avoid any compatibility issues.

Adding icon to .exe

Hi people I been trying to do this the whole night, can somebody help me/guide me on this.
Details:
Not Visual Studio (using Geany).
I'm using A lightweight IDE, and projects option is not available.
Is for the .exe file output.
Please give me some guidance on this.
I use Resource Hacker for such tasks. This will add an existing icon to an EXE; you'll need another tool to make the actual icon.
I am guessing you are using Visual Studio since you are talking about Windows.
First go to "Resource View" (from menu: View → Other Window → Resource View). Then in "Resource View" navigate through resources, if any. If there is already a resource of Icon type, added by Visual Studio, then open and edit it. Otherwise right-click and select Add Resource, and then add a new icon.
Recompile your project and see if change takes effect.
Second way:
Use preprocessor directives in your resource script to choose your icon file.
You need to use the resource compiler rc.exe. You will also need to create a .rc file listing the resource (your icon). On compilation with rc.exe, you will get a .res file which should be passed to the linker.

Compiling and Running MFC Applications with Visual Studio 2008?

I was wondering if anyone can provide a detailed explanation on how I can compile and execute a C++ MFC application in Visual Studio 2008 given that I already have a .h and .cpp file only.
I couldn't find a decent and up to date explanation anywhere and when I try to create a plain MFC project in VS08 I get a bunch of xxx.h xxxDoc.h xxxView.h files, I try and replace those files with my own .cpp and .h files but i get a ton of errors when I run it.
So just to summarize, how do I compile and run my MFC project's .h and .cpp files in Visual Studio 2008 and create an .exe?
Thanks in advance.
See here: Creating an MFC Application
This tutorial may help you as well: Introduction to MFC Applications
It depends on what you are trying to do, but deleting the files the wizard creates is not a good idea. They are there because you told it to put them there (by selecting MFC-SDI/MDI), so they are necessary for the basic initialization and such.
If you don't need the Doc/View architecture, you can create a Dialog Based application. Or, you can even use an MDI or SDI app, and not use the Doc and the View, but if you want to delete them you'll have to make sure there are no references to them. What you cannot delete is the "MyProject.cpp" (where the CWinApp derived class lays), which does the initialization of the application.
Another option is to create a Console application with MFC support. To do so, you have to select "Win32 console application" in the wizard and then check "Add headers for MFC".

Setting file version number in Visual Studio 2005 C++

Can anyone point me in the right direction how to configure Visual Studio 2005 with our C++ console project how we can include a 'File Version' in the details section of the file properties.
I've tried resource files without any luck. This is with a C++ project just for clarification, and big thank you for the guys you responded with C# suggestions.
Thanks in advance.
If you are talking about unmanaged c++, you need to add a version resource to the project.
right-click on the project, choose add - Resource.... Choose Version and press new.
There you can enter all info you need.
You have to have one VS_VERSION_INFO section in your resource (*.rc) file(s) that compile into your project.
In the Visual Studio 2005 Solution Explorer, open the context menu on your C++ project and choose Add, Resource.
Mark Version and click "New".
Fill in the fields as desired and save the file.
Build.
Now your project output has a FileInfo resource.
Please be aware that Windows Vista does not show all available version info in the Explorer context menu's "Details" tab.
For c++ projects I use StampVer and call it as a post build operation including check in/out of revision control for release builds.
Unless you have a good reason for your file version to be different than the version of the assembly inside, I think it is a better idea to provide the AssemblyVersion alone. If you do not specify an AssemblyFileVersion, it will automatically get the same value, so you can see your assembly's version directly in the file's properties.
The advantage is that you can use a wildcard and allow the version to be automatically incremented, so that every time you compile the library you get a different build and/or revision number. As far as I can tell, this trick does not work with AssemblyFileVersion, so you have to increment it by hand.
Of course, all this only applies if you're writing .NET code. Are you by any chance talking about a project using unmanaged code?