C++ compiler needed (free is nice

  • C/C++
  • Thread starter Saladsamurai
  • Start date
  • Tags
    C++ Compiler
In summary: You are not supposed to use the Main() function in a DLL. Use a main() function in a WinMain() instead.
  • #1
Saladsamurai
3,020
7
C++ compiler needed (free is nice:)

So I am taking a very basic (no pun) programming course at my university. We are working in C++ for now and we use Microsoft Visual Basic C++ 6.0 (or something to that effect).

I live waayyy off campus, so I would like to be able to work at home if necessary as opposed to hanging out all day in the computer lab.

Is there a C++ compiler that is:

a) free

b) Operates in the same exact way as MS Visual

c) Will allow me to save a program and then open it with MS Visual

?

Sorry if these are silly questions, but this is my first experience with programming.

Casey
 
Technology news on Phys.org
  • #2


The express edition of Microsoft Visual studio is free (all languages) http://www.microsoft.com/express/vc/

The compiler doesn't do all the performance optomisations of the pro one but is otherwise identical, you have to manually download some extra SDKs to do certain kinds of windows programming but for general learning C++ it is great.

There is also the excellent GCC compiler for windows http://www.mingw.org/
But if you want an IDE you will need to something like eclipse http://www.eclipse.org/
 
Last edited by a moderator:
  • #3


Note that the interplay of Visual C++ 6.0 with the current version of Visual C++ is sub optimal. In particular, since VC++ 6.0 was such a dog you may find that VC++ 2008 sometimes has problems importing projects generated with VC++ 6.0. Moreover, if you find yourself doing anything vaguely related to technical/scientific computing with VC++ 6.0, get ready to learn an awful lot about pragmas...

You might find it worth your while having a word with whoever's giving your class and telling them that the current (Express) version of Visual C++ is both free and much, much better than VC++ 6.0. It would make an awful lot more sense to give a class based on the newer, better version than a ten year old piece of crap.
 
  • #4


dev c++ is another one you might be interested in, its a complete IDE like visual studio.
 
  • #5


mgb_phys said:
The express edition of Microsoft Visual studio is free (all languages) http://www.microsoft.com/express/vc/

The compiler doesn't do all the performance optomisations of the pro one but is otherwise identical, you have to manually download some extra SDKs to do certain kinds of windows programming but for general learning C++ it is great.

There is also the excellent GCC compiler for windows http://www.mingw.org/
But if you want an IDE you will need to something like eclipse http://www.eclipse.org/

That free MS Visual trial looks perfect! Thanks! I think 90 days should be right on schedule since we then move on to MATLAB.

Thanks for all the input guys :smile:

Casey
 
Last edited by a moderator:
  • #6


The MS one isn't a trial - if you download the EXPRESS edition it's totally free.
 
  • #7


Okay... where the HELL is the execute command/button in Visual Express? Am I retarded or something?

I have been looking for like 30 minutes now :rofl:
 
  • #8


F5 / ctrl-F5 ? or debug->start->without debugging
Or at least it is in pro
 
  • #9


I cannot get it to work. It's weird; I click "start w/out debugging" and a dialogue box appears that asks me to "pick something executable file..." and there is a drop box with only one option.

I did not want to mess with it since it looked like something registry-related.

What happened to a simple red exclamation point?

Also, the "Help" section is a nightmare. I am going to watch a tutorial when I get time.
 
  • #10


Strange. If you have a properly created project (it is called a solution now, or something, I am still thinking in terms of VStudio 6.0) F5 or Ctrl-F5 should either start the program, or ask if you want to make it if there is no up to date exe.

Perhaps you have just opened some source without creating a project?
 
  • #11


In the project setup (project menu->properties or right click on the project in the tree)
Then Configuration properties->Debugging
The 'Command' should be $(TargetPath)
Also check the 'Output file' setting in Linker->General

If it's missing it will ask you for the executable to run.
 
  • #12


Hmm. Still having trouble; sorry, this is my first time with any programming software :smile:

I have my program written in an open project.
I have "built" it and there are zero errors.

That info you told me to check looks like this (I had to put in the "$(TargetPath)") Is it really supposed to say that? Or am I supposed to replace "Target path" with something?:blushing:

debug.jpg

linker.jpg


Now when I hit "Start w/out debugging I get this:
error.jpg


Then I am lost again :smile:

Thanks for your help thus far, I appreciate it!
 
  • #13


You are building a DLL (a shared library) not an executable.

If you want an executable set
Configuration properties->General
Configuration type = Application (.exe)

I'm surprised it let you build a dll with a main() without complaining ?
 
  • #14


Awesome! Thanks so much!

So will I need to change all of that stuff ($(TargetPath)", (Application(.exe))
every time I start a new project?

Or will it default to that from now on?
 
  • #15


It will be filled in automatically.
When you start a new project it asks you if you want to create a console app, windows app, dll etc.
 
  • #16


Okay. My problem is I really just do not know what I am doing.

Here is a really stupid program I just wrote; I am sure there are errors, but that is not important:

#include <iostream>;
using namespace std;

int main()
{
double x1 (1), x2 (2);
y = x2-x1;

cout <<"y is " << y;

return (0)
}

Now if I want to open Visual Studio and paste that into an environment where it will work, what is the correct file path?

When I click File-->new project

these are my options:

file.jpg
 
  • #17


Select win32->win32 console project
It will just make a regualr .exe that you can run on the command line (or from visual studio)

It will create an empty project with a file called "name_of_project.cpp" containing just

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

You can replace this with the normal main(...) it's just some windows redefines for historical reasons.


CLR is C++ but running ontop of the .Net - a whole level of complexity you want to avoid!
 
  • #18


mgb_phys said:
Select win32->win32 console project
It will just make a regualr .exe that you can run on the command line (or from visual studio)

CLR is C++ but running ontop of the .Net - a whole level of complexity you want to avoid!

:rofl: Sorry, but there is win32--> and my options are "Win32 Console Application" or "Win32 Project"

There is no "win32 console project"

Thanks!
 
  • #19


Sorry meant application (was doing it from memory)

new_project.png
 
  • #20


Sweet! Thank you :smile:
 
  • #21


For very simple programs like that you can also just use the command line compiler.
Create "whatever.cpp" in a text editor then in the start menu for visual studio there should be an entry "visual studio 200X command prompt" which will start a dos box with all the correct paths set.
Cd to the the directory with "whatever.cpp" and just type "cl whatever.cpp" it will create "whatever.exe" which you can run by just typing "whatever"
 

1. What is a C++ compiler?

A C++ compiler is a software program that translates C++ code into machine-readable instructions that a computer can understand and execute.

2. Why do I need a C++ compiler?

If you want to write and run programs in the C++ programming language, you will need a compiler to translate your code into executable files that can be run on your computer.

3. Is a C++ compiler necessary for free?

Yes, a C++ compiler is necessary for free. While there are paid options available, there are also many free C++ compilers that can be downloaded and used without any cost.

4. What are some popular free C++ compilers?

Some popular free C++ compilers include GCC, Clang, MinGW, and Visual Studio Community Edition. These compilers are widely used and have a good reputation for their performance and features.

5. Where can I find a free C++ compiler?

You can find free C++ compilers on the websites of the compilers themselves, as well as on open-source platforms like GitHub. Many programming tutorials and courses also provide links to free C++ compilers for learners to use.

Similar threads

Replies
6
Views
1K
  • Programming and Computer Science
Replies
20
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
5
Views
7K
  • Science and Math Textbooks
Replies
1
Views
925
Back
Top