1

I am trying to integrate a library into an existing iOS product which requires -ObjC linker flag but this causes duplicate symbol _main error in another library (libSDL2.a). Anyone here knows how to deal with this error ? I tried using unexpected_symbol main to suppress the symbol from exporting but that didn't help.

Is modifying the source code of libSDL to comment out main() definition the only way possible ? I would like to avoid it if possible. Thanks AJ.

Alfred J
  • 21
  • 3
  • I meant -unexported_symbol linker flag not unexpected_symbol :) – Alfred J Aug 08 '17 at 10:15
  • I think one of your framework is already using same function. check here for solution https://stackoverflow.com/questions/24298144/duplicate-symbols-for-architecture-x86-64-under-xcode. or this: https://stackoverflow.com/questions/14369143/all-load-other-linker-flag-causing-duplicate-symbol-errors-in-3rd-party-framewo – Joshua Aug 08 '17 at 10:22
  • The problem you have is that the library to integrate and libSDL2.a implement the same method name. If you own one of those libraries just add a prefix at the beginning of the method so you know from which library it is. With this the problem should be gone. – Ivan Aug 08 '17 at 10:38
  • Joshua, I have seen these two threads and many more. I already know that there is a main function in libSDL2.a and one in my own files and I need the one I have. Problem is that -ObjC forces loading all the libraries. I can build fine without -ObjC flag but then I run into runtime exceptions. – Alfred J Aug 08 '17 at 10:40
  • Ivan, this is main function. Prefixing it won't help – Alfred J Aug 08 '17 at 10:40
  • @AlfredJ have you tried removing 'all_load' in other linker flags? – Joshua Aug 08 '17 at 10:44
  • Then it builds but I do need all_load/ObjC flag because otherwise I get those "selector not recognised" runtime exception. – Alfred J Aug 08 '17 at 10:53
  • Take a look into the linker output in the report navigator of Xcode. In the details it will show you the conflicting files. – clemens Aug 08 '17 at 11:28

0 Answers0