Compile single C++ file in Visual Studio 2010 - c++

I want to compile a single file in c++ using Visual Studio 2010. I created a new file, not a project, and wrote some "hello world" code and I want to compile it and run it. How to do so?
I've searched here and in Google, I got things like F7 or F5 nothing worked.

You can follow this guide from MSDN to compile standalone C++ files without an IDE.

In Visual Studio 6.0, you could load up a single CPP file, with a main(), and compile it. Can't remember if this was taken away in Visual Studio 2008 or 2010, but it's gone.
It used to be easy to fire up a new instance, paste in some test code an just run it. Now it takes creating or using a dummy project, as others above have noted.
Not hard, just less handy than before.

Probably for simple tests editing your source file in some editor like Notepad or Metapad and building from the command line with something like:
cl /EHsc /W4 /nologo YourSource.cpp
would be just fine (faster than starting up VS2010 IDE, create new project, etc.)

Related

How to compile a C++ File without making a project in Visual Studio 2017?

I want to compile a C++ source file without making a project in visual studio 2017 without making a project like we do in some code editors, how can I do that. Can anyone please tell?
Here is an example, in sublime text, I create a code and then compile it by ctrl + b.In a similar manner, I want to do that in visual studio 2017.
You can open a folder and start coding in visual studio without creating a project or solution file.
They call it the Open Folder feature.
Visual Studio 2017 introduces the "Open Folder" feature, which enables you to open a folder of source files and immediately start coding with support for IntelliSense, browsing, refactoring, debugging, and so on. No .sln or .vcxproj files are loaded...
from the main menu select File | Open | Folder or press Ctrl + Shift + Alt + O.
The easiest way I found from there is to right click in the "Solution Explorer" area and select "Open Developer Command Prompt". From there you can use cl to compile your program however you see fit.
You can open "Developer Command Prompt for VS2017" at the start menu and use cl.exe to compile your source code.
E.g.
c++ source file name: test.cpp
type "cl test.cpp"
Then, it will generate "test.obj" and "test.exe" if no bugs found.
You can type "cl" for simple usage and "cl /?" for complete help.
If you wish to get away from the IDEs I would recommend looking up MinGW for compiling in the command prompt. If you are running Ubuntu or something similar I believe you can compile in bash without further extensions.
For MinGW http://www.mingw.org/wiki/mingw_for_first_time_users_howto
I believe you compile in the same way in ubuntu if not I believe you can find some sources for that aswell.
Pros about compiling in the terminal is mostly that you do not have to setup a complete project but you can make your own personal little setup. Of course an IDE is a simple way to start but compiling in the terminal also helps you understand what is actually happening instead of just pressing "Debug".

Visual studio 2015 not compile changes c++

from some time visual c++ compiler not compiling my code, I tried to do things that are there: Visual Studio 2013 C++ not compiling changes
Cleaning soultion works in my case, but after compilation i must do it again and so always. I saw also Build solution options and build configuration and there are OK. I moved project, delete execute file but it also not helped me.
What I can do to fix it? :(

How to compile source C++ code that doesn't have a project file?

I have just started learning more about C/C++ and I am using Visual Studio 2013 to manage the code.
A project I am working on to use the Tobii EyeX eye gaze system requires me to be able to tweak this code slightly, however I do not understand how I can compile this code to an exe file without a Microsoft Visual Studio project file. This is that code:
https://github.com/MastaLomaster/bkb
In the source folder you see all the project's files but not an actual project file. How would I go about compiling this code? Where do I start? I can not seem to be able to load this is Visual Studio at all - the programmer of the code says (at the bottom of the Github page):
Compiling the source codes As for now, you have to use Microsoft
Visual Studio 2012 (latest update preferred)...
Either create a makefile(if no makefile is exist) for visual studio using nmake or you can use the suggestion provided in this link.
Additionally you can create a project by adding these codes as source. follow this link.

auto compile MS visual c++

I have 2 programs: One written in c++ and compile on MS visual studio 2010; The other written in C# and compile on MS visual studio 2010.
My second program automatically edit one of first projects file (.cpp), I want to know is there any way to auto compile my c++ code on file changed?
Thanks.
Yes, call msbuild.
E.g.
msbuild YourSolution.sln /p:Configuration=Release
(Or Debug, if that's what you're building for)
Sounds like your tool would be better off written as an msbuild task though.

OpenGL: How to compile glew32.dll from source file

I download the glew source file from http://glew.sourceforge.net/.
In the readme file, it says I should use \build\vc6.0\glew.dsw to comple the DLL.
But there are four projects after I open it in VS 2010.
When I compile them, 2 of them failed to compile.
Thanks.
Ok.
I figured it out.
Just open the the file in glew.dsw in VS 2010.
There are four projects.
Compile glew_shared, you will get glew32d.dll.
Compile glew_static, you will get glew32d.lib.
just ignore the other two.
glew32d.dll and glew32d.lib works fine in VS 2010.
This also answer my own question in
Glew in VS 2010: unresolved external symbol __imp__glewInit
Just a guess but by the way that folder is labelled, it's probably meant to compile using Visual C++ 6.0, which came with Visual Studio 6. I just gave it a quick try and built without problems under that IDE. Of course, I don't believe Microsoft offers that product anymore. If you want to build it yourself, you'll probably have to upgrade the code base to Visual C++ 2010.
I ran into the same problem. I converted the original project to Visual Studio 2010 and placed the result in https://github.com/chrisoei/glew. See the downloads section for a zip file containing glew32.dll built using VS 2010.