LInker errors where there were none before


Graham Cox
 

Hi all,

I’m suddenly running into some linker errors against AudioToolbox on a project after upgrading Xcode and installing High Sierra (not sure which of these did it).

Undefined symbols for architecture x86_64:
"_AudioComponentFindNext", referenced from:
-[CCToneGenerator createToneUnit] in CCToneGenerator.o
"_AudioComponentInstanceDispose", referenced from:
-[CCToneGenerator dealloc] in CCToneGenerator.o
"_AudioComponentInstanceNew", referenced from:
-[CCToneGenerator createToneUnit] in CCToneGenerator.o
"_AudioOutputUnitStart", referenced from:
-[CCToneGenerator setEnabled:] in CCToneGenerator.o
"_AudioOutputUnitStop", referenced from:
-[CCToneGenerator stop] in CCToneGenerator.o
"_AudioUnitInitialize", referenced from:
-[CCToneGenerator setEnabled:] in CCToneGenerator.o
"_AudioUnitSetProperty", referenced from:
-[CCToneGenerator createToneUnit] in CCToneGenerator.o
"_AudioUnitUninitialize", referenced from:
-[CCToneGenerator stop] in CCToneGenerator.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m linking against AudioToolbox, the source code includes the headers and the ‘Jump to Definition’ finds the declaration in the header OK. The functions are not deprecated and the project built just fine last time I tried it (which was some months ago on a different Xcode/OS version). When building the project, Xcode did not prompt to update any build settings as it usually does after an update.

Any ideas what could be causing this?


—Graham


Alex Zavatone
 

Which version of Xcode?

I haven’t had problems with Xcode 9.0, but 9.0.1 was released and some people are reporting various errors.

Are you using 9.0 or 9.0.1?

On Oct 24, 2017, at 5:19 PM, Graham Cox <graham@...> wrote:

Hi all,

I’m suddenly running into some linker errors against AudioToolbox on a project after upgrading Xcode and installing High Sierra (not sure which of these did it).

Undefined symbols for architecture x86_64:
"_AudioComponentFindNext", referenced from:
-[CCToneGenerator createToneUnit] in CCToneGenerator.o
"_AudioComponentInstanceDispose", referenced from:
-[CCToneGenerator dealloc] in CCToneGenerator.o
"_AudioComponentInstanceNew", referenced from:
-[CCToneGenerator createToneUnit] in CCToneGenerator.o
"_AudioOutputUnitStart", referenced from:
-[CCToneGenerator setEnabled:] in CCToneGenerator.o
"_AudioOutputUnitStop", referenced from:
-[CCToneGenerator stop] in CCToneGenerator.o
"_AudioUnitInitialize", referenced from:
-[CCToneGenerator setEnabled:] in CCToneGenerator.o
"_AudioUnitSetProperty", referenced from:
-[CCToneGenerator createToneUnit] in CCToneGenerator.o
"_AudioUnitUninitialize", referenced from:
-[CCToneGenerator stop] in CCToneGenerator.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m linking against AudioToolbox, the source code includes the headers and the ‘Jump to Definition’ finds the declaration in the header OK. The functions are not deprecated and the project built just fine last time I tried it (which was some months ago on a different Xcode/OS version). When building the project, Xcode did not prompt to update any build settings as it usually does after an update.

Any ideas what could be causing this?


—Graham





Graham Cox
 

I’m using 8.3.3 ;)

Yes, that was an update! Maybe I should try 9, but somehow an issue like this doesn’t quite seem like an Xcode problem.

—Graham

On 25 Oct 2017, at 9:30 am, Alex Zavatone <zav@...> wrote:

Which version of Xcode?

I haven’t had problems with Xcode 9.0, but 9.0.1 was released and some people are reporting various errors.

Are you using 9.0 or 9.0.1?


Alex Zavatone
 

It sounds like the one of a few things might help.

Look in your "link to binaries” build section to see if any binaries are added twice, or are missing.

Also, check to see in the build file phases that you’re not adding the .m file twice under Compile Sources.

I’ve seen Xcode return an error like this, but really, it was that there were two attempts to build the file with the same methods and it said that it couldn’t link, not that the same file was included twice in the compile process.

I’d check that before attempting to reinstall Xcode 8.3.3.


FYI, since we don’t know if High Sierra is part of the problem or not, this is why I always install major OS and Xcode upgrades to a clone of my working OS, or in a VM which is a clone of my working OS.

I went through issues with High Sierra and MacOS Server for High Sierra a few weeks back that only became apparent a day or so after I did the upgrade and started working with it that the upgrade sucked and removed the nice Git hosting option from MacOS Server.

Now, I have a 25 GB VM image of 10.12.6, Xcode 9.0 and Server 5.3 that I can duplicate, start up the cloned VM, upgrade and rename, work with it and see if it’s worth moving forward with the upgrade without destabilizing my working environment.

If it sucks (it did) I can just throw the copy away, but I can keep the working image to duplicate again for the next set of upgrades.

Good luck.
Alex Zavatone

On Oct 24, 2017, at 6:22 PM, Graham Cox <graham@...> wrote:

I’m using 8.3.3 ;)

Yes, that was an update! Maybe I should try 9, but somehow an issue like this doesn’t quite seem like an Xcode problem.

—Graham



On 25 Oct 2017, at 9:30 am, Alex Zavatone <zav@...> wrote:

Which version of Xcode?

I haven’t had problems with Xcode 9.0, but 9.0.1 was released and some people are reporting various errors.

