Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > "ld: can't locate file for: -lrt"

"ld: can't locate file for: -lrt"
Thread Tools
wwiiol
Fresh-Faced Recruit
Join Date: Mar 2003
Location: Las Vegas, NV
Status: Offline
Reply With Quote
Nov 9, 2004, 02:48 AM
 
I'm working with semaphores and threads (semaphore.h and pthread.h).
If i try to compile blah.c from the command line
gcc blah.c -lpthread -lrt

I get the the error in the subject. Xcode compiles but gives me alot of errors from sem_wait().

I have tried reinstalling Xcode but that didn't help.

Any help would be appreciated ALOT.


[edit] I have the current xcode version (1.5).
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Nov 9, 2004, 04:19 PM
 
That's because there is no librt? And libpthread is just a symlink to libSystem (which is linked automatically), so that's not needed either.

What do you getif you don't specify those libraries at all?
     
wwiiol  (op)
Fresh-Faced Recruit
Join Date: Mar 2003
Location: Las Vegas, NV
Status: Offline
Reply With Quote
Nov 9, 2004, 08:02 PM
 
It compiles but i get errors from sem_wait() when I run it.
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Nov 10, 2004, 04:01 PM
 
You get errors? Say it ain't true.
     
wwiiol  (op)
Fresh-Faced Recruit
Join Date: Mar 2003
Location: Las Vegas, NV
Status: Offline
Reply With Quote
Dec 17, 2004, 03:27 AM
 
Anyone have constructive help?
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 17, 2004, 06:22 AM
 
If you want a good, specific answer, ask a good, specific question. How are we supposed to troubleshoot "I get errors"? There's no information about what kind of errors (Does it make the Quark robot come out and zap everything?) or any sample code for us to find problems with.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
hayesk
Guest
Status:
Reply With Quote
Dec 17, 2004, 10:01 AM
 
Are you using unnamed semaphores? MacOS X doesn't support unnamed semaphores, but it does support named semaphores. Use Google to get some more info and sample code.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Dec 17, 2004, 04:00 PM
 
I didn't think Mac OS X even had the APIs for unnamed semaphores (meaning it wouldn't be possible to compile an app that uses them).
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
wwiiol  (op)
Fresh-Faced Recruit
Join Date: Mar 2003
Location: Las Vegas, NV
Status: Offline
Reply With Quote
Dec 18, 2004, 06:25 AM
 
The soruce file has nothing to do with it

I type in "gcc blah.c -lrt" at the command prompt.
I get this: "ld: can't locate file for: -lrt"

I can't be any more specific than this.

I believe I'm missing a file or something is not linked properly.
     
wadesworld
Grizzled Veteran
Join Date: Apr 2001
Status: Offline
Reply With Quote
Dec 18, 2004, 11:17 AM
 
Originally posted by wwiiol:
The soruce file has nothing to do with it

I type in "gcc blah.c -lrt" at the command prompt.
I get this: "ld: can't locate file for: -lrt"

I can't be any more specific than this.

I believe I'm missing a file or something is not linked properly.
Well, if you're going to try to link to a library, you should make sure that the library exists.

There's no "librt.a" on OS X.

I don't know where you got the idea you needed such a lib, but it looks like the instructions were wrong.

Post the errors you get when you run it without attempting to link to libraries.

Wade
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Dec 18, 2004, 12:01 PM
 
Originally posted by wwiiol:
The soruce file has nothing to do with it
Uh, sorry... You're compiling source code, and having problems, so how exactly is the source nothing to do with it? It's everything to do with it.

I type in "gcc blah.c -lrt" at the command prompt.
I get this: "ld: can't locate file for: -lrt"
And as I already said in the first reply way up there, there is no librt on OS X by default. Kicking and screaming won't magically make the linker find it if it's not there. Also, you said earlier:
It compiles but i get errors from sem_wait() when I run it.
So, which is it to be? Either it compiles or it doesn't.

I can't be any more specific than this.
Then nobody can help you.

I believe I'm missing a file or something is not linked properly.
Maybe you need to get this librt? But apparently not because it compiled and then you got "errors". Of course, nobody can tell you what to do to fix these "errors" because they don't know what these "errors" are. Any attempt to help you would be a stab in the dark, and expecting people to try and do your work for you is probably not going to get you any helpful responses.

Oh, and actually, I was being constructive. I was trying to cajole you into providing more information so that people could actually help you. You're apparently unable or unwilling to do so, and if that's the case then you shouldn't expect people to help you. Actually, you shouldn't expect people to help you at all, but anyway.

You'd do well to read this: http://www.catb.org/~esr/faqs/smart-questions.html
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 04:13 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,