views:

303

answers:

1

I'm compiling a trivial wxWidgets app on MacOS X 10.6 with XCode 3.2

The linker is return an error about the symbol _main being defined twice:

  • once in main.mm
  • once in the test_app.cpp file.

After I commented out the macro:

Implement_App(TestApp)

The error went away, compiled & linked and I was able to run the application.

I haven't found this anywhere so any ideas about this?

+3  A: 

IMPLEMENT_APP is a macro used in wxWidgets to create an entry point to the program without worrying about whether the program will be compiled on Windows, Mac, *nix, or whatever. As a result of this, IMPLEMENT_APP has to define main (or its equivalent, such as WinMain).

You might find the IMPLEMENT_APP_NO_MAIN macro to be useful. Check the other IMPLEMENT_APP_XXX functions in wx/app.h, too.

This paragraph from the wxApp overview is a little helpful too:

Note the use of IMPLEMENT_APP(appClass), which allows wxWidgets to dynamically create an instance of the application object at the appropriate point in wxWidgets initialization. Previous versions of wxWidgets used to rely on the creation of a global application object, but this is no longer recommended, because required global initialization may not have been performed at application object construction time.

Mark Rushakoff
awesome,thanks, didn't know that
cbrulak