我正在尝试编译我的cocos2d-x项目,但是当我运行build_native.sh时出现此错误:
/Users/default/Documents/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: ./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/3rdParty/zlib-1.2.3/minigzip.o: multiple definition of 'main'
/Users/default/Documents/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/3rdParty/zlib-1.2.3/example.o: previous definition here
/Users/default/Documents/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: ./obj/local/armeabi/tiff.a(mkg3states.o): multiple definition of 'main'
/Users/default/Documents/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/3rdParty/zlib-1.2.3/example.o: previous definition here
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libgame.so] Error 1
make: Leaving directory //.....
我可以在没有zlib的情况下构建项目,但我需要它。
修改:
删除example.c后,我得到了这个:
/Users/default/Documents/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: ./obj/local/armeabi/tiff.a(mkg3states.o): multiple definition of 'main'
/Users/default/Documents/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/objs-debug/game_shared/__/__/Classes/3rdParty/zlib-1.2.3/minigzip.o: previous definition here
我可以从cocos2d中排除libtiff或我该如何解决这个问题?
答案 0 :(得分:1)
您的minigzip
和example
源代码文件都包含main()
函数。删除你不需要的那个。我猜它在example
。