Android.mk settings throws error

m9games
m9games
edited November 2013 in Native
Hi,

Thanks for all your help on the previous issue. I managed to get it working with your help. This time its a different issue that I am facing. I switched to a newer version of cocos2dx and suddenly I started getting the following errors just after compiling libgame.so:

proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libcurl/libs/armeabi/libcurl.a(sha256.o): previous definition here
proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libcurl/libs/armeabi/libcurl.a(sha512.o): previous definition here
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA256_Final'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA256_Init'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA256_Transform'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA256_Update'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA384_Final'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA384_Init'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA384_Update'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA512_Final'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA512_Init'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA512_Transform'
error: jni/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK/LoadBalancing-cpp/loadbalancing-cpp-prebuilt/../../Photon-cpp/photon-cpp-prebuilt/libphoton-cpp-static_debug_android_armeabi.a(sha2.o): multiple definition of 'SHA512_Update'
make: *** [obj/local/armeabi/libgame.so] Error 1

Ideally it should go to install the libgame.so after the compilation.

I am using the settings that you have mentioned in this thread: viewtopic.php?f=8&t=2788 and my makefile looks like this.

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := game_shared

LOCAL_MODULE_FILENAME := libgame

LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \...
...
...
... my classes list


LOCAL_PHOTON_ROOT := $(LOCAL_PATH)/../../../../../Photon-AndroidNDK_v3-2-3-1_Cloud_SDK

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes $(LOCAL_PHOTON_ROOT)/

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static

LOCAL_STATIC_LIBRARIES := loadbalancing-cpp-static-prebuilt photon-cpp-static-prebuilt common-cpp-static-prebuilt

include $(BUILD_SHARED_LIBRARY)

$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions)\

$(call import-add-path, $(LOCAL_PHOTON_ROOT)/LoadBalancing-cpp)
$(call import-add-path, $(LOCAL_PHOTON_ROOT)/LoadBalancing-cpp/loadbalancing-cpp-prebuilt)
$(call import-module,loadbalancing-cpp-prebuilt)

I understand that it finds multiple versions of few files, but I cant understand why.

Please help me understand...

Thanks in advance

