Android Source code build problem

2019-07-23 15:44发布

问题:

I've been going through the steps to build the Android Source code. After getting everything set up according to the instructions, I executed "make". The make process chugged along until the link where it ultimately failed with the following error:

Undefined symbols for architecture x86_64:
  "_main", referenced from:
      start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

The other thing of note is that the link is generating a number of warning similar to this:

ld: warning: ignoring file out/host/darwin-x86/obj/EXECUTABLES/emulator_intermediates/android/hw-kmsg.o, file was built for i386 which is not the architecture being linked (x86_64)

Can anyone help me with the solution to this?

Thanks, Craig

回答1:

Thanks dljava. Yes, Xcode 4.x is a problem, but not the only problem that I've found. I'm sorry I didn't come back and post some of my findings earlier. I've been locked down on something else.

Officially, the Android source build is only supported on Leopard, not Snow Leopard. Googling around you can find a number of posts about this and how people have gotten around it. The solution typically involved changing various makefiles and other settings. The one thing about those solutions are that many have become stale and no longer work. Some authors have updated their instructions, while others have not.

Additionally, the latest Xcode proved problematic as well. In general, my attempts to get the Android source built on my iOS dev machine with Snow Leopard and the latest XCode was like a never-ending frustrating game of whack-a-mole.

My solution was simply to use a Mac mini that wasn't being used at the moment as an Android source dev box. I did a clean install of Leopard on it. I installed the last version of the iPhone SDK + XCode that supported Leopard. I think that was for iOS 3.1.3. Then after following the instructions on the Android dev site for building the source, I was successful.

So I would suggest either what I did with a separate box, or if you are able to create a bootable partition on your box and install Leopard on it. That seems to be the way to do it with the least brain damage.

Good luck,

Craig



回答2:

Upgrading to Xcode 4.x is the cause, try uninstalling and reinstalling 3.x



回答3:

I have had better luck in compiling and extending CyanogenMod instead of using AOSP directly, and I'm building on Snow Leopard. There are instructions for a number of supported devices. Furthermore, Cyanogen seems to be following AOSP pretty closely, e.g. with the recent 2.3.4 support.

If you are building on the Mac for a device that is not officially supported by CyanogenMod, the Mac template is a good place to start.

Personally, I'm using homebrew rather than MacPorts, but that is a minor detail.

--Pekka Nikander



回答4:

I can definitely second dljava. It is XCode 4.2 what causes the probs. I made exactly the same steps on an iMac SnowLeopard 10.6.8, running XCode 3.2.6 and everything was fine...after having days of trouble on my MacBook with XCode 4.2