You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Problems with /usr/bin/ar on MacBook Pro

I am having a problem with /usr/bin/ar on my MacBook Pro running 10.4.7. I get the following error:

mac3032 ~/src [0:492] ar rv stuff.a netscape-remote.o
ar: creating archive stuff.a
ar: temporary file: No such file or directory

This is with /usr/bin/ar supplied with both Xcode 2.4 as well as Xcode 2.3. I didn't try it with either the stock ar (assuming is supplied with the stock MacOSX), or with any earlier version of Xcode. The same command works fine on my G5 iMac. I have checked, obviously, the permissions on /tmp, and they seem fine:

mac3032 ~/src [1:510] ls -ld /tmp
lrwxr-xr-x 1 root admin 11 Aug 2 09:33 /tmp -> private/tmp
mac3032 ~/src [0:511] ls -lLd /tmp
drwxrwxrwt 482 root wheel 16388 Aug 17 08:28 /tmp

That is identical to what I have on my G5.

Any one else seen this?


15" MBP 2 GB 20" iMac 1 GB Mac OS X (10.4.7)

Posted on Aug 17, 2006 8:39 AM

Reply
6 replies

Aug 17, 2006 9:36 AM in response to etresoft

Ah, that was just an example. Short file names don't work either:

mac3032 ~/src [0:513] mv netscape-remote.o b.o
mac3032 ~/src [0:514] ar rv stuff.a b.o
ar: temporary file: No such file or directory

**AND**, as I said in the original post, it works on my G5!

And, please, don't suggest that I should abandon an archive library for a shared library or anything like that. I am trying to install a package that I got from someone else, and that package puts everything into an archive lib. It should work, but it doesn't, at least not on my MBP.

Aug 17, 2006 10:00 AM in response to Robert Clare1

There are still lots and lots of factors that could cause a failure that have nothing to do with the MBP.

The only MBP-specific factor I can think of is that maybe ar just has some bug. It is very unlikely that this is the case. Something like that would probably have been noticed.

You can also use libtool to create static archives.

It is also possible that your MBP has the case-insensitive flag set differently than on the G5. You could have a "Stuff.a" file that is causing problems.

Do you have an existing archive file in this directory? If so, delete it. You could have an old copy with PPC files in it.

Do you have any leftover object files in this directory? If so, delete them. You could have some PPC object files that you copied over from the other machine.

Have you checked/repaired permissions? There could be some strange setting with this directory or /tmp.

I'm not asking you to use shared libraries. I don't even like them. I prefer to use static libraries for software I distribute. I have had no problems with libtool. I don't know if ar will still work in the new world of universal static libraries as I have never tried it.

If you suspect there is a problem with ar, don't just rename a file called "netscape-remote". You have to do a sanity check with an object file that contains only a simple helloworld function. If ar fails on that, you know it is a bug. Otherwise, there are far too many other possibilities.

Aug 17, 2006 10:55 AM in response to etresoft

OK. All good suggestions. I have repaired disk permissions. A couple of directories in /var were a little off, but that didn't help.

I made a very simple Hello World function:
mac3032 ~/bug [0:567] cat hello.c
#include <stdio.h>

void hello () {
printf("Hello world.\n");
}
mac3032 ~/bug [0:568] gcc -c hello.c
mac3032 ~/bug [0:569] ls -l
total 12
-rw-r--r-- 1 clare staff 67 Aug 17 10:48 hello.c
-rw-r--r-- 1 clare staff 628 Aug 17 10:50 hello.o
-rw-r--r-- 1 clare staff 39 Aug 17 10:41 main.c
mac3032 ~/bug [0:570] ar rv libstuff.a hello.o
ar: creating archive libstuff.a
ar: temporary file: No such file or directory

It compiles fine 🙂, but ar just doesn't work.

libtool does work:

mac3032 ~/bug [0:578] libtool -static -o libstuff.a hello.o
mac3032 ~/bug [0:579] ll
total 16
-rw-r--r-- 1 clare 67 Aug 17 10:48 hello.c
-rw-r--r-- 1 clare 628 Aug 17 10:50 hello.o
-rw-r--r-- 1 clare 848 Aug 17 10:54 libstuff.a
-rw-r--r-- 1 clare 39 Aug 17 10:41 main.c
mac3032 ~/bug [0:580] gcc main.c -L. -lstuff
mac3032 ~/bug [0:581] ./a.out
Hello world.

(main.c is equally simple:
int main () {
hello();
return 0;
}
)

But, to use libtool instead of ar, I will have to change the make rules in the package, as the makefiles that are in the package use the implicit ar rule for adding objects to the library...

I guess it is time to submit a bug report to Apple?

Aug 17, 2006 11:41 AM in response to Robert Clare1

But, to use libtool instead of ar, I will have to
change the make rules in the package, as the
makefiles that are in the package use the implicit ar
rule for adding objects to the library...

I guess it is time to submit a bug report to Apple?


I think you're almost to that point. I'm interested enough now to try it. Unfortunately, this Dell in front of me isn't going to help. I will have to wait a couple of hours.

Bugs are like birds. No one will believe until you get a double-sighting. I will try it and report back. There are still things (such as environment variables) that could cause a problem. But from your description, the burden of proof has now shifted the other way. I now have to prove that ar isn't broken.

In any event, it might be a good idea for you to fix that code so that it uses libtool and builds a universal binary. If it is open source, you can submit your fixes. I have never had much luck getting my MacOS X fixes into open-source projects. I try, but I always wind up having to maintain my Mac fixes in my own CVS repository.

Aug 17, 2006 12:00 PM in response to etresoft

ARRGGHHHHH!!!!!!!!!!!!!

It was an environment variable! In my profile, for reasons which have been lost in antiquity, I set TMPDIR=/usr/tmp. Well, /usr/tmp doesn't exist, by default, on Mac OSX. I had made a link in /usr (I know, that's a BAD thing to do) on my iMac. I had also made a link on my MBP. But, not too long ago, I had to reinstall the OS on my MPB. That completely replaced /usr including my link. That, of course, is why messing with /usr is BAD.

I have now killed the setting of TMPDIR in my profile. And, miracles of miracles, ar is now working!

Sorry for wasting your time and net bandwidth!

Problems with /usr/bin/ar on MacBook Pro

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.