每当我尝试编译我移植的iPhone应用程序时,我都会遇到链接错误。该应用程序使用一种名为Squirrel的脚本语言(通过SDK读取级别文件,没有用户输入)。我链接了所有库,包括libsquirrel.a。我究竟做错了什么? (App是SuperTux,supertux.lethargik.org的源代码,用于计算机版)。
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
当我查看构建输出时:
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 <b>"/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"</b>
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
libstdc ++ - static.a可能会发生一些奇怪的事情。甚至不确定它是什么。
答案 0 :(得分:8)
C ++ filt是你的朋友,它将取消这些名称以显示缺少的内容:
> c++filt __ZN9Scripting24create_squirrel_instanceEP4SQVMPNS_12AmbientSoundEb
Scripting::create_squirrel_instance(SQVM*, Scripting::AmbientSound*, bool)
上面的第一行似乎表明它无法从类Scripting中找到方法create_squirrel_instace的定义。
因此库呈现给g ++(在mac上使用的编译器)的顺序非常重要。那么看一下构建输出,看看你是否能找到库链接的行:
它应该是这样的:
g++ <STUFF> -l<lib1> -l<lib2> etc.
我重新格式化了abovre输出,因此它是可读的: 在文中我替换
/Users/Thomas/Documents/iPhone Dev Projects./SuperTux
<DIR>
以提高可读性:
由于它们是错误的架构,所以没有使用大量的库:
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
然后您还应该注意一些警告:
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