cocos2d-x: build_native.sh compile errors - android

I'm trying to build cocos2d-x hello world project using build_native.sh, it shows me some compile errors. it seems that NDK can't find cocos2d-x sources.first it says:
NDK_ROOT = /cygdrive/c/Android-NDK-r4/android-ndk-r4-crystax
COCOS2DX_ROOT = /cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/../..
APP_ROOT = /cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/..
APP_ANDROID_ROOT = /cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android
then:
Compile++ thumb: game_shared <= /cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/jni/hellocpp/main.cpp
In file included from /cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/jni/hellocpp/main.cpp:1:
/cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/jni/../../Classes/AppDelegate.h:4:27: error: CCApplication.h: No such file or directory
/cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/jni/hellocpp/main.cpp:2:44: error: platform/android/jni/JniHelper.h: No such file or directory
In file included from /cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/jni/hellocpp/main.cpp:6:
/cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/jni/../../Classes/HelloWorldScene.h:4:21: error: cocos2d.h: No such file or directory
and many more compile errors.
I used cocos2dx website tutorial, I'm using API 10(android 2.3.3) and windows 7 .
can anyone help me?

Try including <Cocos2d-x Root Folder>\cocos2dx\platform\ under Right Click->Properties->C\C++ general->path and symbols-> source folder -> Link Folder It is not able to find CCApplication.h file which could be found under <Cocos2d-x Root Folder>\cocos2dx\platform\android . Hope this helps.

COCOS2DX_ROOT = /cygdrive/c/cocos2d-x/cocos2d-cocos2d-x-6e84662/firstapp/proj.android/../.. make sure that cocos2dx files are available at that location.

Try including Cocos2dx folder in your Android.mk file, the error is telling that it cannot find the source file CCApplication.h which is in the cocos2dx folder.

first import the library of cocos2d-x in the eclicips
path of lib D:\cocos2d-x-2.2\cocos2dx\platform\android
then
Add the library of cocos2d-x in your project.

In buid_native.sh file, around line 55, there is $COCOS2DX_ROOT defined with default path like '../../../', which means it will search COCOS2D_ROOT just relative to its current directory. So have a look at that first.

Related

undefined reference to 'cocos2d::network::HttpClient::send(cocos2d::network::HttpRequest*)'

I'm developing a game that stores data on server in cocos2d-x 3.2 in eclipse c++ for android.
In .h file I include network file #include "network/HttpClient.h".
In .cpp file I wrote following code.
HttpRequest *request = new network::HttpRequest();
request->setUrl("My Url");
request->setResponseCallback(CC_CALLBACK_2(HelloWorld::onHttpRequestCompleted, this));
cocos2d::network::HttpClient::getInstance()->send(request);
But on cocos2d::network::HttpClient::getInstance()->send(request); generate undefined reference to 'cocos2d::network::HttpClient::send(cocos2d::network::HttpRequest*)' this error.
I search it on cocos forum too but i don't get solution of my error.
Thanx in advance.
Not sure if you're still interested in this but all you need to do is add the libnetwork.tbd to your project. For me I used XCode so I just goto Target and then to the Build Phases and add libnetwork.tbd in the "Link Binary with Libraries" section. Then I am able to import "network/HttpClient.h" and using namespace cocos2d::network.

How to set version-script file in CMakeLists.txt file of Android Studio