Are you using 9.0 or 9.0.1?



Graham Cox
 

All looks OK.

I’m going to try Xcode 9, just in case (grasping at straws perhaps). I did upgrade Xcode and the OS separately, but this particular project wasn’t recompiled until now.

—Graham

On 25 Oct 2017, at 10:45 am, Alex Zavatone <zav@...> wrote:

It sounds like the one of a few things might help.

Look in your "link to binaries” build section to see if any binaries are added twice, or are missing.

Also, check to see in the build file phases that you’re not adding the .m file twice under Compile Sources.

I’ve seen Xcode return an error like this, but really, it was that there were two attempts to build the file with the same methods and it said that it couldn’t link, not that the same file was included twice in the compile process.

I’d check that before attempting to reinstall Xcode 8.3.3.


Roland King
 

what I usually do to debug these things is pull the link line from the detailed build log, go to the same directory, run it by hand and ensure I see the same result.

Then I start hunting along the command line to ensure the AudioToolbox is really being linked and where it's coming from, then go and check the package to make sure it contains the symbols I need.

You might want (by hand) to also try then shuffling AudioToolbox later in the link line to see if you have a link order issue (CCToneGenerator linked after AudioToolbox). if you can get it going by hand, then go back to Xcode and see what you can do to make it generate a working link line.


On 25/10/2017 08:34, Graham Cox wrote:

All looks OK.

I’m going to try Xcode 9, just in case (grasping at straws perhaps). I did upgrade Xcode and the OS separately, but this particular project wasn’t recompiled until now.

—Graham





On 25 Oct 2017, at 10:45 am, Alex Zavatone <zav@...> wrote:

It sounds like the one of a few things might help.

Look in your "link to binaries” build section to see if any binaries are added twice, or are missing.

Also, check to see in the build file phases that you’re not adding the .m file twice under Compile Sources. 

I’ve seen Xcode return an error like this, but really, it was that there were two attempts to build the file with the same methods and it said that it couldn’t link, not that the same file was included twice in the compile process.

I’d check that before attempting to reinstall Xcode 8.3.3.





Graham Cox
 

Thanks,

I have managed to get it working, but the reason is something of a mystery.
Xcode 9 showed the same problem, so that wasn’t it. I created a new project and just added the CCToneGenerator class to it (which is where the calls to Audio Toolbox are made). It compiled, linked and worked fine.

I worked through the build settings for each to see what differed. The only one was deployment target - 10.8 for the failing build, 10.13 for the working one. Changing it to 10.13 compiled, linked and worked fine. The earliest deployment target that works is 10.10. This is the mystery - when I previously built this project it targeted 10.8 and that worked fine. The APIs in question are marked as being available from 10.6.

For this project, targeting 10.10 as a minimum is not a problem, but I can’t understand why it can’t target 10.8 as before.

Any ideas?

—Graham

On 25 Oct 2017, at 12:21 pm, Roland King <rols@...> wrote:

what I usually do to debug these things is pull the link line from the detailed build log, go to the same directory, run it by hand and ensure I see the same result.

Then I start hunting along the command line to ensure the AudioToolbox is really being linked and where it's coming from, then go and check the package to make sure it contains the symbols I need.

You might want (by hand) to also try then shuffling AudioToolbox later in the link line to see if you have a link order issue (CCToneGenerator linked after AudioToolbox). if you can get it going by hand, then go back to Xcode and see what you can do to make it generate a working link line.


Alex Zavatone
 

Did you try removing and re-adding the linked binary?

It could be that the changes required for the newer versions to work would not function because of an API change if you wanted it to work on 10.8. If you try setting it to 10.9, then 10.10 as you mentioned, it starts working at 10.10, so there was an API change that was triggered by something you changed recently and the API needed is not in the currently linked binary for the CGToneGenerator when you target earlier than 10.10.

Or at least Xcode thinks this.

Argh, man.

If it weren’t 1:15 AM, I’d offer to spool up a VM and test on 10.12.6 in Xcode 8.3.3 and 9 to see if I could see what it might be.

On Oct 24, 2017, at 10:17 PM, Graham Cox <graham@...> wrote:

Thanks,

I have managed to get it working, but the reason is something of a mystery.
Xcode 9 showed the same problem, so that wasn’t it. I created a new project and just added the CCToneGenerator class to it (which is where the calls to Audio Toolbox are made). It compiled, linked and worked fine.

I worked through the build settings for each to see what differed. The only one was deployment target - 10.8 for the failing build, 10.13 for the working one. Changing it to 10.13 compiled, linked and worked fine. The earliest deployment target that works is 10.10. This is the mystery - when I previously built this project it targeted 10.8 and that worked fine. The APIs in question are marked as being available from 10.6.

For this project, targeting 10.10 as a minimum is not a problem, but I can’t understand why it can’t target 10.8 as before.

Any ideas?

—Graham




On 25 Oct 2017, at 12:21 pm, Roland King <rols@...> wrote:

what I usually do to debug these things is pull the link line from the detailed build log, go to the same directory, run it by hand and ensure I see the same result.

Then I start hunting along the command line to ensure the AudioToolbox is really being linked and where it's coming from, then go and check the package to make sure it contains the symbols I need.

You might want (by hand) to also try then shuffling AudioToolbox later in the link line to see if you have a link order issue (CCToneGenerator linked after AudioToolbox). if you can get it going by hand, then go back to Xcode and see what you can do to make it generate a working link line.