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

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.

Related

When compiled c function from different platforms and got symbols in difference with __kernel__

I tried to compile open source library nmap for the android platform.
In ubuntu, I used ndk tookchain to build libnetutil and get libnetutil.a.
With nm, I lookup symbol for fuction:
int mac_cache_get(const struct sockaddr_storage *ss, u8 *mac);
I got symbol _Z13mac_cache_getPK25__kernel_sockaddr_storagePh.
But on Mac, I use Android Studio to writed a simple android c++ demo and call the fuction mac_cache_get.
It will report undefined reference to mac_cache_get(sockaddr_storage const*, unsigned char*) link error.
With nm the .o file, it try to call the function with symbol:
_Z13mac_cache_getPK16sockaddr_storagePh.
So the symbol has littel difference with _Z13mac_cache_getPK25__kernel_sockaddr_storagePh and _Z13mac_cache_getPK16sockaddr_storagePh.
I don't know whether the difference cause the link error, if yes, how to fix the difference?
I made a mistake to use the compiler for linux platform which will generate the symbol with kernel prefix for sockaddr_storage parameter.
The compiler for android platform will generate the symbol without kernel prefix.
Thanks for all.

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 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.

Can't build streamer tutorial for android on mac

Can't build streamer tutorial_3 for android on mac
I,ve got all environment variables needed.
My eclipse can't to resolve some symbols, but to some of them i can get by pushing F3. It's very strange for me.
Here is the command line output:
23:04:06 **** Build of configuration Default for project Tutorial3 ****
/Users/antonivanuskin/android-develop/android-ndk-r10/ndk-build all
GStreamer : [GEN] => gst-build-armeabi/gstreamer_android.c
GStreamer : [COMPILE] => gst-build-armeabi/gstreamer_android.c
GStreamer : [LINK] => gst-build-armeabi/libgstreamer_android.so
lto1: fatal error: bytecode stream generated with LTO version 2.2 instead of the expected 3.0
compilation terminated.
lto-wrapper: /Users/antonivanuskin/android-develop/android-ndk-r10/toolchains/arm- linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-gcc returned 1 exit status
/Users/antonivanuskin/android-develop/android-ndk-r10/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.gold: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make: *** [buildsharedlibrary_armeabi] Error 1
23:04:10 Build Finished (took 3s.740ms)*
I use ndk-10r and gst-1.4.0.
I know that there is no interfaces/xoverlay in new streamer.
EDIT
I've built ok, but steel got underlines of many glib-types and GST-macross. Here is a screenshot:
what is interesting that i have no underlined headers, for example: i've include pthread.h but have got underlined pthread_t and phtread_key_t....
i think that i have not install some general libraries on my mac, something like libc or what ever...may it couse this problem? The problem is that i can't run my app from eclipse. and for more: i use DS-5 CE IDE
This is most likely because we build the android 1.4.x cerbero packages with the r9d NDK.
You might want to use the r9d NDK until we provide binaries built with a more recent NDK (started some builds to see if everything goes through fine).

Compiling for Android using Make on OSX

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

Categories

Resources