PDA

View Full Version : How to compile .cpp with gcc (NOT g++)



alphaoide
11-25-2004, 12:50 PM
I tried this one, but did not work

gcc -x c++ prog.cpp
// gives "std::basic_string" undefined reference

oh, yeah, g++ keeps give me warning about "no newline at EOF" even though I have thousands of blank line at the end of code. What sup with that?

Salem
11-25-2004, 01:02 PM
But "gcc -x c++" is g++
Isn't it?
Where's the code?

alphaoide
11-25-2004, 01:08 PM
>> But "gcc -x c++" is g++, Isn't it?
In my practice, those two do not give equal result

>>

#include <iostream>
int main() {
std::cout << "Hello, world\n";
return 0;
}

Salem
11-25-2004, 02:37 PM
Try


gcc -x c++ hello.c -lstdc++

alphaoide
11-25-2004, 02:40 PM
oh ,yeah , baby. I'm back in business. Thnx a bunch

itsme86
12-02-2004, 12:55 PM
oh, yeah, g++ keeps give me warning about "no newline at EOF" even though I have thousands of blank line at the end of code. What sup with that?

Which text editor are you using to create your source code file?

alphaoide
12-02-2004, 02:24 PM
Which text editor are you using to create your source code file?
kdevelop

CornedBee
12-02-2004, 03:20 PM
It's a convention that the last character in a plain text file (such as source code) is a newline. Otherwise - well, output the file with cat and see for yourself where your prompt ends up.
gcc emits a warning when this is not the case.

Why can't you use g++?

alphaoide
12-02-2004, 11:04 PM
Something's wrong with my kdevelop. I did cat, all the newlines are there at the end of file yet the compiler warning persists. I open and simply re-save with vi and it compiles with no warning.
And I was just curious of the equivalence of g++

CornedBee
12-03-2004, 05:07 AM
g++ is usually merely a symlink to gcc, and gcc knows to assume C++ code and the C++ standard library if it's called via that link.

eccles
12-10-2004, 03:21 AM
Something's wrong with my kdevelop. I did cat, all the newlines are there at the end of file yet the compiler warning persists. I open and simply re-save with vi and it compiles with no warning.


can I just say that this is one of the most gorgeous/priceless statements ever??

take the hint my friend, and use vim for your coding...

:D

Kleid-0
12-20-2004, 10:28 PM
Edit the option in kdevelop to use "\r\n" for newlines rather than "\n" or whatever it uses. Tell me if that works.

Salem
12-21-2004, 01:19 AM
Stop bumping old threads will you!!!

Kleid-0
12-21-2004, 01:37 AM
It's only 10 days old!

Salem
12-21-2004, 03:00 AM
> It's only 10 days old!
The original question was answered a month ago, the rest was off-topic wibble which wound itself to a close.

See...
11-25-2004, 08:40 PM
oh ,yeah , baby. I'm back in business. Thnx a bunch