Hi,
I recently moved from MacOS 10.4 to 10.5 on my old PPC laptop. I re-installed GPC for MacOS 10.5 from the Microbizz site. When I try to compile a hello world program, I get the following error:
gpc p.pas /Xcode2.5/usr/bin/ld: can't locate file for: -lcrt1.o collect2: ld returned 1 exit status
The file crt1.o is sitting in
/Xcode2.5/SDKs/MacOSX10.4u.sdk/usr/lib
When I add the above directory to my PATH, I still have problems. My path is now:
/usr/bin:/bin:/usr/sbin:/sbin:/Xcode2.5/usr/bin:/Xcode2.5/SDKs/MacOSX10.4u.sdk/usr/lib
Do I have my path set up wrong?
Yours, Kevan
Kevan Hashemi wrote:
Hi,
I recently moved from MacOS 10.4 to 10.5 on my old PPC laptop. I re-installed GPC for MacOS 10.5 from the Microbizz site. When I try to compile a hello world program, I get the following error:
gpc p.pas /Xcode2.5/usr/bin/ld: can't locate file for: -lcrt1.o collect2: ld returned 1 exit status
The file crt1.o is sitting in
/Xcode2.5/SDKs/MacOSX10.4u.sdk/usr/lib
When I add the above directory to my PATH, I still have problems. My path is now:
/usr/bin:/bin:/usr/sbin:/sbin:/Xcode2.5/usr/bin:/Xcode2.5/SDKs/MacOSX10.4u.sdk/usr/lib
Do I have my path set up wrong?
The PATH environment variable is not what the linker is using. Apart from linking in crt1.0 manulally, there are two solutions to your problem:
1. Check UNIX Tools in the Xcode installer when installing Xcode. This is the simplest solution.
2. Add the command line option -Wl,-syslibroot,/Xcode2.5/SDKs/MacOSX10.4u.sdk.
Let me know if this works.
Regards,
Adriaan van Os
Dear Adriaan,
Thank you for your help.
The PATH environment variable is not what the linker is using.
Of course you are right. I was not thinking clearly.
Apart from linking in crt1.0 manulally
This does not work because there are other libraries missing in addition.
- Check UNIX Tools in the Xcode installer when installing Xcode. This
is the simplest solution.
I un-installed Xcode2.5 and re-installed, but did not see any UNIX Tools box.
- Add the command line option
-Wl,-syslibroot,/Xcode2.5/SDKs/MacOSX10.4u.sdk.
This works. And it's the same line I add to make shared libraries out of my Pascal code. Thank you very much.
Last night I tried to solve my problem by running cctools-576 from your website. After that, my linker does not recognise the -mmacosx-version-min=10.4 option, despite removing and re-installing XCode 2.5. Where does this cctools come from? I Googled it, but am finding unrelated tools of the same name.
In theory, can I run cctools-576 then run gpc, and so avoid installing XCode all-together?
Yours, Kevan
Dear Jonas,
You may have to perform a custom install (click on the "Customize" button in the installer). There is no need to uninstall Xcode 2.5 first.
Thank you for yor suggestion. I tried that, and the installer is unaware of the fact that I already deleted the entire Xcode directory. It still thinks I have all the files installed, and it gives me no options for installing the files. I think I generally messed things up with a combination of deleting that Xcode directory and running cctools, and now I have to figure out how to get it sorted out again, short of re-installing my operating system.
Yours, Kevan
Dear GPC Users,
I think I have it all sorted now. It turns out that cctools installs eighteen files in /usr/bin. Among these are "ld" that takes precedence over the XCode2.5 "ld" if /usr/bin comes first in your directory search path.
Searching the likely directories on my hard drive with "ls -R | grep crt1.o" I find no crt1.o installed except in the Xcode2.5 directory tree. This leads me to conclude that cctools may install "ld" and "as" but they do not install the "crt1.o" library required by GPC to make an executable. So installing Xcode appears to be necessary on MacOSX10.5.
Of the eighteen files installed by cctools in /usr/bin, sixteen are available in /Xcode2.5/usr/bin/. Only "lipo" and "strings" are unique to /usr/bin. I deleted the uneccessary 16, leaving "lipo" and "strings". The pre-cctools version of these files are no longer available to me. But I built a universal binary with "lipo" and it seems to work.
After this removing the sixteen duplicate files from /usr/bin, my compile works fine with the library search directive that Adriaan suggested:
-Wl,-syslibroot,/Xcode2.5/SDKs/MacOSX10.4u.sdk/
and I can even add the convenient:
-mmacosx-version-min=10.4
which is the flag that the cctools "ld" would not accept.
As to uninstalling XCode2.5, just deleting the XCode2.5 folder does not remove the devtools files in the main UNIX file structure, so you have to run XCode2.5/Library/uninstall-devtools, which gets rid of everything. After that, you can re-install XCode2.5. But it still gives me no UNIX Tools option.
Yours, Kevan
On 15 Sep 2011, at 17:34, Kevan Hashemi wrote:
As to uninstalling XCode2.5, just deleting the XCode2.5 folder does not remove the devtools files in the main UNIX file structure, so you have to run XCode2.5/Library/uninstall-devtools, which gets rid of everything. After that, you can re-install XCode2.5. But it still gives me no UNIX Tools option.
I guess you are installing it on Mac OS X 10.5. There you can only globally install the Unix tools of Xcode 3.x.
Jonas
Kevan Hashemi wrote:
Last night I tried to solve my problem by running cctools-576 from your website. After that, my linker does not recognise the -mmacosx-version-min=10.4 option, despite removing and re-installing XCode 2.5. Where does this cctools come from? I Googled it, but am finding unrelated tools of the same name.
The cctools-576 are an older version of cctools, that work around a problem in Xcode/Projectbuilder 1. My website says
Unless you have installled Xcode 2.x or 3.x, you have to update Apple's Mac OS X assembler and linker (cctools-576). Click here to download sources (1.4 MB) and binaries (1.7 MB).
So, forget about them for Xcode 2, 3 or 4.
In theory, can I run cctools-576 then run gpc, and so avoid installing XCode all-together?
Although they install a linker and assembler, some extra files are needed to assemble and link with success. It is rather clumsy to have to install all of Xcode for just those few files, but I can't help it, that's Apple politics.
Regards,
Adriaan van Os