Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Old 03-15-2012, 07:05 PM   #1
Alutard
Prospect
 
Join Date: Mar 2012
Posts: 2
gcc compiler not working

This is my first time on these forums, so I'm not sure if this is the correct place to post this. I'm new to Mac OSX, so I figured I'd post my question here.

I'm using OSX Lion, but I'm having trouble compiling C code. I downloaded Xcode for the gcc compiler, and it's in my $PATH. Then I'll write a simple C program such as:

#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}

Then I save it and run the command: gcc -o hello hello.c

Instead of compiling I get this error message:

ld: library not found for -lcrt1.10.6.o
collect2: ld returned 1 exit status

I have no idea what this means or how to fix it. Any help will be greatly appreciated! Thanks!
Alutard is offline   Reply With Quote
Old 03-16-2012, 06:08 AM   #2
bramley
MVP
 
Join Date: Apr 2004
Location: Cumbria, UK
Posts: 2,461
Which version of XCode have you downloaded?
bramley is offline   Reply With Quote
Old 03-16-2012, 11:41 AM   #3
fracai
MVP
 
Join Date: May 2004
Posts: 2,099
This looks like you have a rogue compiler flag somehwere in your environment. What's the output of: env | grep 'lcrt1.10.6.o'
fracai is offline   Reply With Quote
Old 03-19-2012, 01:14 PM   #4
Alutard
Prospect
 
Join Date: Mar 2012
Posts: 2
Quote:
Originally Posted by bramley
Which version of XCode have you downloaded?

I downloaded 4.3.1.
Alutard is offline   Reply With Quote
Old 03-19-2012, 01:39 PM   #5
szymczyk
Prospect
 
Join Date: Aug 2005
Posts: 45
When you install Xcode 4.3, it does not initially install tools for compiling from the command line. Go to Xcode's Downloads preferences and click the Components tab. From there you can install the command line tools. After installing the command line tools, you should be able to compile from the command line.
__________________
Mark Szymczyk
Author, Xcode Tools Sensei
http://www.meandmark.com
szymczyk is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:22 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.