Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

aaeyers

macrumors newbie
Original poster
Feb 16, 2008
27
0
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?

Code:
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$
 

aaeyers

macrumors newbie
Original poster
Feb 16, 2008
27
0
Can you post your code?

To my test program?

Code:
#include<iostream>
using namespace std;

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

aaeyers

macrumors newbie
Original poster
Feb 16, 2008
27
0
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.

Code:
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$

Code:
#include<iostream>
using namespace std;

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

sord

macrumors 6502
Jun 16, 2004
352
0
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

macrumors newbie
Original poster
Feb 16, 2008
27
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.