I am trying to set up BUILD rules for a third party library,
Juce. Juce has lots of dependencies; on MacOSX, those dependencies include Cocoa, CoreAudio, and several other frameworks.
I'm getting errors like this:
In file included from ThirdParty/Juce/lib/modules/juce_audio_devices/../juce_events/juce_events.h:29:
In file included from ThirdParty/Juce/lib/modules/juce_audio_devices/../juce_events/../juce_core/juce_core.h:137:
In file included from ThirdParty/Juce/lib/modules/juce_audio_devices/../juce_events/../juce_core/native/juce_BasicNativeHeaders.h:44:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:10:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSArray.h:5:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:10:1: error: expected unqualified-id
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:11:1: error: expected unqualified-id
@class Protocol;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:17:1: error: expected unqualified-id
@protocol NSCopying
^
The errors are because I'm not linking to Cocoa and Foundation (though it seems to be finding them?). How do I specify that I am using these frameworks in my build rule?
I've tried:
cc_library (
...
copts = [
"-framework Cocoa",
"-framework Foundation",
]
)
I've tried linkopts (instead of copts) with and without linkstatic.
The problem seems to be that it is trying to parse those headers and getting to Objective C code that it doesn't understand, perhaps linking to a built version of them is the right thing to do?
Looks like somebody wanted to know the same thing is me a while back, but the thread never really got off the ground.
https://groups.google.com/forum/#!topic/bazel-discuss/pMZJI3qR2_A
Any advice is greatly appreciated.
Thanks,
Chet