Compiling for Android using Make on OSX - android

Fair warning I am somewhat new to GCC development.
I am currently trying to do a personal port of Box2D to android (tech arm). I create a standalone toolchain, export the following....
export PATH=/tmp/my-android-toolchain/bin:$PATH
export CC=arm-linux-androideabi-gcc
export CXX=arm-linux-androideabi-g++
Then I run Make, everything "seems" to be running fine, however, at the end I see...
/private/tmp/my-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: bin/Debug/libBox2D.a: no archive symbol table (run ranlib)
/private/tmp/my-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: obj/Debug/HelloWorld/Helloworld.o: in function main:../../HelloWorld/Helloworld.cpp:38: error: undefined reference to 'b2World::b2World(b2Vec2 const&)'
/private/tmp/my-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: obj/Debug/HelloWorld/Helloworld.o: in function main:../../HelloWorld/Helloworld.cpp:47: error: undefined reference to 'b2World::CreateBody(b2BodyDef const*)'
/private/tmp/my-toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: obj/Debug/HelloWorld/Helloworld.o: in function main:../../HelloWorld/Helloworld.cpp:53: error: undefined reference to 'b2PolygonShape::SetAsBox(float, float)'
If I open up a new terminal (essentially killing the exports) and delete the bin and obj folder everything compiles fine. A quick Google search suggests this could be related to it using the llvm compiler instead of GCC (although with my CC I think this less likely). There are the following instructions for llvm in the standalone toolchain doc...
If you wish, add --llvm-version=3.1 to also copy clang/llvm 3.1.
Should I add llvm? Is this an issue with bionic being different?
Thanks!

You are likely using the OSX version of ar. Can't tell for sure from you log. Try setting export AR=arm-linux-androideabi-ar

Related

Embarcadero RAD Delphi 10.3.3, cannot compile my app with Box2D library for 64-bits Android

