Compiling a wxGLCanvas app on OS X 10.3.9 Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
Xangis
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR
Contact:

Compiling a wxGLCanvas app on OS X 10.3.9

Post by Xangis » Sat Jul 22, 2006 8:55 pm

I have an application that builds on Windows and Linux without issue, but on OS X I get strange errors that I don't know how to resolve (I'm fairly new to MacOS, but not to wxWidgets).

Here are my errors:

Code: Select all

% make -f Makefile.mac
g++ -framework OpenGL -o GalaxyXangis -I/usr/local/include/wx-2.6/ bitmapfont.o commands.o font_base16x16.o font_base8x12.o gameclient.o maindlg.o MS3DFile.o network.o scenemanager.o sceneobject.o gamecanvas.o -L/System/Library/Frameworks/OpenGL.framework/Libraries `/usr/local/bin/wx-config --libs --gl-libs` -lm -lobjc -lstdc++
ld: MS3DFile.o illegal reference to symbol: std::_Rb_tree_rotate_left(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*&) defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib
ld: warning suggest use of -bind_at_load, as lazy binding may result in errors or different symbols being used
symbol _acosl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _tanl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _tanhl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _asinl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _atan2l used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _atanl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _ceill used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _coshl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _cosl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _expl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _floorl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _fmodl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _frexpl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _hypotl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _ldexpl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _log10l used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _logl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _modfl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _powl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _sinhl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _sinl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _sqrtl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
make: *** [GalaxyXangis] Error 1
So it appears that something is being linked wrong. Chances are I did something wrong in the makefile.

Here is the makefile:

Code: Select all

# Galaxy Xangis client makefile.  Requires wxWidgets.
# by default, wx-config from the PATH is used
WX_CONFIG := /usr/local/bin/wx-config

# Main executable file
PROGRAM = GalaxyXangis
FRAMEWORK = -framework OpenGL

# Directory containing library portions of code.
LIBDIR = /System/Library/Frameworks/OpenGL.framework/Libraries
INCLUDEDIR = /usr/local/include/wx-2.6/

# Object files
OBJECTS = bitmapfont.o commands.o font_base16x16.o font_base8x12.o gameclient.o maindlg.o MS3DFile.o network.o scenemanager.o sceneobject.o gamecanvas.o

CXX = $(shell $(WX_CONFIG) --cxx -g)

.SUFFIXES:      .o .cpp

.cpp.o :
        $(CXX) -g -c -Dmac -I$(INCLUDEDIR) `$(WX_CONFIG) --cxxflags --gl-libs` -o [email protected] $<

all:    $(PROGRAM)

$(PROGRAM):     $(OBJECTS)
        $(CXX) $(FRAMEWORK) -o $(PROGRAM) -I$(INCLUDEDIR) $(OBJECTS) -L$(LIBDIR) `$(WX_CONFIG) --libs --gl-libs` -lm -lobjc -lstdc++

clean: 
        rm -f *.o $(PROGRAM)
I'm hoping that this is just some newbie mistake and not a broken operating system. Any help would be appreciated.

The compiler I'm using is GCC 3.3 20030304, which I believe was installed as part of the XCode 1.5 install.

AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser » Mon Jul 24, 2006 6:57 am

i had a problem too, but now its fine, see this thread:

http://forums.wxwidgets.org/viewtopic.p ... highlight=

AUser
Knows some wx things
Knows some wx things
Posts: 38
Joined: Mon Jun 26, 2006 12:18 am

Post by AUser » Tue Jul 25, 2006 4:13 am

Actually now i look closer at your makefile, you have`$(WX_CONFIG) --cxxflags --gl-libs` in your .cpp.o line, this will generate -l(something) when making a .o file, which i believe to be incorrect.

You shouldn't be passing a -l to gcc unless it is linking. this shouldn't cause the error you describe though, it shold just say "linking argument not used as linking not done" or the like. Of course im not overly familiar with apples release of gcc, so this could be the cause.

