Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Android undefined reference VS 2013 and Nvidia Nsight  (Read 10368 times)

0 Members and 2 Guests are viewing this topic.

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Android undefined reference VS 2013 and Nvidia Nsight
« on: November 04, 2015, 12:17:22 am »
I was trying to make and Android app that uses SFML.

I successfully create all the .so and .a


E:\Android\SFML-master>cmake -DANDROID_ABI=armeabi-v7a -DCMAKE_TOOLCHAIN_FILE=cm
ake/toolchains/android.toolchain.cmake -DANDROID_NDK=E:\Android\android-ndk-r10e

-- Building for: Visual Studio 12 2013
CMake Warning at CMakeLists.txt:97 (message):
  CMake might not properly support setting the STL.  Make sure to adjust all
  generated library projects!


-- Found JPEG: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libjpeg.a

-- Found OpenAL: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libopen
al.so
-- Found VORBIS: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libvorb
is.a
-- Found FLAC: E:/Android/SFML-master/extlibs/libs-android/armeabi-v7a/libFLAC.a

-- Configuring done
-- Generating done
-- Build files have been written to: E:/Android/SFML-master

E:\Android\SFML-master>

 

As you can see, all fine.

I import the sfml's default android example using ( import and ndk-build Android Project ) using the last version of Nvidia Nsight.

