PDA

View Full Version : C++ compiler needed (free is nice:)


Saladsamurai
Jan8-09, 09:16 PM
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

mgb_phys
Jan8-09, 09:22 PM
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/

shoehorn
Jan8-09, 09:48 PM
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.

ytoruno
Jan8-09, 11:07 PM
dev c++ is another one you might be interested in, its a complete IDE like visual studio.

Saladsamurai
Jan9-09, 02:24 PM
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

mgb_phys
Jan9-09, 02:32 PM
The MS one isn't a trial - if you download the EXPRESS edition it's totally free.

Saladsamurai
Jan12-09, 11:21 PM
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:

mgb_phys
Jan12-09, 11:37 PM
F5 / ctrl-F5 ? or debug->start->without debugging
Or at least it is in pro

Saladsamurai
Jan13-09, 12:11 AM
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.

Borek
Jan13-09, 02:05 AM
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?

mgb_phys
Jan13-09, 09:43 AM
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.

Saladsamurai
Jan13-09, 12:50 PM
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:

http://i12.photobucket.com/albums/a220/saladsamurai/debug.jpg
http://i12.photobucket.com/albums/a220/saladsamurai/linker.jpg

Now when I hit "Start w/out debugging I get this:
http://i12.photobucket.com/albums/a220/saladsamurai/error.jpg

Then I am lost again :smile:

Thanks for your help thus far, I appreciate it!

mgb_phys
Jan13-09, 01:12 PM
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 ?

Saladsamurai
Jan13-09, 01:29 PM
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?

mgb_phys
Jan13-09, 01:36 PM
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.

Saladsamurai
Jan13-09, 01:52 PM
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:

http://i12.photobucket.com/albums/a220/saladsamurai/file.jpg

mgb_phys
Jan13-09, 01:55 PM
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!

Saladsamurai
Jan13-09, 01:59 PM
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!

mgb_phys
Jan13-09, 02:07 PM
Sorry meant application (was doing it from memory)

http://i410.photobucket.com/albums/pp185/mgb_phys/new_project.png

Saladsamurai
Jan13-09, 02:11 PM
Sweet! Thank you :smile:

mgb_phys
Jan13-09, 02:28 PM
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"