#1 2017-04-04 01:47:02

Hypernova^
Member

SDL2 link errors on Mac

Hey guys,
  Building Tesseract on Mac with GCC/clang fails on linking with the following:

Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
     (maybe you meant: _mainmenu, _SDL_main )
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [client] Error 1

I have googled extensively and found it has to do with SDL2 missing its macros for renaming Tesseract's main() and calling its own. However I've only really found solutions for IDEs such as XCode by including the .m file included with SDL2 (btw my SDL2 download did not contain am .m file). I've also found suggestions of hacking the SDL2 main headers but that didn't work properly either. I can build/run Tesseract fine using XCode. Any ideas how I can fix this issue?

Thanks!

Offline

#2 2017-04-04 20:08:52

chasester
Member

Re: SDL2 link errors on Mac

We found that in cube.h

#ifndef STANDALONE
  #ifdef __APPLE__
    #include "SDL2/SDL.h"
    #define GL_GLEXT_LEGACY
    #define __glext_h_
    #include <OpenGL/gl.h>
    //#define main SDL_main  // remove this
   #define SDL_MAIN_NEEDED //add this
  #else
    #include <SDL.h>
    #include <SDL_opengl.h>
  #endif
#endif

What we found that sdl does this same define if we declare SDL_MAIN_NEEDED (in SDL_MAIN.h ln 94-96). This seems to be a localization error (or pickeness) and only happens on clang with mac. This is the more proper way to declare this, and should fix this error on any os (though it only seems to happen on that version of mac). We will keep posted on any extra changes that may be os dependent.

chasester

Last edited by chasester (2017-04-04 20:11:40)

Offline

Board footer