I had to change the original android.mk  ( and the application.mk too ) of the example (because don't work at least for me)

my android.mk:
LOCAL_PATH := $(call my-dir)

## sfml-activity ##

        include $(CLEAR_VARS)
                LOCAL_MODULE := sfml-activity-main
                LOCAL_SRC_FILES := libsfml-activity-d.so
        include $(PREBUILT_SHARED_LIBRARY)

## sfml-activity end ##

## sfml-system.so ##

        include $(CLEAR_VARS)
                LOCAL_MODULE := sfml-system
                LOCAL_SRC_FILES := libsfml-system-d.so
        include $(PREBUILT_SHARED_LIBRARY)

## sfml-system.so end ##

## sfml-window.so ##

        include $(CLEAR_VARS)
                LOCAL_MODULE := sfml-window
                LOCAL_SRC_FILES := libsfml-window-d.so
        include $(PREBUILT_SHARED_LIBRARY)
       
## sfml-window.so end ##

## sfml-graphics.so ##

        include $(CLEAR_VARS)
                LOCAL_MODULE := sfml-graphics
                LOCAL_SRC_FILES := libsfml-graphics-d.so
        include $(PREBUILT_SHARED_LIBRARY)
       
## sfml-graphics.so end ##

## sfml-audio.so ##

        include $(CLEAR_VARS)
                LOCAL_MODULE := sfml-audio
                LOCAL_SRC_FILES := libsfml-audio-d.so
        include $(PREBUILT_SHARED_LIBRARY)
       
## sfml-audio.so end ##

## sfml-network.so ##

        include $(CLEAR_VARS)
                LOCAL_MODULE := sfml-network
                LOCAL_SRC_FILES := libsfml-network-d.so
        include $(PREBUILT_SHARED_LIBRARY)
       
## sfml-network.so end ##


## sfml-main ##

        include $(CLEAR_VARS)
                LOCAL_MODULE := sfml-main
                LOCAL_SRC_FILES := libsfml-main-d.a
        include $(PREBUILT_STATIC_LIBRARY)

## sfml-main end ##

## sfml-example ##

    include $(CLEAR_VARS)
                LOCAL_MODULE    := sfml-example
                LOCAL_SRC_FILES := main.cpp
                LOCAL_SRC_FILES += String.cpp

                LOCAL_SHARED_LIBRARIES := sfml-system
                LOCAL_SHARED_LIBRARIES += sfml-window
                LOCAL_SHARED_LIBRARIES += sfml-graphics
                LOCAL_SHARED_LIBRARIES += sfml-audio
                LOCAL_SHARED_LIBRARIES += sfml-network
                LOCAL_STATIC_LIBRARIES := sfml-main
        include $(BUILD_SHARED_LIBRARY)

## sfml-example end ##

## sfml-activity ##

   include $(CLEAR_VARS)

        LOCAL_MODULE    := sfml-start

        LOCAL_SHARED_LIBRARIES := sfml-activity-main

        include $(BUILD_SHARED_LIBRARY)

## sfml-activity end ##
 

I get this undefined:
1>------ Build started: Project: test, Configuration: Debug Tegra-Android ------
1>  [armeabi-v7a] Gdbserver      : [arm-linux-androideabi-4.8] ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/gdbserver
1>  [armeabi-v7a] Gdbsetup       : ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/gdb.setup
1>  [armeabi-v7a] Install        : libsfml-start.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-start.so
1>  [armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
1>  [armeabi-v7a] Compile++ thumb: sfml-example <= String.cpp
1>  [armeabi-v7a] Install        : libsfml-activity-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-activity-d.so
1>  [armeabi-v7a] Install        : libsfml-system-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-system-d.so
1>  [armeabi-v7a] Install        : libsfml-window-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-window-d.so
1>  [armeabi-v7a] Install        : libsfml-graphics-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-graphics-d.so
1>  [armeabi-v7a] Install        : libsfml-audio-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-audio-d.so
1>  [armeabi-v7a] Install        : libsfml-network-d.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libsfml-network-d.so
1>  [armeabi-v7a] Install        : libc++_shared.so => ../../../prueba/test/test/Tegra-Android/Debug//libs/armeabi-v7a/libc++_shared.so
1>  [armeabi-v7a] SharedLibrary  : libsfml-example.so
1>E:\Android\prueba\test\test\jni\main.cpp(13): error :  error: undefined reference to 'sf::Texture::loadFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, sf::Rect<int> const&)'
1>E:\Android\prueba\test\test\jni\main.cpp(21): error :  error: undefined reference to 'sf::Music::openFromFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
1>  collect2.exe: error: ld returned 1 exit status
1>  make.exe: *** [../../../prueba/test/test/Tegra-Android/Debug//local/armeabi-v7a/libsfml-example.so] Error 1
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

I add to the jni path String.hpp for resolve the undefined Sf::String() symbol, if i add Music.hpp and Texture.hpp start asking for more and more include...

 As you can see i'm using debug libraries, but i tested in release ( i take care of don't mix them, i have both release/debug) even i tried with the stripped_libsfml-xxx.so that automatically generates NSight among the libsfml_xxx.so.

I try using esfml ( https://github.com/Sonkun/esfml ) i built fine but get the same linking symbols error.

 I had to change LOCAL_WHOLE_STATIC_LIBRARIES for LOCAL_STATIC_LIBRARIES , using the first one (like in the original example) give me more a lot of undefined.

I used ARMEABI-V7A for compiling all .so and .a and try to make the .apk (because i don't find the option inside NSight to try with ARMEABI ) seems that only support V7 , V8, x86 , x86_64.

The STL type is the default one (GNU libstdc++ Static)

I use the sfml's cmake toolchain, even i tried all using ""another"" toolchain (seems to make the same result , https://github.com/taka-no-me/android-cmake/blob/master/android.toolchain.cmake , i don't know is both are the same)

The minAndroidApi lvl i use is 14 ( in making all .so and .a and the .apk)
The target  and max are NotSpecified

Can someone help me?
I need to give more details?
« Last Edit: November 04, 2015, 12:19:26 am by DarkRoku »
I would like a spanish/latin community...
Problems building for Android? Look here

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #1 on: November 04, 2015, 02:59:31 pm »
I got it works.

i make build it with MinGw (using -G "MSYS Makefiles") i made for both armeabi / armeabi-v7a

I make a debug apk following this:


cd to the project path and update the project with:
android project update --path $PATH_TO_PROJECT --android-14

android-14 in my case, but you can use higher or lower.

execute ndk-build clean
execute ndk-build

execute ant debug

enjoy your apk.

And then i export the project inside NSight for VS 2013, i change the STL to libc++ shared

I someone wnat to provide more details ask me.
I would like a spanish/latin community...
Problems building for Android? Look here

cookie

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #2 on: December 28, 2015, 04:13:45 am »
Hey DarkRoku,
great that you solved the problem! I'm heading to the same problem right now, I've ben able to build the makefiles with MinGW and the MSYS generator. I also want to use Visual Studio. (but 2015 version, I don't think it makes a huge difference).

And in the next step I got stuck. :(

I run 'make' in the folder created by MinGW and it builds all the SFML library files to the 'lib' subfolder. Great, but what I have to do next? You said sth. about 'android update project --path <path/to/project>' but what exactly is the path to the project? Or what is here the project at all? :O I only can see the makefiles and stuff...

(btw. how do you managed to pass the '--android-14' parameter throug the update command? Isn't it this command: http://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject)

And all the 'ndk-build' commands have to run in the created android project, right?

Look forwad to hear from you  :)
gr8 work

cookie

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #3 on: December 28, 2015, 04:42:27 pm »

(btw. how do you managed to pass the '--android-14' parameter throug the update command? Isn't it this command: http://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject)



The path to the project is the path of the sfml android example (you can take it for a base project). sfml -> example -> android (this is the path)

A relative example on console, work on CMD and MSYS on windows:

cd c:/sfml/example/android
android project update --path c:/sfml/example/android --android-14
ndk-build clean
ndk-build
ant debug


In the first you change the directory to the folder containing jni,assets,bin etc...
the second line update the project to make it work with ant. (only need to run once unless you need to change the target)
the third line is optional, clean the project (only i do this for protocol)
the fourth and fifth line create the apk.

« Last Edit: December 28, 2015, 04:45:09 pm by DarkRoku »
I would like a spanish/latin community...
Problems building for Android? Look here

cookie

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #4 on: December 28, 2015, 09:41:43 pm »
Hey DarkRoku,
thank you very much! Updating the android project worked for me now!
Except that I have used a slightly different command:
android update project --path <absolute/path/to/sfml/android/example> --target 5
where '--target 5' stands for android-19.
The currently available targets can be seen with the following command:
android list targets

But when it cames to build the project I struggle a bit.
In the directory of the android example I type 'ndk-build' and it print's this:
Android NDK: jni/Android.mk: Cannot find module with tag 'sfml' in import path
It seems to me that the error's source is this line in the Android.mk:
$(call import-module,sfml)

So I googled and found out that I have to set NDK_MODULE_PATH enviroment variable to the parent path of the module.
Great, but what is the sfml module? It seems logical to me that it should be the path to the generated files with MSYS (or maybe the library files generated with make?)
But everytime I try another path it just prints the same error :(
I used forward slashes in the path.

And in all the makefiles is written sth. about shared librarys, does it mean I have to build sfml as shared library and not as static?

thx for your help :)
cookie

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #5 on: December 28, 2015, 10:28:10 pm »
The ndk search the module on the path $ndk/sources

The module is a folder, when you see in your Android.mk:
$(call import-module,sfml)
you are telling the ndk to search the module in this path:

$ndk/sources/module_name

in your case:

$ndk/sources/sfml


If you executed the command:
make && make install

make install
will install the module sfml in your $ndk/source path.

If the ndk can't find module sfml means that there is no folder named sfml in yours $ndk/source directory.

The module will contain an Android.mk file that will tell to the ndk who to link sfml with the libs you have built.
You don't need to worry about the module, all you need to type on the sfml installation is to execute.
make && make install
and sfml will do all the job for you. Thanks Laurent and others team's members.

The think about i'm thinking is that Android have support for openGL ES2.0 3.0 and 3.1, these versions allows shaders, in the current sfml build for android sfml don't allow shaders  :(
« Last Edit: December 28, 2015, 10:35:44 pm by DarkRoku »
I would like a spanish/latin community...
Problems building for Android? Look here

cookie

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #6 on: December 29, 2015, 12:05:37 am »
Hey DarkRoku,
thank you so much! You helped me skipping weeks of struggle already  ;D
But unfortunately there is another problem  :-\

I got it to load the sfml module from $NDK/sources. For that I had to modify the NDK_MODULE_PATH enviroment variable to %ANDROID_NDK%/sources where %ANDROID_NDK% is the NDK root path. Without this variable it doesn't work and outputs the same error.

So, with make && make install I have successfuly build sfml and it copied all over to $NDK/sources.

Next step was ndk-build. You said in the $NDK/sources/sfml directiry should be a Android.mk makefile? Well, after make install ther is no makefile. So building with ndk-build fails with the same import error as before. When I create an empty Android.mk makefile in there it will start compiling the main.cpp but it fails in the first line (#include <SFML/System.hpp>) as there is no such file. Seems ok because we haven't included the sfml sources with the empty makefile.
But where can we get the original makefile to include the sfml module?

And yeah, shaders would be nice :O

cookie

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #7 on: December 29, 2015, 01:28:47 am »
Well, the Android.mk must appear.

But i will upload my sfml folder inside the $ndk/sources

Inside you will enconter the Android.mk, includes,libs (for armeabi-v7a),etc.


link: http://s000.tinyupload.com/index.php?file_id=10478807811861178411

Hope it help you. ;)


PD: my sfml files are modified by me.

This means that if you use my .so the entry point is not main, is
int myCustomEntryPoint( int argc , char* argv[] , ANativeActivity* activity )

I did this for expose ANativeActivity pointer.
« Last Edit: December 29, 2015, 01:34:20 am by DarkRoku »
I would like a spanish/latin community...
Problems building for Android? Look here

cookie

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #8 on: December 29, 2015, 02:13:16 am »
THANK YOU man! It finally works  ;D

With your sfml folder does it compile and run on android  :)
Of course with the modification you have to change the main.cpp slightly:
#include <android/native_activity.h>
int myCustomEntryPoint( int argc , char* argv[] , ANativeActivity* activity )
{
    // ...
}
 

My own compiled and installed sfml package looks a bit different, but I will investigate and still try to build my own sfml :) But for now I use yours :)

thank you!

cookie

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Android undefined reference VS 2013 and Nvidia Nsight
« Reply #9 on: December 29, 2015, 02:53:29 am »
THANK YOU man! It finally works  ;D

For have help and give help we are here, we are a community.

Feel free to ask me at MP, i very interested on port my engine to android, but i have two obstacles.

LTBL system for sfml relies on shaders, hope SFML's futures versions bring it with openGL ES 2.0 or later.

And sfe::Movie, i missed a lot trying to port FFmpeg for android, but i know that is posible.
And there is no a good library apart from FFmpeg for encode/decode.
But later i will try videoView or mediaPlayer with JNI.

I succesfully port LuaJIT, Box2d (liquidfun google implementation). LTBL2 get compiled but dosen't work correctly because shaders lack AFAIK.
I would like a spanish/latin community...
Problems building for Android? Look here

 

anything