googlevr / gvr-ios-sdk

Google VR SDK for iOS
http://developers.google.com/vr/ios/
Other
645 stars 191 forks source link

Thousands of duplicate symbols in libGVRSDK.a #259

Closed cargath closed 7 years ago

cargath commented 7 years ago

After adding the framework i can't compile my project anymore. I get thousands of duplicate symbols during the linker phase, like

duplicate symbol __ZN6google8protobuf2io22LazyStringOutputStreamC1EPNS0_14ResultCallbackIPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEE in:
    /path/to/Frameworks/GVRSDK/Libraries/libGVRSDK.a(zero_copy_stream_impl_lite_a809880079c3d6afa0c6c0ccb3eaf596.o)
    /path/to/Frameworks/GVRSDK/Libraries/libGVRSDK.a(zero_copy_stream_impl_lite.o)

Any idea what i might be doing wrong?

edit btw, the problem persists, whether i use CocoaPods or try adding the SDK directly. I'm not using Unity though (like in the related issue #234).

sanjayc77 commented 7 years ago

Is it possible you are linking some other google library (in this case protobuf) along with GVRSDK? GVRSDK cocoapod dependencies are https://github.com/CocoaPods/Specs/blob/master/Specs/3/7/9/GVRSDK/1.60.0/GVRSDK.podspec.json#L5 Maybe there is a library that is not Cocoapod, but is pulling in some of these symbols.

berendo commented 7 years ago

After adding the framework i can't compile my project anymore. I get thousands of duplicate symbols during the linker phase, like

duplicate symbol __ZN6google8protobuf2io22LazyStringOutputStreamC1EPNS0_14ResultCallbackIPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEE in:
    /path/to/Frameworks/GVRSDK/Libraries/libGVRSDK.a(zero_copy_stream_impl_lite_a809880079c3d6afa0c6c0ccb3eaf596.o)
    /path/to/Frameworks/GVRSDK/Libraries/libGVRSDK.a(zero_copy_stream_impl_lite.o)

Ditto. Much like @cargath, I am not using Unity or any other Google libraries and, as the errors indicate clearly, both duplicate symbols are within the exact same libGVRSDK.a file itself.

berendo commented 7 years ago

