Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountered an error while building from source code on macOS 10.14 with Xcode 11.3.1 #57

Open
hao-lh opened this issue May 28, 2023 · 5 comments

Comments

@hao-lh
Copy link

hao-lh commented May 28, 2023

Building environment:
Xcode: Version 11.3.1 (11C505)
macOS Mojave 10.14.6 (18G9323)

Building details:

xcodebuild -target SwitchAudioSource
note: Using new build system
note: Planning build
note: Constructing build description
CreateBuildDirectory ~/Code/switchaudio-osx/build (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    builtin-create-build-directory ~/Code/switchaudio-osx/build

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources/Entitlements.plist (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources/Entitlements.plist

ProcessProductPackaging "" ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource.xcent (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx


Entitlements:

{
    "com.apple.security.get-task-allow" = 1;
}


    builtin-productPackagingUtility -entitlements -format xml -o ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource.xcent

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource.hmap (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource.hmap

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-project-headers.hmap (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-project-headers.hmap

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/all-product-headers.yaml (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/all-product-headers.yaml

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-own-target-headers.hmap (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-own-target-headers.hmap

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-generated-files.hmap (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-generated-files.hmap

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-all-target-headers.hmap (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-all-target-headers.hmap

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-all-non-framework-target-headers.hmap (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-all-non-framework-target-headers.hmap

CompileC ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/audio_switch.o ~/Code/switchaudio-osx/audio_switch.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -target x86_64-apple-macos10.6 -fmessage-length=179 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -std=c99 -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -iquote ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-generated-files.hmap -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-own-target-headers.hmap -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-all-target-headers.hmap -iquote ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-project-headers.hmap -I~/Code/switchaudio-osx/build/Release/include -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources-normal/x86_64 -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources/x86_64 -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources -F~/Code/switchaudio-osx/build/Release -MMD -MT dependencies -MF ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/audio_switch.d --serialize-diagnostics ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/audio_switch.dia -c ~/Code/switchaudio-osx/audio_switch.c -o ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/audio_switch.o
~/Code/switchaudio-osx/audio_switch.c:210:16: warning: enumeration value 'kAudioTypeUnknown' not handled in switch [-Wswitch]
        switch(typeRequested) {
               ^
~/Code/switchaudio-osx/audio_switch.c:210:16: note: add missing switch cases
        switch(typeRequested) {
               ^
~/Code/switchaudio-osx/audio_switch.c:286:43: warning: passing 'const char *' to parameter of type 'char *' discards qualifiers
      [-Wincompatible-pointer-types-discards-qualifiers]
        if (CFStringGetCString(deviceUID, deviceUID_string, maxSize, kCFStringEncodingUTF8)) {
                                          ^~~~~~~~~~~~~~~~
In file included from ~/Code/switchaudio-osx/audio_switch.c:30:
In file included from ~/Code/switchaudio-osx/audio_switch.h:33:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:49:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFCalendar.h:16:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFTimeZone.h:18:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:333:57: note:
      passing argument to parameter 'buffer' here
Boolean CFStringGetCString(CFStringRef theString, char *buffer, CFIndex bufferSize, CFStringEncoding encoding);
                                                        ^
~/Code/switchaudio-osx/audio_switch.c:417:113: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const void * _Nullable'
      [-Wint-conversion]
    OSStatus result = AudioObjectGetPropertyDataSize(deviceID, &propertyAddress, sizeof(AudioClassDescription), kAudioDevicePropertyScopeInput, &dataSize);
                                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ~/Code/switchaudio-osx/audio_switch.c:30:
In file included from ~/Code/switchaudio-osx/audio_switch.h:34:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h:18:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:263:69: note:
      passing argument to parameter 'inQualifierData' here
                                const void* __nullable              inQualifierData,
                                                                    ^
~/Code/switchaudio-osx/audio_switch.c:601:21: warning: comparison between pointer and integer ('AudioDeviceID' (aka 'unsigned int') and 'void *')
    if (newDeviceID != nil) {
        ~~~~~~~~~~~ ^  ~~~
~/Code/switchaudio-osx/audio_switch.c:612:21: warning: comparison between pointer and integer ('AudioDeviceID' (aka 'unsigned int') and 'void *')
    if (newDeviceID != nil) {
        ~~~~~~~~~~~ ^  ~~~
~/Code/switchaudio-osx/audio_switch.c:623:21: warning: comparison between pointer and integer ('AudioDeviceID' (aka 'unsigned int') and 'void *')
    if (newDeviceID != nil) {
        ~~~~~~~~~~~ ^  ~~~
~/Code/switchaudio-osx/audio_switch.c:703:12: warning: enumeration values 'kAudioTypeUnknown' and 'kAudioTypeAll' not handled in switch [-Wswitch]
    switch(typeRequested) {
           ^
~/Code/switchaudio-osx/audio_switch.c:703:12: note: add missing switch cases
    switch(typeRequested) {
           ^
~/Code/switchaudio-osx/audio_switch.c:718:23: error: use of undeclared identifier 'kAudioObjectPropertyElementMain'; did you mean 'kAudioObjectPropertyElementName'?
        .mElement   = kAudioObjectPropertyElementMain,
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                      kAudioObjectPropertyElementName
In file included from ~/Code/switchaudio-osx/audio_switch.c:30:
In file included from ~/Code/switchaudio-osx/audio_switch.h:34:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h:18:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardware.h:85:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/CoreAudio.framework/Headers/AudioHardwareBase.h:331:5: note:
      'kAudioObjectPropertyElementName' declared here
    kAudioObjectPropertyElementName         = 'lchn',
    ^
7 warnings and 1 error generated.

WriteAuxiliaryFile ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/SwitchAudioSource.LinkFileList (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    write-file ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/SwitchAudioSource.LinkFileList

CompileC ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/main.o ~/Code/switchaudio-osx/main.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'SwitchAudioSource' from project 'AudioSwitcher')
    cd ~/Code/switchaudio-osx
    export LANG=en_US.US-ASCII
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -target x86_64-apple-macos10.6 -fmessage-length=179 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -std=c99 -Wno-trigraphs -fpascal-strings -Os -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -g -fvisibility=hidden -Wno-sign-conversion -Winfinite-recursion -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wno-semicolon-before-method-body -iquote ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-generated-files.hmap -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-own-target-headers.hmap -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-all-target-headers.hmap -iquote ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/SwitchAudioSource-project-headers.hmap -I~/Code/switchaudio-osx/build/Release/include -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources-normal/x86_64 -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources/x86_64 -I~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/DerivedSources -F~/Code/switchaudio-osx/build/Release -MMD -MT dependencies -MF ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/main.d --serialize-diagnostics ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/main.dia -c ~/Code/switchaudio-osx/main.c -o ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/main.o

** BUILD FAILED **

The following build commands failed:
	CompileC ~/Code/switchaudio-osx/build/AudioSwitcher.build/Release/SwitchAudioSource.build/Objects-normal/x86_64/audio_switch.o ~/Code/switchaudio-osx/audio_switch.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
make: *** [build/Release/SwitchAudioSource] Error 65

I see there is a building error occurred from audio_switch.c:718:23: error: use of undeclared identifier 'kAudioObjectPropertyElementMain', could you help take a look?
Thanks.

@igorbernstein
Copy link

Looking at the apple docs that symbol was added in MacOS 12 (Monterey). Which is 3 versions newer than Mojave (10.14). So I suspect the quick answer is that switch audio-osx doesn't support your version of os x.

It might be possible to add backwards compatibility using older apis, but I think you are better off upgrading to a newer version of os x. (if your hardware is too old, take a look at oclp

@ryandesign
Copy link

But the readme suggests it should work on 10.7 and newer.

This is a command-line utility only and has no graphical user interface. Tested on OS 10.7 - 11.2.

@igorbernstein
Copy link

Hmm, maybe the readme is out of date? It looks like kAudioObjectPropertyElementMain symbol was added in 1.2.0. Can you build v 1.1.0?

@RobK88
Copy link

RobK88 commented Oct 15, 2023

Given that new symbols only found in macOS 12 Monterey are now being used, it looks like switchaudio-osx now only runs on macOS 12 Monterey and newer. This can be confirmed by looking at the status on MacPorts:

https://ports.macports.org/port/switchaudio-osx/details/

If this is the case, the readme.md file on the Github project page should be updated accordingly. Or the source code should be changed to support the 10.7 and later.

@RobK88
Copy link

RobK88 commented Oct 15, 2023

@igorbernstein -- I can confirm that v1.1.0 still builds and runs find on Lion Mac OS X 10.7.5 (and presumably on newer macOS releases such as Mojave).

But the versions 1.2.0 to 1.2.2 do not build. But I see a different build error on Lion than that reported for Mojave.

fatal error: 'CoreAudio/AudioHardwareBase.h' file not found
#include <CoreAudio/AudioHardwareBase.h>
         ^
1 error generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants