LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Free C++ Compiler (https://www.linuxquestions.org/questions/programming-9/free-c-compiler-115704/)

leroy27336 11-13-2003 04:35 PM

Free C++ Compiler
 
anyone know any good, free c++ compiler for the linux workstation??

dakensta 11-13-2003 04:49 PM

Is this a trick question?

g++ as part of gcc (Gnu Compiler Collection) is very likely already installed, and if not certainly available as part of your distro.

leroy27336 11-13-2003 05:17 PM

ok i just installed it......however just running a little test program i'm wondering why i'm getting so many damn errors with this this little bitty piece of code.

#include <iostream>
using namespace std;


int main()
{

cout <<"Hello World\n";

return 0;

}

i'm getting errors such as this one:

undefine reference to 'std::cout' but also many others as well.

leroy27336 11-13-2003 05:21 PM

it alos syas iostream no such file or directory

leroy27336 11-13-2003 05:26 PM

is there another library where the cout function is defined in or what.....it's not liking "using namespace std"

mr_segfault 11-13-2003 05:42 PM

Did you compile with g++ or gcc?

You must use g++

Cheers

leroy27336 11-13-2003 05:48 PM

ok so now when i try to run it does it say:

permission denied

i'm using the command ./test.c

thanks for your help

leroy27336 11-13-2003 05:50 PM

nevermind....i noticed that it created a new binary file with a differnt name...how do i compile it so it will create either the name of the .c file i compile or a name of my choosing.....

leroy27336 11-13-2003 05:54 PM

also what i really wanted to know was if there was a 3rd party c++ program...one like bloodshed dev c++.....one that will auto format for me, and show nice little blue italicized postcondition and precondition remarks.......one that will turn the cout statements into nice little red words......just one that is better then g++....i do appreciate all your help and quick replys......

amos 11-13-2003 06:17 PM

Open kwrite or kate.

Save your blank document as helloworld.cpp (or something similar ending with .cpp).

Type in your code, it'll be coloured.

When you've finished and saved. In the directory where you've saved it at the command prompt type:

g++ -o hello.exe helloworld.cpp

This should produce an executable called hello.exe (it doesn't need an exe extension). To execute it type hello.exe at the prompt.

If you want more then start looking at kdevelop.

Doesn't bloodshed dev-c++ use a port of gcc/g++ to compile anyway.

Cheers
Amos

Skyline 11-13-2003 10:14 PM

Quote:

how do i compile it so it will create either the name of the .c file i compile or a name of my choosing.....
Save your code in an ordinary text file as:

sourcefile.C

(capital C)

Then to get an executable with the same name without the .C extension do

g++ path_to_sourcefile.C -o sourcefile

Here.. the executable is created in your current working directory.

....... and for a different name.. simply

g++ path_to_sourcefile.C -o executable_name


All times are GMT -5. The time now is 09:24 PM.