I have a feeling this has to do with the addition of Bitcode support in 1.30 onward (#212). My project does not have Bitcode enabled (and cannot at this time due to an external vendor dependency) and I can integrate all versions of this project up to 1.10, but 1.30 onward result in the duplicate symbols.

Edited: No, the issue must not be Bitcode support, as according to the release notes, 1.10 was where Bitcode support was added. It looks like between 1.10 and 1.20 there was a library consolidation that took place (among other things, libGVRView_arm.a and libGVRView_x86.a which were separate in 1.10 became a single fat library called libGVRSDK.a), which somehow must have caused this issue. I can integrate 1.10 cleanly, but 1.20 (and beyond) have the duplicate symbol errors during linking.

sanjayc77 commented 7 years ago

If it is in libGVRSDK.a, we should see these in the example apps: Panorama, VideoWidgetDemo, etc.

berendo commented 7 years ago

If it is in libGVRSDK.a, we should see these in the example apps: Panorama, VideoWidgetDemo, etc.

The error message is pretty unambigious (that both instances of the conflicting symbol are within libGVRSDK.a) and I am not linking any other Google (or Unity) code. Note that there somehow are two "versions" of the same object file for each of the conflicting symbols (zero_copy_stream_impl_lite_a809880079c3d6afa0c6c0ccb3eaf596.o vs zero_copy_stream_impl_lite.o) and I am not sure what to make of that.

That said, I understand that if the answer was "obvious," in theory, example apps, continuous integration, etc. would catch this issue.

Also keep in mind that release 1.10 of the library integrates perfectly cleanly and works.

berendo commented 7 years ago

The error message is pretty unambigious (that both instances of the conflicting symbol are within libGVRSDK.a) and I am not linking any other Google (or Unity) code.

I re-verified that there's absolutely no other component beyond libGVRSDK.a in my project that defines these symbols.

sanjayc77 commented 7 years ago

The duplicate symbol referred to here is __ZN6google8protobuf2XXXXX, which I think is from GoogleToolboxForMac (https://github.com/CocoaPods/Specs/blob/master/Specs/3/7/9/GVRSDK/1.60.0/GVRSDK.podspec.json#L4) cocoapod dependency. Whats strange is that this is not included as part of libgvrsdk.a, instead Cocoapods should pull in the library containing the symbol. But you seem to have more than one of these (duplicate).

I still suspect these are coming from some other library.

berendo commented 7 years ago

I still suspect these are coming from some other library.

I assure you, it's not. Here's a "quick and dirty" search for that symbol anywhere within my project, after all submodules and CocoaPods have been initialized:

Berends-MacBook-Pro:... berend$ find . -type f -print0 | xargs -0 fgrep __ZN6google8protobuf2io22LazyStringOutputStreamC1EPNS0_14ResultCallbackIPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEEE
Binary file ./MysteryHouse/Pods/GVRSDK/Libraries/libGVRSDK.a matches

I wonder if Xcode versions might be at play here...

berendo commented 7 years ago

I wonder if Xcode versions might be at play here...

Upgraded to Xcode 8.3.2 (from Xcode 8.2.x) and the problem persists.

cargath commented 7 years ago

I finally got it to work by removing the -all_load linker flag that's been there since the inception of the project years ago (i then had a different issue with undefined symbols for architecture x86_64, but that's another story). Hope this helps people with similar issues.

nathanmartz commented 7 years ago

Glad you got it resolved!

berendo commented 7 years ago

I finally got it to work by removing the -all_load linker flag that's been there since the inception of the project years ago

Wow, I was in the exact same boat - I had -all_load as an historical relic going all the way back to Xcode 4.0 (see https://stackoverflow.com/questions/2567498/objective-c-categories-in-static-library/2615407#2615407 for some background and Apple's fix as of Xcode 4.2).

Thanks for closing the loop @cargath!

ghost commented 7 years ago

I am seeing this issue—I did not have -all_load in the linker flags for Debug or Release.

berendo commented 7 years ago

I am seeing this issue—I did not have -all_load in the linker flags for Debug or Release.

Can you paste the complete linker command from the Xcode build logs?

ghost commented 7 years ago

Sorry for the delay.

Some background, my application is built using React Native, using the react-native-360 plugin—this is what pulls in the SDK, from what I understand. Also installed is react-native-firebase, which may be part of the issue. Are these the relevant logs you mentioned?

MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_METACLASS_$_GTMLogNoFilter in:
    MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
    MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_CLASS_$_GTMLogMininumLevelFilter in:
    MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
    MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_METACLASS_$_GTMLogMininumLevelFilter in:
    MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f

a46fc1725083b13869753a.o)
    MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_CLASS_$_GTMLogMaximumLevelFilter in:
    MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
    MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_METACLASS_$_GTMLogMaximumLevelFilter in:
    MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
    MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_CLASS_$_GTMLogLevelFilter in:
    MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
    MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_METACLASS_$_GTMLogLevelFilter in:
    MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_IVAR_$_GTMLogStandardFormatter.dateFormatter_ in:
MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_IVAR_$_GTMLogger.filter_ in:
MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_IVAR_$_GTMLogger.writer_ in:

MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_IVAR_$_GTMLogStandardFormatter.pname_ in:
MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_IVAR_$_GTMLogStandardFormatter.pid_ in:
MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol _OBJC_IVAR_$_GTMLogLevelFilter.verboseLoggingEnabled_ in:
MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(GTMLogger_f7ebcf131f
a46fc1725083b13869753a.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libG
oogleToolboxForMac.a(GTMLogger.o)
duplicate symbol __ZN3fLI9FLAGS_novE in:
MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(vlog_is_on.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
duplicate symbol __ZN3fLI7FLAGS_vE in:
MyProject/ios/Pods/GVRSDK/GVRView/Libraries/libGVRView_x86.a(vlog_is_on.o)
MyProject/ios/build/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
ld: 197 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:

    Ld build/Build/Products/Debug-iphonesimulator/MyProject.app/MyProject normal x86_64
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/MyProject.app
An error was encountered processing the command (domain=LaunchServicesError, code=0):
The operation couldn’t be completed. (LaunchServicesError error 0.)
berendo commented 7 years ago

Some background, my application is built using React Native, using the react-native-360 plugin—this is what pulls in the SDK, from what I understand. Also installed is react-native-firebase, which may be part of the issue. Are these the relevant logs you mentioned?

Yeah, your issue is different than the one tracked in this issue (which is specific to duplicate symbols within just the libGVRSDK.a library itself). You may want to look at #163 and #234, which pertain to linking issues when multiple frameworks with various Google-linkages are used in a given project.

ghost commented 7 years ago

Ah ok, thanks for the suggestion, will check them out.

Tankerxyz commented 6 years ago

Any solution?