PDA

View Full Version : g++ error




aaeyers
Feb 16, 2008, 03:25 PM
I've been trying to compile a test c++ program (test.cpp) in the terminal, but I can't get g++ to run. I keep getting an error, and I have no idea what it means, could any of you guys help me out?

x-134-84-96-216:~ aaeyers$ g++ test.cpp -o test
/usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/libstdc++.dylib load command 5 unknown cmd field
/usr/bin/ld: /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libSystem.dylib unknown flags (type) of section 6 (__TEXT,__literal16) in load command 0
/usr/bin/ld: /usr/lib/libSystem.B.dylib unknown flags (type) of section 6 (__TEXT,__literal16) in load command 0
collect2: ld returned 1 exit status
x-134-84-96-216:~ aaeyers$



toddburch
Feb 16, 2008, 04:05 PM
Can you post your code?

aaeyers
Feb 16, 2008, 04:31 PM
Can you post your code?

To my test program?

#include<iostream>
using namespace std;

int main()
{
int num;
cout <<"Enter number: ";
cin >> num;
cout << endl << "Your number is " << num << endl;
return(0);
}

aaeyers
Feb 16, 2008, 04:35 PM
Ok, I reinstalled the developer tools, and now I can compile files, but they won't run in the terminal. Using the same program, I compile it, and try running it, but nothing happens. I've tried running a bunch of programs that I've written (that work when I compile and run in Ubuntu), but none of them seem to be recognized in the terminal.

x-134-84-96-216:~ aaeyers$ cd Projects
x-134-84-96-216:Projects aaeyers$ ls
csci1113 test test.cpp test.cpp~
x-134-84-96-216:Projects aaeyers$ emacs test.cpp
x-134-84-96-216:Projects aaeyers$ g++ test.cpp -o test
x-134-84-96-216:Projects aaeyers$ test
x-134-84-96-216:Projects aaeyers$


#include<iostream>
using namespace std;

int main()
{
int num;
cout <<"Enter number: ";
cin >> num;
cout << endl << "Your number is " << num << endl;
return(0);
}

sord
Feb 16, 2008, 05:34 PM
Your program isn't running because you are trying to execute the 'test' program thats in the path (/bin/test) as opposed to your program. Try using './test' (minus quotes)

aaeyers
Feb 16, 2008, 11:06 PM
Your program isn't running because you are trying to execute the 'test' program thats in the path (/bin/test) as opposed to your program. Try using './test' (minus quotes)

Oh alright, got it. Thanks for the help. I never would have figured that out on my own.

ChrisBrightwell
Feb 17, 2008, 02:06 AM
Oh alright, got it. Thanks for the help. I never would have figured that out on my own.

Read the man page for the 'which' command. :)