Cannot compile my App for Android 64-bit with Delphi 10.3.3.
My App is using Box2D library.
While compile I get following errors:
[DCC Error] E2597 C:\Users\Public\Documents\Embarcadero\Studio\android-ndk-r17b\toolchains\aarch64-linux-android-4.9\prebuilt\windows\aarch64-linux-android\bin\ld.exe: cannot find -lFlatBox2D
C:\Users\Public\Documents\Embarcadero\Studio\android-ndk-r17b\toolchains\aarch64-linux-android-4.9\prebuilt\windows\aarch64-linux-android\bin\ld.exe: cannot find -lgnustl_static
Compilation for Android 32-bit of same App is successful.
Compilation of another my (simple) App for Android 64-bits works fine.
So, I realized, that problem is only with Box2D for Android 64-bits used in my App.
Then I also tested compilation of Box2D TestBed App that is coming with RAD (here ...\Embarcadero\Studio\20.0\Samples\Object Pascal\Multi-Device Samples\Physics\TestBed\) - the same issue - it is compiled successfully for Android 32-bits, but same error when I'm compiling TestBed for Android 64-bits!
Please help. Thousands of lines of code in my App already, and now it is full stop - can't build it for Android 64-bits [scared]
UPDATE1
Second error "cannot find -lgnustl_static" fixed by adding path C:\Users\Public\Documents\Embarcadero\Studio\android-ndk-r17b\sources\cxx-stl\gnu-libstdc++\4.9\libs\arm64-v8a into menu Tools->Options, then 'SDK Manager'->NDK->'Android SDK 25.2.5 64-bits'-> value for 'Delphi NDK Library path'.
However, the first problem 'cannot find -lFlatBox2D'still exists.
I found only 2 files of library libFlatBox2D.a on my computer, it is
C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\debug
C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android\release
Both paths I added to the same 'Delphi NDK Library path' at SDK Manager for Android 64bit.
However, now getting error message skipping incompatible libFlatBox2D.a when searching for -lFlatBox2D for each of these paths.
So the question now - where to find a compatible libFlatBox2D.a that required for Android 64bits?
UPDATE2:
Hm... and in following 2 android64 paths do not have any libFlatBox2D.a files.
C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android64\debug
C:\Program Files (x86)\Embarcadero\Studio\20.0\lib\android64\release
Does it mean, that 10.3.3 Delphi installation is missing 64-bits Box2D android library?
UPDATE3:
As answered by #Stefanos , now I have 64bit version of libFlatBox2D.a.
But now while compiling I receiving count of 1700 linker errors about Box2D names , all of them similar to below:
[DCC Error] E2597 C:\Users\Public\Documents\Embarcadero\Studio\20.0\Samples\Object Pascal\Multi-Device Samples\Physics\TestBed\Android64\Debug\Box2D.Common.o: In function `Box2d::Common::Create_b2Draw_delegate(System::DelphiInterface<Box2d::Common::Ib2Draw>)':
Box2D.Common:(.text._ZN5Box2d6Common22Create_b2Draw_delegateEN6System15DelphiInterfaceINS0_7Ib2DrawEEE[_ZN5Box2d6Common22Create_b2Draw_delegateEN6System15DelphiInterfaceINS0_7Ib2DrawEEE]+0x0): undefined reference to `Create_b2Draw_delegate'
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Samples\Object Pascal\Multi-Device Samples\Physics\TestBed\Android64\Debug\Box2D.Common.o: In function `Box2d::Common::Destroy_b2Draw_delegate(NativeUInt)':
Box2D.Common:(.text._ZN5Box2d6Common23Destroy_b2Draw_delegateE10NativeUInt[_ZN5Box2d6Common23Destroy_b2Draw_delegateE10NativeUInt]+0x0): undefined reference to `Destroy_b2Draw_delegate'
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Samples\Object Pascal\Multi-Device Samples\Physics\TestBed\Android64\Debug\Box2D.Common.o: In function `Box2d::Common::b2Version_Create()':
Box2D.Common:(.text._ZN5Box2d6Common16b2Version_CreateEv[_ZN5Box2d6Common16b2Version_CreateEv]+0x0): undefined reference to `b2Version_b2Version'
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Samples\Object Pascal\Multi-Device Samples\Physics\TestBed\Android64\Debug\Box2D.Common.o: In function `Box2d::Common::b2BlockAllocator_Create()':
Box2D.Common:(.text._ZN5Box2d6Common23b2BlockAllocator_CreateEv[_ZN5Box2d6Common23b2BlockAllocator_CreateEv]+0x0): undefined reference to `b2BlockAllocator_b2BlockAllocator_1'
C:\Users\Public\Documents\Embarcadero\Studio\20.0\Samples\Object Pascal\Multi-Device Samples\Physics\TestBed\Android64\Debug\Box2D.Common.o: In function `Box2d::Common::b2BlockAllocator_Destroy(NativeUInt)':
Box2D.Common:(.text._ZN5Box2d6Common24b2BlockAllocator_DestroyE10NativeUInt[_ZN5Box2d6Common24b2BlockAllocator_DestroyE10NativeUInt]+0x0): undefined reference to `b2BlockAllocator_dtor'
etc...etc...
UPDATE4: Current status
I'm looking now for original libFlatBox2D.a library file for Android 64-bits (Delphi 10.3.3). If anyone has it, please share it with me.
The above attempts were not successful. An 'original' 64bits libFlatBox2D.a is required, which is not in my installation of RAD 10.3.3...
UPDATE5:
Embarcadero QA created a ticket:
https://quality.embarcadero.com/browse/RSP-27762
Will wait from their solution.
You have to create a new Package with name FlatBox2D, add all FlatBox units from ..\studio\20.0\source\FlatBox2D and compile it for Android64.
I have created the package and compiled both debug and release versions for Android64 with Delphi 10.3.3. In the link below you will find the new package files and the Android64 folder where you can find the libFlatBox2D.a for Debug and Release. Just copy the .a file to the corresponding folder in ..\studio\20.0\lib\Android64.
You can always compile the package on your own by just copying the FlatBox2D.dpr and FlatBox2D.dproj files in ..\studio\20.0\source\FlatBox2D, load the dpr in Delphi and compile it for Android64...
Stefanos
FlatBox2D.zip

How to cross-compiling node C++ addon on armv7?

I have written a small node C++ addon. On Linux I could compile and use it (with the help of node-gyp). But now I'd like to test the addon on my phone(armv7), so I compile and link it with cross-compiler, libv8.so and libnode.so(arm architecture), then push it into phone.
But on adb shell I get the error info when using it:
node: symbol lookup error: /bitmap.node: undefined symbol:
_ZN6bitmap9ImageData4InitEN2v85LocalINS1_6ObjectEEE
which means bitmap::ImageData::Init(v8::Local<v8::Object>) cannot be found...
Why and how should I solve it? Thank you in advance!
I just set the appropriate CXX environment variables before invoking node-gyp -arch=arm ... and it works!

Linker error Android - ndk :undefined reference to `G_STATIC_ASSERT'

I am Building android project for arm64-v8 and I am using NDK-r10e.I have build build Libnice 0.13 using its dependency (Glib 2.35.8) and I have all the dependencies of Glib compiled(intl,iconv,ffi).
So I was successfull in building the static libraries of Glib and then using my glib libraries to build a Libnice static library .
Now I am using these static libraries to build my android project ,I am getting the following errors and i have no clue why its giving me this linker errors because at the time of building those libraries everything was fine for me.
libnice.a(pseudotcp.o): In function `pseudo_tcp_socket_get_type':
/Users/aagman/Desktop/LibNIce/libnic/Newlibnice/jni/files/agent/pseudotcp.c:78: undefined reference to `G_STATIC_ASSERT'
In function `nice_agent_get_type':
/Users/aagman/Desktop/LibNIce/libnic/Newlibnice/jni/files/agent/agent.c:85: undefined reference to `G_STATIC_ASSERT'
/Users/aagman/Desktop/LibNIce/libnic/Newlibnice/jni/files/agent/agent.c:85: undefined reference to `G_STATIC_ASSERT'
This error occur if the address of an "unsigned int" is passed for a 64 bit build, which would be okay for a 32 bit build but should be an unsigned long for 64 bit. Pass -m64 / -m32 on the command line to control the build target.