I have a ndk project in Android Studio, and I want to control the exported symbols by this way:
set (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=D:\ProjectFolder\export_symbols")
or
set (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=export_symbols")
This export_symbols file is put together with CMaleLists.txt.
The problem is that the compiler would report an error during link and complain that: 'error: no such file or directory'.
So the question is how can I tell the compiler where my export_symbols file is? Any suggestion is welcomed. Thanks.
Try to do next:
Find you add_library command. E.g.:
add_library( ${MY_LIBRARY_NAME} SHARED main.cpp )
And right after it add set_target_properties command:
set_target_properties( ${MY_LIBRARY_NAME} PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../your_version.script)
Here is short info about LINK_DEPENDS.
Solved by adding ${CMAKE_SOURCE_DIR} before the file name.
set (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--version-script=" ${CMAKE_SOURCE_DIR} "/export_symbols")

Cross compiling c program with openssl for Android

I am facing the following issue when trying to compile a c program using openssl for android x-86. I set up the environment variables as follows using the following script:
setenv-android.sh
After running the script I have the following environment.
./setenv-android_x86.sh
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
Error: FIPS_SIG does not specify incore module. Please edit this script.
ANDROID_NDK_ROOT: /opt/android-ndk-r9d-x86
ANDROID_ARCH: arch-x86
ANDROID_EABI: x86-4.6
ANDROID_API: android-18
ANDROID_SYSROOT: /opt/android-ndk-r9d-x86/platforms/android-18/arch-x86
ANDROID_TOOLCHAIN: /opt/android-ndk-r9d-x86/toolchains/x86-4.6/prebuilt/darwin-x86_64/bin
FIPS_SIG:
CROSS_COMPILE: i686-linux-android-
ANDROID_DEV: /opt/android-ndk-r9d-x86/platforms/android-18/arch-x86/usr
However when trying to compile with the following command I get the following error:
pwd
/opt/android-ndk-r9d-x86/bin
./i686-linux-android-gcc Test.c -o test -lcrypto
fatal error: openssl/conf.h: No such file or directory
When I locate for the openssl/conf.h I see the file is available in many places:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/openssl/conf.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/openssl/conf.h
/data/local/arm/ssl/include/openssl/conf.h
/data/local/ssl/include/openssl/conf.h
/openssl/include/openssl/conf.h
/openssl-1.0.1e/include/openssl/conf.h
/openssl-1.0.1g/include/openssl/conf.h
/opt/local/include/openssl/conf.h
/usr/include/openssl/conf.h
/usr/local/include/openssl/conf.h
/usr/local/ssl/android-14/include/openssl/conf.h
/usr/local/ssl/android-18/include/openssl/conf.h
/usr/local/ssl/android-18-x86/include/openssl/conf.h
/usr/local/ssl/include/openssl/conf.h
I think the proper path is this:
/usr/local/ssl/android-18-x86/include/openssl/conf.h
I tried with the -L option but with no luck.
-L/usr/local/ssl/android-18-x86/include/
Can anybody please explain how to setup the path properly to solve this issue. (finally there is no issue with the C code as it compiles properly with gcc)
You are compiling your code using the Android NDK, which creates a "virtual" compiling environment by placing everything you need to compile for android into the ${ANDROID_SYSROOT} directory.
Those directories you listed are outside that sysroot, and therefore are not available to the build system, hence the errors. You must install OpenSSL for Android and putting the resulting headers and binaries there. You might follow this guide to assist you in that.

Build errors while cross compile C source project with android standalone toolchain

I m trying to build old c code with android standalone tool chain and it keeps failing on
following error :
fatal error: ftw.h: No such file or directory
Not sure how to include these headers from android.
Thanks,
ftw.h is included in android-21 platform (ndk 10c):
MBA-Anton:android-ndk-r10c asmirnov$ find /softdev/android-ndk-r10c -name "ftw.h"
/softdev/android-ndk-r10c/platforms/android-21/arch-arm/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-arm64/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-mips/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-mips64/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-x86/usr/include/ftw.h
/softdev/android-ndk-r10c/platforms/android-21/arch-x86_64/usr/include/ftw.h
This was an old message, but as I am on a similar ftw-hunt today: as of my writing this, ftw.h does not exist in contemporary android ndk include dirs.
Here are external links to source code for ftw* which may be useful:
http://www.opensource.apple.com/source/ksh/ksh-4/ksh/src/lib/libast/comp/ftw.c
http://www.opensource.apple.com/source/ksh/ksh-4/ksh/src/lib/libast/comp/ftw.h
Also, ftwalk.c is located as above but libast/misc/ftwalk.c (stackoverflow will not let me post a third link cause I'm a newb).

search.h-No such file or directory while porting libtiff on Android-tiff 4.0.1

I am trying to port libtiff on Android. The source version I am using is tiff 4.0.1.
I am building this source inside u1 android OS.
I am getting the below error when I run mmm external/tiff 4.0.1/
In file included from external/tiff-4.0.1/libtiff/tiffiop.h:33,
from external/tiff-4.0.1/libtiff/tif_dirread.c:42:
external/tiff-4.0.1/libtiff/tif_config.h:93:1: warning: "HAVE_MALLOC_H" redefined
In file included from <command-line>:0:
./system/core/include/arch/linux-arm/AndroidConfig.h:221:1: warning: this is the location of the previous definition
In file included from external/tiff-4.0.1/libtiff/tif_dirread.c:42:
external/tiff-4.0.1/libtiff/tiffiop.h:54:21: error: search.h: No such file or directory
I tries searching a lot on internet but could not get the issue.
Can any one provide me just an approx idea what could be wrong or which package is missing.
I resolved this issue finally. I hope this will help someone who is doing this work in future. We just need to remove the lines from libtiff/tiffiop.h where header file is being referenced.That worked for me.
Depending on your libtiff version, you can also just undefine HAVE_SEARCH_H in the config file tif_config.h which will then no longer include <search.h>:
In tif_config.h:
#ifndef ANDROID
/* Define to 1 if you have the <search.h> header file. */
#define HAVE_SEARCH_H 1
#endif

Categories

Resources