Problem statically linking libraries on OS X
Posted: Mon Jun 13, 2011 12:23 am
I have freetype2 and ftgl on my system through MacPorts. I assume that MacPorts compiled them for the architecture of my computer, an Intel-based iMac running OS X 10.6.7.
These are the Linker settings for the CodeLite project:
Append to global settings
Options: -mwindows;$(shell $(WX_TOOL) --debug=yes --libs --unicode=yes);-m32
Library Paths: /opt/local/lib
Libraries: libfreetype.a;libftgl.a;libz.a
All three libraries are in the /opt/local/lib directory.
When I try to build, I get the following errors:
ld: warning: ignoring file /opt/local/lib/libfreetype.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /opt/local/lib/libftgl.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"wxGLContext::SetCurrent()", referenced from:
gGraphWindow::OnPaint(wxPaintEvent&) in graphs_graph.o
"wxGLCanvas::SwapBuffers()", referenced from:
gGraphWindow::OnPaint(wxPaintEvent&) in graphs_graph.o
"wxGLCanvas::~wxGLCanvas()", referenced from:
gGraphWindow::~gGraphWindow()in graphs_graph.o
gGraphWindow::~gGraphWindow()in graphs_graph.o
gGraphWindow::~gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
...
"wxGLCanvas::wxGLCanvas(wxWindow*, wxGLContext const*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)", referenced from:
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
"FTPixmapFont::FTPixmapFont(char const*)", referenced from:
GraphInit() in graphs_graph.o
"FTTextureFont::FTTextureFont(char const*)", referenced from:
GraphInit() in graphs_graph.o
"wxGLContext::wxGLContext(__AGLPixelFormatRec*, wxGLCanvas*, wxPalette const&, wxGLContext const*)", referenced from:
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
"wxGLCanvas::Show(bool)", referenced from:
vtable for gGraphWindowin graphs_graph.o
"wxGLCanvas::MacSuperChangedPosition()", referenced from:
vtable for gGraphWindowin graphs_graph.o
"wxGLCanvas::MacTopLevelWindowChangedPosition()", referenced from:
vtable for gGraphWindowin graphs_graph.o
"wxGLCanvas::MacVisibilityChanged()", referenced from:
vtable for gGraphWindowin graphs_graph.o
"typeinfo for wxGLCanvas", referenced from:
typeinfo for gGraphWindowin graphs_graph.o
"wxGLCanvas::ms_classInfo", referenced from:
__static_initialization_and_destruction_0(int, int)in graphs_graph.o
"_iconv", referenced from:
wxMBConv_iconv::GetMBNulLen() const in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
(maybe you meant: wxMBConv_iconv::~wxMBConv_iconv(), wxMBConv_iconv::~wxMBConv_iconv(), wxMBConv_iconv::~wxMBConv_iconv(), vtable for wxMBConv_iconv, wxMBConv_iconv::wxMBConv_iconv(wchar_t const*), wxMBConv_iconv::wxMBConv_iconv(wchar_t const*), typeinfo name for wxMBConv_iconv, typeinfo for wxMBConv_iconv, wxMBConv_iconv::Clone() const , wxMBConv_iconv::GetMBNulLen() const , wxMBConv_iconv::ms_wcNeedsSwap , wxMBConv_iconv::IsOk() const , wxMBConv_iconv::ms_wcCharsetName , wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) const, wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) const, new_wxMBConv_iconv(wchar_t const*))
"_iconv_close", referenced from:
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
"_iconv_open", referenced from:
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make[1]: *** [Debug/SleepyHead.app/Contents/MacOS/SleepyHead] Error 1
make[1]: Leaving directory `/Users/Jimbo/sleepyhead/Projects/CodeLite/OSX'
make: *** [All] Error 2
make: Leaving directory `/Users/Jimbo/sleepyhead/Projects/CodeLite/OSX'
----------Build Ended----------
0 errors, 6 warnings, total time: 00:00:12 seconds
Odd that the messages say "0 errors" after so many problems.
Odd that the first two "ld:" warnings refer to .dylib files when I specified .a files.
The architecture references are odd, since MacPorts presumably built for my system.
What am I doing wrong? How do I fix it? This is driving me nuts!
These are the Linker settings for the CodeLite project:
Append to global settings
Options: -mwindows;$(shell $(WX_TOOL) --debug=yes --libs --unicode=yes);-m32
Library Paths: /opt/local/lib
Libraries: libfreetype.a;libftgl.a;libz.a
All three libraries are in the /opt/local/lib directory.
When I try to build, I get the following errors:
ld: warning: ignoring file /opt/local/lib/libfreetype.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /opt/local/lib/libftgl.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols for architecture i386:
"wxGLContext::SetCurrent()", referenced from:
gGraphWindow::OnPaint(wxPaintEvent&) in graphs_graph.o
"wxGLCanvas::SwapBuffers()", referenced from:
gGraphWindow::OnPaint(wxPaintEvent&) in graphs_graph.o
"wxGLCanvas::~wxGLCanvas()", referenced from:
gGraphWindow::~gGraphWindow()in graphs_graph.o
gGraphWindow::~gGraphWindow()in graphs_graph.o
gGraphWindow::~gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
...
"wxGLCanvas::wxGLCanvas(wxWindow*, wxGLContext const*, int, wxPoint const&, wxSize const&, long, wxString const&, int*, wxPalette const&)", referenced from:
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow()in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
"FTPixmapFont::FTPixmapFont(char const*)", referenced from:
GraphInit() in graphs_graph.o
"FTTextureFont::FTTextureFont(char const*)", referenced from:
GraphInit() in graphs_graph.o
"wxGLContext::wxGLContext(__AGLPixelFormatRec*, wxGLCanvas*, wxPalette const&, wxGLContext const*)", referenced from:
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
gGraphWindow::gGraphWindow(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long)in graphs_graph.o
"wxGLCanvas::Show(bool)", referenced from:
vtable for gGraphWindowin graphs_graph.o
"wxGLCanvas::MacSuperChangedPosition()", referenced from:
vtable for gGraphWindowin graphs_graph.o
"wxGLCanvas::MacTopLevelWindowChangedPosition()", referenced from:
vtable for gGraphWindowin graphs_graph.o
"wxGLCanvas::MacVisibilityChanged()", referenced from:
vtable for gGraphWindowin graphs_graph.o
"typeinfo for wxGLCanvas", referenced from:
typeinfo for gGraphWindowin graphs_graph.o
"wxGLCanvas::ms_classInfo", referenced from:
__static_initialization_and_destruction_0(int, int)in graphs_graph.o
"_iconv", referenced from:
wxMBConv_iconv::GetMBNulLen() const in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) constin libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
(maybe you meant: wxMBConv_iconv::~wxMBConv_iconv(), wxMBConv_iconv::~wxMBConv_iconv(), wxMBConv_iconv::~wxMBConv_iconv(), vtable for wxMBConv_iconv, wxMBConv_iconv::wxMBConv_iconv(wchar_t const*), wxMBConv_iconv::wxMBConv_iconv(wchar_t const*), typeinfo name for wxMBConv_iconv, typeinfo for wxMBConv_iconv, wxMBConv_iconv::Clone() const , wxMBConv_iconv::GetMBNulLen() const , wxMBConv_iconv::ms_wcNeedsSwap , wxMBConv_iconv::IsOk() const , wxMBConv_iconv::ms_wcCharsetName , wxMBConv_iconv::MB2WC(wchar_t*, char const*, unsigned long) const, wxMBConv_iconv::WC2MB(char*, wchar_t const*, unsigned long) const, new_wxMBConv_iconv(wchar_t const*))
"_iconv_close", referenced from:
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::~wxMBConv_iconv()in libwx_base_carbonud-2.8.a(baselib_strconv.o)
"_iconv_open", referenced from:
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
wxMBConv_iconv::wxMBConv_iconv(wchar_t const*)in libwx_base_carbonud-2.8.a(baselib_strconv.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
make[1]: *** [Debug/SleepyHead.app/Contents/MacOS/SleepyHead] Error 1
make[1]: Leaving directory `/Users/Jimbo/sleepyhead/Projects/CodeLite/OSX'
make: *** [All] Error 2
make: Leaving directory `/Users/Jimbo/sleepyhead/Projects/CodeLite/OSX'
----------Build Ended----------
0 errors, 6 warnings, total time: 00:00:12 seconds
Odd that the messages say "0 errors" after so many problems.
Odd that the first two "ld:" warnings refer to .dylib files when I specified .a files.
The architecture references are odd, since MacPorts presumably built for my system.
What am I doing wrong? How do I fix it? This is driving me nuts!