How to make Eclipse work with Gstreamer SDK?

I try to develop an Android app using Gstreamer. I use Fedora 20 with installed Eclipse with ADT and NDT, Android SDK and NDK, gstreamer SDK for Android. But something goes wrong, when I try to build tutorials.
Everything is OK, when I build NDK samples (like hello-jni), but building is not complited working with samples from gstreamer SDK (definitely it is android-tutorial-1 from [gstreamer sdk installation]/share/gst-sdk/tutorials/). Here is what i see in log:
13:13:10 **** Auto Build of configuration Default for project Tutorial1 ****
/home/staslatgttt/work/android-ndk-r10c/ndk-build all
GStreamer : [GEN] => gst-build/gstreamer_android.c
GStreamer : [COMPILE] => gst-build/gstreamer_android.c
GStreamer : [LINK] => gst-build/libgstreamer_android.so
/home/staslatgttt/work/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.gold: /home/staslatgttt/work/gstreamer-sdk-android-arm-debug-2013.6//lib/libgstreamer-0.10.a(libgstparse_la-lex.priv_gst_parse_yy.o): in function priv_gst_parse_yylex:lex.priv_gst_parse_yy.c:1598: error: undefined reference to '__srget'
/home/staslatgttt/work/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.gold: /home/staslatgttt/work/gstreamer-sdk-android-arm-debug-2013.6//lib/libglib-2.0.a(libcharset_la-localcharset.o): in function _g_locale_get_charset_aliases:localcharset.c:158: error: undefined reference to '__srget'
/home/staslatgttt/work/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.gold: /home/staslatgttt/work/gstreamer-sdk-android-arm-debug-2013.6//lib/libglib-2.0.a(libcharset_la-localcharset.o): in function _g_locale_get_charset_aliases:localcharset.c:167: error: undefined reference to '__srget'
/home/staslatgttt/work/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.gold: /home/staslatgttt/work/gstreamer-sdk-android-arm-debug-2013.6//lib/libintl.a(localcharset.o): in function locale_charset:./localcharset.c:195: error: undefined reference to '__srget'
/home/staslatgttt/work/android-ndk-r10c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.gold: /home/staslatgttt/work/gstreamer-sdk-android-arm-debug-2013.6//lib/libintl.a(log.o): in function __sputc:/home/slomo/Projects/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.7/include-fixed/stdio.h:376: error: undefined reference to '__swbuf'
collect2: ld returned 1 exit status
make: *** [buildsharedlibrary] Error 1
13:13:11 Build Finished (took 972ms)
I tried to surf Internet, but I didn't find useful explanation how to solve this problem. All I understood is that problem is connected to Gold Linker. Only on this site http://docs.gstreamer.com/display/GstSDK/Installing+for+Android+development is a small tip about problems with Gold Linker on Windows, but I use Linux! Anyway, if I wanted to solve this problem on Windows, "this project" link mentioned there is not avaliable.
Can anyone help me with this? I don't know, what I do wrong, but I really need to solve this problem.
The NDK r10c wasn't support till 11-10-2014.
"The Android binaries are now built with the r10c NDK and as such binary compatible again with all NDK and Android releases" - http://gstreamer.freedesktop.org/
Try it again with the latest NDK and GStreamer Android SDK.
I encountered the same error... Google removed __srget starting from NDKr10c (check their official site in other fixed bugs). Downgrade to r10b or below and it should work.

Error undefined reference in build muPDF for android (need help)

this is sample error in cygwin
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:111:
undefined reference to `fz_array_get'
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:112:
undefined reference to `fz_is_string'
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:115:
undefined reference to `fz_dict_put'
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:116:
undefined reference to `fz_drop_obj'
In pdf_nametree include fitz.h
actually I check the function fz_array_get in fitz.h already
I have no idea now
Can anybody point me to the right direction or give me a another way
thx
sasara
Looks like your %path% variable (DOS) was not correctly translated to the $PATH (Cygwin) variable....
You need to install both the Android SDK as well as the Android NDK. Then you need to add both <sdk-install-dir>\tools and <ndk-install-dir> to your %path% variable.
Also, you need Cygwin v1.7 or greater on Windows.
Then, look here: http://groups.google.com/group/android-ndk/msg/b385e47e1484c2d4 for 2 fixes which deal with bugs that occur for automatic conversion from DOS format path variables to Cygwin format path variables.

Categories

Resources