Anyway as i said before i gave up o making my own makefiles, so i ended up modifying the one that i saw in that other thread.

Hope this helps somewhat.

Xangis
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR
Contact:

Post by Xangis » Tue Jul 25, 2006 4:40 am

The -l option you mention doesn't seem to have any ill effect. Thanks for the suggestion though.

I seem to be making progress inch by inch.

Apparently I need to link against a specific SDK in 10.3.9. This *almost* did the trick:

http://developer.apple.com/documentatio ... ion_2.html

However, it doesn't quite seem to work. It takes the -iysroot argument well enough, but I get:

Code: Select all

g++: unrecognized option `-syslibroot/Developer/SDKs/MacOSX10.3.0.sdk'
It seems as if 3.3 does not actually support the -syslibroot argument. Ouch.

Xangis
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR
Contact:

Post by Xangis » Tue Jul 25, 2006 5:00 am

Almost.

After actually READING THE SCREEN (an invaluable but oft-overlooked troubleshooting aid), I tried linking with the -bind_at_load argument.

It helped. I'm now down to a single error.

Code: Select all

==== Building executable ====
g++ -o Debug/GalaxyXangis.app/Contents/MacOS/GalaxyXangis MS3DFile.o bitmapfont.o commands.o font_base16x16.o font_base8x12.o gamecanvas.o gameclient.o maindlg.o network.o scenemanager.o sceneobject.o `/usr/local/bin/wx-config --inplace  --libs` -bind_at_load -isysroot/Developer/SDKs/MacOSX10.3.0.sdk -L/usr/lib/gcc/darwin/3.3 -lstdc++
ld: MS3DFile.o illegal reference to symbol: std::_Rb_tree_rotate_left(std::_Rb_tree_node_base*, std::_Rb_tree_node_base*&) defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib
make: *** [Debug/GalaxyXangis.app/Contents/MacOS/GalaxyXangis] Error 1
I also tried specifically pointing to the library I want by adding -L/usr/lib/gcc/darwin/3.3. It didn't seem to help, but I also don't know whether it's finding the libstdc++.6.dylib first in the library search path (is there an actual 'order of operations' for search paths in gcc?).

So close, yet so far... I feel like Tantalus.

Xangis
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR
Contact:

Post by Xangis » Tue Jul 25, 2006 5:26 am

So as far as my research tells me, it's QuickTime's fault as of 7.03 and since there's supposedly no way to downgrade 7.1.2 (although older versions were downgradeable), I pretty much have to reinstall my operating system but *NOT* patch it if I want to be able to build. Or change to 10.4. WTF?

I think swallowing a porcupine might be more fun than trying to build on OSX. Is it always this rough?

Xangis
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR
Contact:

Post by Xangis » Sun Jul 30, 2006 2:36 am

So I've managed to get the wxGLCanvas app to build on OSX 10.3.9. In the process I also learned that you can't fix MacOS by installing it over the top of itself like you can with Windows XP. Note to self: never update Quicktime.

Here are the compiler/linker flags I needed to add for wxGLCanvas in wxMac in case anyone might find them useful:

Code: Select all

LIBDIR=/System/Library/Frameworks/OpenGL.framework/Libraries
INCLUDEDIR=/usr/local/include/wx-2.6/
CPPFLAGS=-Dmac -I$(INCLUDEDIR) `$(WX_CONFIG) --inplace --cxxflags`
LDFLAGS=-L$(LIBDIR) `$(WX_CONFIG) --inplace --libs --gl-libs` -lGL -lGLU -lm -lobjc -lstdc++
I'm not sure all of the extra library flags are necessary, but -lGL -lGLU and the -framework are. With just the framework set but not the library flags I received missing symbol errors for _glBegin and _gluLookAt (I'm surprised wx-config --gl-libs didn't add those). I'm not sure whether the linker was just telling me about the first one, or whether it was just those two that it couldn't find (I use a ton of GL calls in my app).

It was a long road, but I'm finally able to build my OpenGL application on MacOS, Linux, Windows, and Solaris.

Post Reply