views:

1450

answers:

1

Whenever I try to compile my iPhone app which i am porting I get linking errors. The app uses a scripting language called Squirrel (to read the level files, fine by the SDK, no user input). I have linked all the libraries including libsquirrel.a. What am I doing wrong? (App is SuperTux, source code at supertux.lethargik.org for computer version).

Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_12AmbientSoundEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_12ThunderstormEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_13DisplayEffectEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_14ScriptedObjectEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_4TextEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_4WindEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_6CameraEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_6CandleEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_6PlayerEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_7SSectorEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_7TileMapEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_8PlatformEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_9LevelTimeEb", referenced from: Line Location Tool:0: "__ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_9WillOWispEb", referenced from: Line Location Tool:0: "__ZN9Scripting25register_supertux_wrapperEP4SQVM", referenced from: Line Location Tool:0: __ZN9Scripting13expose_objectINS_12AmbientSoundEEEvP4SQVMiPT_RKSsb in ambient_sound.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_12ThunderstormEEEvP4SQVMiPT_RKSsb in thunderstorm-02078462.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_13DisplayEffectEEEvP4SQVMiPT_RKSsb in display_effect.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_14ScriptedObjectEEEvP4SQVMiPT_RKSsb in scripted_object.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_4TextEEEvP4SQVMiPT_RKSsb in text_object.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_4WindEEEvP4SQVMiPT_RKSsb in wind-9E10B675.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_6CameraEEEvP4SQVMiPT_RKSsb in camera-A3560D66.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_6CandleEEEvP4SQVMiPT_RKSsb in candle-06462D68.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_6PlayerEEEvP4SQVMiPT_RKSsb in player.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_7SSectorEEEvP4SQVMiPT_RKSsb in sector.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_7TileMapEEEvP4SQVMiPT_RKSsb in tilemap-8DC8046A.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_8PlatformEEEvP4SQVMiPT_RKSsb in platform-E187A570.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_9LevelTimeEEEvP4SQVMiPT_RKSsb in level_time-2C8E1157.o Line Location Tool:0: __ZN9Scripting13expose_objectINS_9WillOWispEEEvP4SQVMiPT_RKSsb in willowisp.o Line Location Tool:0: __ZN9Scripting13init_squirrelEb in squirrel_util.o Line Location Tool:0: collect2: ld returned 1 exit status Line Location Tool:0: symbol(s) not found

When I looked at the build output:

Ld "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator/SuperTux.app/SuperTux" normal i386 cd "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux" setenv MACOSX_DEPLOYMENT_TARGET 10.5 setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator" "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux" "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Library/Frameworks/SDL.framework/Headers" "-L/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Downloads/SQUIRREL2/lib" -L/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.1.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1 "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator" "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Library/Frameworks" "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Downloads" "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux" -F/Applications/SuperTux.app/Contents/Frameworks "-F/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/../../../Desktop/SDL2" -filelist "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/SuperTux.LinkFileList" -Wl,--no-demangle -mmacosx-version-min=10.5 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -framework SDL_image -framework Ogg -framework Vorbis -lSDLSimulator -lSDLiPhoneOS -framework SDL -framework OpenAL -lphysfsdevice "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/English.lproj/lphysfssimulator.a" -loggdevice -loggsim -lSDL_imagedevice -lSDL_imagesim -lvorbisdevice -lvorbisencdevice -lvorbisfiledevice -lvorbisencsim -lvorbisfilesim -lvorbissim -lminiswigdevice -lminiswigsim -lsqstdlib -framework SDL_mixer -framework SDL_image -lSDL_mixer -lSDL_mixersim -lstdc++-static -lstdc++ -lz -lSDLmain -framework CoreGraphics -framework CoreAudio -framework AudioToolbox -lsquirrelsim -lsquirreldevice -prebind -o "/Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/Debug-iphonesimulator/SuperTux.app/SuperTux" ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libSDLiPhoneOS.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libphysfsdevice.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/liboggdevice.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libSDL_imagedevice.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libvorbisdevice.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libvorbisencdevice.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libvorbisfiledevice.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libminiswigdevice.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libSDL_mixer.a, file is not of required architecture ld warning: in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libsquirreldevice.a, file is not of required architecture ld warning: __ZTVSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(stdexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o ld warning: __ZTISt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(stdexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o ld warning: __ZTSSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(stdexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o ld warning: __ZTISt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(functexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o ld warning: __ZTVSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(functexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o ld warning: __ZTSSt11range_error has different visibility (hidden) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/libstdc++-static.a(functexcept.o) and (default) in /Users/Thomas/Documents/iPhone Dev Projects./SuperTux/build/SuperTux.build/Debug-iphonesimulator/SuperTux.build/Objects-normal/i386/font.o

Something strange might be going on with libstdc++-static.a. Not even sure what it is.

+8  A: 

C++filt is your friend it will unmangle those names to show you what is missing:

> c++filt __ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_12AmbientSoundEb
Scripting::create_squirrel_instance(SQVM*, Scripting::AmbientSound*, bool)

The first line from above seems to indicate that it can't find the definition of the method create_squirrel_instace from the class Scripting.

So the order the libraries are presented to g++ (which is the compiler used on a mac) is important. So have a look at the build output and see if you can find the line where the libraries are linked:

It should look like this:

g++ <STUFF> -l<lib1> -l<lib2> etc.

I reformated the abovre output so it is readable: In the text I replace

/Users/Thomas/Documents/iPhone Dev Projects./SuperTux with <DIR> to help readability:

A whole bunch of the libraries are not being used becuase they are the wrong architecture:

ld warning: in <DIR>/SuperTux/libSDLiPhoneOS.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libphysfsdevice.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/liboggdevice.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libSDL_imagedevice.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libvorbisdevice.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libvorbisencdevice.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libvorbisfiledevice.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libminiswigdevice.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libSDL_mixer.a,
file is not of required architecture

ld warning: in <DIR>/SuperTux/libsquirreldevice.a,
file is not of required architecture

Then you also have some warning you should look at:

ld warning: __ZTVSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(stdexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o

ld warning: __ZTISt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(stdexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o

ld warning: __ZTSSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(stdexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o

ld warning: __ZTISt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(functexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o

ld warning: __ZTVSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(functexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o

ld warning: __ZTSSt11range_error
has different visibility
(hidden) in <DIR>/SuperTux/libstdc++-static.a(functexcept.o)
and (default) in <DIR>/SuperTux/build/SuperTux.build/Debug iphonesimulator/SuperTux.build/Objects-normal/i386/font.o
Martin York
i didn't know c++filt existed. that's excellent. it's unfortunate that link errors in Xcode don't already use it
Robert Karl
The unused libraries make sense; I built all the libraries twice - once for the device and once for the simulator. The strange warnings disappear once I delete libstdc++-static.a. Must have accidentely linked it. Thanks for all the help, by the way. The errors are still there.
Firestar