gcc ld error under MacOs

Joined
May 13, 2011
Messages
3
Reaction score
0
Points
1
Hi, all,

I am a newbie of MacOS. Now I am compiling a simple test.cc under it but ld error happened. So could you help me?

-MacOS: Darwin kernel Version 10.0.0
-Xcode: 2.5

-The content of test.cpp
int main()
{
;
return 0;
}

-The command I input: gcc test.cc

-The output Info.:
/PATH/OF/GCC/ld: /usr/lib/system/libmathCommon.A.dylib load command 4 unknown cmd field
collect2: ld returned 1 exit status

-What I have did before
I login as a normal user(not root) and
1> Faced a error of "no gcc", so add /PATH/OF/GCC to $PATH
2> Faced a error of "no lib", so add a new env viariable, that is LD_LIBRARY_PATH=/PATH/OF/SDK/usr/lib

Then, I faced the problem mentioned above. Hope your suggestion. Thank you!

BTW, I did google and found some answers about this kind of problem, but most of those are suggestion of updating OS or Xcode. But I cannot update them cause I am not root, and I heard that other people has compiled sucessfully on this environment.

Daqi
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You have an unnecessary semicolon above the "return 0;". Remove that. You've also got a main method that doesn't do anything.
 
OP
D
Joined
May 13, 2011
Messages
3
Reaction score
0
Points
1
Vansmith,
Thanks for your reply.
And I just did a test code but not an actual here. My question is how to compile it successfully?

Daqi
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top