Comments

  • Hi.
    Please see my answer in this thread:
    viewtopic.php?f=8&t=2976
    The libtool workaround should also work for android.
  • Hi Kaiserludi,

    Thanks for your suggestion. I tried merging the two lib files as you have mentioned. I put both the files in one common folder and tried running the command, but got this error:

    iMac-3:Lib merge root$ libtool -o merged.a libcurl.a libphoton-cpp-static_debug_android_armeabi.a
    libtool: file: libcurl.a(/) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(//) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(file.o/) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(timeval.o/) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(base64.o/) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(hostip.o/) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(progress.o/) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(formdata.o/) is not an object file (not allowed in a library)
    libtool: file: libcurl.a(cookie.o/) is not an object file (not allowed in a library)
    ...
    ...
    ...
    ...long list of files
    libtool: file: libphoton-cpp-static_debug_android_armeabi.a(/) is not an object file (not allowed in a library)
    libtool: file: libphoton-cpp-static_debug_android_armeabi.a(//) is not an object file (not allowed in a library)
    libtool: file: libphoton-cpp-static_debug_android_armeabi.a(EventData.o/) is not an object file (not allowed in a library)
    libtool: file: libphoton-cpp-static_debug_android_armeabi.a(bn_add.o/) is not an object file (not allowed in a library)
    libtool: file: libphoton-cpp-static_debug_android_armeabi.a(bn_asm.o/) is not an object file (not allowed in a library)
    libtool: file: libphoton-cpp-static_debug_android_armeabi.a(bn_ctx.o/) is not an object file (not allowed in a library)
    ...
    ...
    ...
    ...long list of files
    iMac-3:Lib merge root$

    Can you please identify the problem??

    Thanks...
  • Hi,

    I did some research and tried the following command which successfully gave me a merged library:

    ar crv merge.a lib1.a lib2.a

    The errors that I used to get earlier after compile have gone away, but now I am getting the following error:

    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.
    D:/Cocos2dx/android-ndk-r8e-windows-x86_64/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: error: D:/Cocos2dx/cocos2d-x-2.1.4/cocos2d-x-2.1.4/MyProject/proj.android/../../cocos2dx/platform/third_party/android/prebuilt/libcurl/libs/armeabi/libcurl.a: malformed archive header name at 8
    terminate called after throwing an instance of 'std::length_error'
    what(): basic_string::assign
    make: *** [obj/local/armeabi/libgame.so] Error 1
    make: Leaving directory `/cygdrive/d/Cocos2dx/cocos2d-x-2.1.4/cocos2d-x-2.1.4/MyProject/proj.android'

    Please help me understand!
  • Sorry. I hoped that that libtool workaround would just work out of the box without any issues.
    I don't think, that tracking down, why it's not working in this case, is worth the effort.

    I will just pm you a prerelease version of the client lib, that already contains a fix for the duplicate symbols.
  • Hi,

    I face the same problem. Would be possible please to get the same library or suggest a solution ?

    My env: eclipse , cocos2dx 2.1.4 , windows 8.

    Thank you.
  • Sure. Please check your PM inbox.
  • All good. Is working.

    Thank you,

    Bogdan
  • hi,

    i have the same problem.
    please to share the fixed library(or suggest other solution)
    (cocos2d-x 2.2.0, macosx, xcode 5/eclipse, iOS/Android)

    thx you.
  • Kaiserludi wrote:
    Sure. Please check your PM inbox.
    You, too :)
  • thank you.

    but iOS version library is not included.

    please to share the iOS version.
  • Just for the record: I have send you another pm.
  • Hi Kaiserludi,

    I'm still facing some problems getting my game going.

    I'm using your LoadBalancing example and in the joinRoomEventAction I'm trying to see if I need to start the game by getting the number of players in the currently joined room and comparing it against MAX_NUMBER of players like so:
    int noOfPlayers = mLoadBalancingClient.getCurrentlyJoinedRoom().getPlayers().getSize();

    if (noOfPlayers == MAX_NUMBER_OF_PLAYERS)
    {
    mOutputListener->writeLine(L"Game full");
    }

    The problem is on IOS the number is reported correctly but on android (on 2 devices) I get 2 players when I know only one is in the room (just the 'host').
    On android I'm using the fixed library that you gave me. Am I doing something wrong? How can I reliably check the number of players in the room. I also tried the ExitGames::Common::JVector<int>& playernrs vector that get passed to the method, and the getPlayerCount (which always return 0).

    And some additional questions:
    1. I want to limit the room to 2 players. I understand that in certain situations certain players might get in after I close the room. Can this situation occur even if I set the max number of players on a room?
    2. Do I need to take special measures to protect the appid when connecting to the cloud? Or setting that in the NetworkLogic constructor is enough.
    3. Is there a way to see if there are open games without retrieving the list of the rooms? I want a game to be created if there are none available or join a room if at least a player is waiting.

    Thank you,

    Bogdan
  • Hi bogdan.

    About the maxplayer difference between iOS and Android:
    Sorry, I will send you a bugfix for the Android AndroidNDK SDK.

    To your questions:
    1. No, there is no way someone can get in after you have closed the room. The only thing that can happen is that due to latency someone joins, while another clients request to the server to close that room is still on its way between client and server. Also there is no way that anyone can join if the maxnumber has been reached, before someone else leaves first.

    2. If you don't modify the source of the LoadBalancing lib to do otherwise, then it will send the authenticate operation encrypted and that operation is the only one that used the appID. If the server receives an encrypted message from a client and that messages needs a server response, then it will also respond to that message with an encrypted message.

    3. The default approach to achieve this would be to call opJoinRandomRoom() and if it returns an error "no match found", then you would fallback to creating a new room with opCreateRoom(). If you are not interested in the room lists, then you could set autojoinLobby to false before you call connect for the first time after you have created the client instance to avoid unneeded traffic that's caused by receiving the room lists (the list of open and visible rooms and updates to that list are broadcasted to every player that is in the lobby and that is also the only purpose of the lobby).