views:

908

answers:

2

Hi,

I am trying to port a windows application based on WxWidgets 2.8.9 to MacOS X. I've gotten to the point where everything compiles successfully, except from a few missing symbols related to WxWidgets. I've tried compiling WxWidgets with the command line and with XCode and I've tried several different configuration options, but none of this has worked properly. The WxWidgets Wiki has a few articles about this here, but most of the information is outdated and none of it solved my problem.

The closest I got was by compiling WxWidgets at the command line with

./configure --enable-monolithic
make

Then I linked the library by adding "wxMac-2.8.9/lib/libwx_mac-2.8.a" to the "Other Linker Flags" in my XCode project settings.

But this gives me the following linking errors:

"wxOnAssert(char const*, int, char const*, char const*, char const*)", referenced from: wxStringBase::wxStringBase(wxStringBase const&)in MyFrame.o wxCloseEvent::Veto(bool) in MyFrame.o wxStringBase::wxStringBase(wxStringBase const&)in TGameSettingsForm.o wxCheckBoxBase::DoSet3StateValue(wxCheckBoxState) in TGameSettingsForm.o wxCheckBoxBase::DoGet3StateValue() const in TGameSettingsForm.o wxStringBase::wxStringBase(wxStringBase const&)in NonoGameStates.o wxStringBase::wxStringBase(wxStringBase const&)in TWxInvalidRegCodeForm.o

"_iconv_close", referenced from: wxMBConv_iconv::~wxMBConv_iconv()in libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::~wxMBConv_iconv()in libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::~wxMBConv_iconv()in libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::~wxMBConv_iconv()in libwx_mac-2.8.a(monolib_strconv.o)

"wxAppConsole::OnAssert(char const*, int, char const*, char const*)", referenced from: vtable for CMyWxApp3_wxstaticAppin MyWxApp3-wxstaticApp.o

"_iconv", referenced from: wxMBConv_iconv::GetMBNulLen() const in libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::wxMBConv_iconv(char const*)in libwx_mac-2.8.a(monolib_strconv.o)

"wxAppConsole::OnAssertFailure(char const*, int, char const*, char const*, char const*)", referenced from: vtable for CMyWxApp3_wxstaticAppin MyWxApp3-wxstaticApp.o "_iconv_open", referenced from: wxMBConv_iconv::wxMBConv_iconv(char const*)in libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::wxMBConv_iconv(char const*)in libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::wxMBConv_iconv(char const*)in libwx_mac-2.8.a(monolib_strconv.o) wxMBConv_iconv::wxMBConv_iconv(char const*)in libwx_mac-2.8.a(monolib_strconv.o) ld: symbol(s) not found collect2: ld returned 1 exit status

If possible, I would prefer dynamic linking, not static linking as used above. However, for the moment I would be happy to get it running at all. If anyone could give me (or point me to) a working step-by-step description on how to compile and link the WxWidgets library, I would be very thankful.

Thanks,

Adrian

+1  A: 

I've not built wx under MacOS, but I do use it extensively under Windows and Linux. The instructions on the page you linked look very similar to those under Linux and it says:

Following make, you will find the built library under your folder (eg, build-release). This is also where the corresponding wx-config is.

The wx-config script under Linux makes building projects a breeze, you simply use the command wx-config --cxxflags to get the compilation flags required for gcc and wx-config --libs to get all of the required libraries for linking. Under build environments such as Code::Blocks you can use those commands in the project settings, however I am not familiar with XCode - but worst case you just need to copy the compiler and linker options that the wx-config script lists.

Dan
It does work after all, albeit only when I compile wxWidgets as dynamic lib. For some reason I still get missing symbols, despite using the wx-config script.
Adrian Grigore
A: 

wxOnAssert-related errors mean that you build your library in debug (__WXDEBUG__ defined, NDEBUG is not) while wxWidgets libraries were built in release build (__WXDEBUG__ not defined). The solution is simple: don't do this.

If you need to build a debug version, build wxWidgets in debug mode too using --enable-debug configure argument and use wx-config --debug ... to get the appropriate flags.

VZ