PDA

View Full Version : Missing "cc1plus?---Newb problems with compiling C



Felixworks
January 14th, 2009, 07:10 AM
I'm trying to learn C on Ubuntu 8.10, but when I tried to compile a simple "hello world" program I got this error:

gcc: error trying to exec 'cc1plus': execvp: No such file or directory


This is probably an easy fix, but in the book I'm following, there's nothing about an error like this. So what's going on? Thanks people ;)

kcode
January 14th, 2009, 07:27 AM
Can you post your code? And have you installed virtual package build-essential?? If not, then execute the following command:


sudo apt-get install build-essential


Cheers

monkeyking
January 14th, 2009, 07:28 AM
Have you installed the dev headers


sudo apt-get install build-essential

Felixworks
January 14th, 2009, 10:51 PM
Thanks, I think that should have worked but...I got another error code when I tried compiling again:

/tmp/ccnrI4Ih.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

jespdj
January 14th, 2009, 11:04 PM
What does your program look like? And what exactly are you typing to compile it? That's a very strange error for a simple Hello World program.

Try this:


#include <iostream>

void main(int argc, char *argv[]) {
std::cout << "Hello World" << std::endl;
}

Save this in a file named hello.cpp and then compile it:

g++ hello.cpp -o hello
And then to run it:

./hello

Felixworks
January 14th, 2009, 11:11 PM
Here's my program:
#include <stdio.h>

int main()
{
printf("Goodbye, cruel world!/n");
return(0);
} Hehe...not exactly a 'hello world' program, but it's along the same lines. I tried to compile it using
gcc goodbye.c -o goodbye as that's what the book said.

I tried what you said and I got this error when trying to compile it
hello.cpp:3: error: ‘::main’ must return ‘int’

dwhitney67
January 15th, 2009, 01:53 AM
Here's my program:
#include <stdio.h>

int main()
{
printf("Goodbye, cruel world!/n");
return(0);
} Hehe...not exactly a 'hello world' program, but it's along the same lines. I tried to compile it using
gcc goodbye.c -o goodbye as that's what the book said.

...

That should be a '\' in the printf() statement, not the '/'.

But that's is not what is causing the problem you are having with compiling/linking.

I've tried to duplicate the problem you are having, and the closest I was able to come was in an attempt to compile a C++ program using 'gcc'. That attempt yielded a few more error messages than you posted, but similar.


/usr/bin/gcc test.cpp
/tmp/ccCXGdoN.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x1d): undefined reference to `std::ios_base::Init::Init()'
test.cpp:(.text+0x22): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccCXGdoN.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status

Anyhow, if you are still having trouble, I would recommend that you verify the steps you are taking to compile, and if the problem persists, uninstall and then install again the build-essential package.

myromance123
January 15th, 2009, 03:22 AM
Wow what odd errors you're getting !

The only problem I spotted was the '/n' in the printf function which should be '\n' but that is definitely not the cause of your errors lol


Looks like a compiler or linker problem :P

Wow must have something to do with a broken or missing package is my guess (i said guess hehe)

myromance123
January 15th, 2009, 03:24 AM
Ooo, may I ask?

Are you by any chance using the "C for Dummies" book?

jespdj
January 15th, 2009, 11:48 AM
I tried what you said and I got this error when trying to compile it
hello.cpp:3: error: ‘::main’ must return ‘int’
Then change it to this:

#include <iostream>

int main(int argc, char *argv[]) {
std::cout << "Hello World" << std::endl;
return 0;
}
Note: This is a C++ program. It looks like you are compiling a C program. I assumed you were programming in C++, because the error message suggests that you are trying to compile a C++ program as if it is a C program.

If you're programming in C, then change your main() line to this:

int main(int argc, char *argv[])
instead of simply "int main()".

The way you are compiling it ("gcc goodbye.c -o goodbye") is correct.

dwhitney67
January 15th, 2009, 01:57 PM
...

If you're programming in C, then change your main() line to this:

int main(int argc, char *argv[])
instead of simply "int main()".

...


In C and C++, the usage of "int main()" is acceptable; in either case, one does not have to declare argc and argv.

The C code the OP posted earlier is syntactically correct, although I assume the "/n" should be a "\n" in the printf() statement. I also assume that the OP had named his/her file with a .c extension.

To compile/link the program, the OP should use "gcc", although "g++" also works for C programs.

For now, the OP appears to be MIA, so until we hear back from him/her, I would consider this thread to be dead.

Felixworks
January 15th, 2009, 11:11 PM
Sorry, I'm back. I'm trying to learn 'C'. Yes I am using the "C for Dummies" book...it was the only guide to C at my library :). It's from 2004 if that's a problem. So...what exactly was the issue? I got it working, but I have no idea how. Last night the original code I listed got that error code but today it works fine. Anyway, thanks for helping all of you.

myromance123
January 16th, 2009, 08:13 AM
Lol computer's are strange~

Many a time a restart will suffice and many it doesnt :P

Glad it works again for ya, I just finished the C for Dummies hehe
Moved on to C all-in-one desktop reference for Dummies xD

:lolflag: