Log in or register to post comments

JNI - vector.h

January 2, 2013 - 1:21am #1

 

Hey,

i'm trying to use std::vecotr in the jni code

i understand i need to add this line APP_STL := stlport_static or APP_STL := stlport_sahred

but all i'm getting is lots of ndk errors when building 

just wondered if anyone was able to use the std::vector class using jni

 

thanks

 

JNI - vector.h

March 27, 2013 - 4:02am #12

Normally yes.

Have you added to application.mk the following line:

APP_STL := stlport_static

?

JNI - vector.h

March 27, 2013 - 3:31am #11

how about ndk-r8d ? ist the same for 

#include<vector> ?

because when i build it , says that

no such file or directory

JNI - vector.h

January 27, 2013 - 1:47pm #10

Hi jesterjazzy,

if it works fine using ndk-build, then the issue is likely with some Eclipse configuration settings for C++;

so, not sure how much I can help further in this case; also, the error sounds pretty general and STL related, so I guess other folks using JNI and C++ (but not necessarily using Vuforia) might have faced similar issues;

have you searched the internet for some discussion about this topic (std::string + Eclipse + error...) ?

 

 

JNI - vector.h

January 27, 2013 - 1:43am #9

Hi Allesandro, 

 

Altought it realy worked when building with ndk-build, 

 

when I try editing the file in eclipse I receive in my line : 

 

std::string test = ""; - Description Resource Path Location Type

Type 'std::string' could not be resolved , Semantic Error
 
I tried to add to the c++ paths  - C:\Android\android-ndk-r8c\sources\cxx-stl\gnu-libstdc++\4.6\include
 
nothing helped, it still makes the anoying error in eclipse (however when I compile with ndk-build, no errors, working fine )
 
Thanks...
 
 

You're welcome.

January 7, 2013 - 4:00am #8

You're welcome.

unbelievable

January 7, 2013 - 3:48am #7

works now.

much appreciate, thanks

 

Hi sagi, try putting this

January 7, 2013 - 3:43am #6

Hi sagi, try putting this line 

  #include <vector>

before all other includes (i.e. before #include "CloudReco.h")

and that should be OK.

 

r8b

January 7, 2013 - 2:16am #5

r8b

Hi, what version of the NDK

January 7, 2013 - 2:14am #4

Hi, what version of the NDK are you using ? (r8b or r8c, other)?

 

Not working

January 7, 2013 - 2:02am #3

Hey,

Thanks for the info

i tried again what you were saying

 

added to cloudreco.cpp - #include <vector>

added to application.mk - APP_STL := stlport_static

and got lots of ndk lib errors

 

really frustrating.. if u can help some how it will be much appreciated

 

thanks

 

the errors:

 

$ ndk-build
Compile++ arm    : CloudReco <= Transition3Dto2D.cpp
Compile++ arm    : CloudReco <= CloudReco.cpp
In file included from C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources                                                               /cxx-stl/stlport/stlport/stl/_algobase.h:46:0,
                 from C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources                                                               /cxx-stl/stlport/stlport/vector:33,
                 from C:/Work/EyeducationAndroid/VstoryBase_3.0/jni/CloudReco.cp                                                               p:17:
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources/cxx-stl/stlport/stlpo                                                               rt/stl/_cstdlib.h: In function 'long int abs(long int)':
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources/cxx-stl/stlport/stlpo                                                               rt/stl/_cstdlib.h:131:25: error: declaration of C function 'long int abs(long in                                                               t)' conflicts with
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/platforms/android-8/arch-arm/                                                               usr/include/../include/stdlib.h:83:23: error: previous declaration 'int abs(int)                                                               ' here
In file included from C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources                                                               /cxx-stl/stlport/stlport/stl/_algobase.h:46:0,
                 from C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources                                                               /cxx-stl/stlport/stlport/vector:33,
                 from C:/Work/EyeducationAndroid/VstoryBase_3.0/jni/CloudReco.cp                                                               p:17:
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources/cxx-stl/stlport/stlpo                                                               rt/stl/_cstdlib.h: In function 'ldiv_t div(long int, long int)':
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources/cxx-stl/stlport/stlpo                                                               rt/stl/_cstdlib.h:137:56: error: declaration of C function 'ldiv_t div(long int,                                                                long int)' conflicts with
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/platforms/android-8/arch-arm/                                                               usr/include/../include/stdlib.h:150:16: error: previous declaration 'div_t div(i                                                               nt, int)' here
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources/cxx-stl/stlport/stlpo                                                               rt/stl/_cstdlib.h: In function 'long long int abs(long long int)':
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources/cxx-stl/stlport/stlpo                                                               rt/stl/_cstdlib.h:151:48: error: declaration of C function 'long long int abs(lo                                                               ng long int)' conflicts with
C:/Android/android-ndk-r8b-windows/android-ndk-r8b/sources/cxx-stl/stlport/stlpo                                                               rt/stl/_cstdlib.h:131:13: error: previous declaration 'long int abs(long int)' h                                                               ere
 

Hi sagi, you should be able

January 2, 2013 - 2:44am #2

Hi sagi,

you should be able to use std::vector by simply adding APP_STL := stlport_static  to your Application.mk file

(note it MUST be added in Application.mk and NOT in Android.mk, just mentioning in case you did put it in the wrong file....)

 

I just verified that the following code works (I am using Android NDK r8b, if this can help):

#include <vector>

and somewhere in your ImageTargets.cpp code, add this:

 

    std::vector<int> ints;
    ints.push_back(1);
    ints.push_back(2);

Maybe could you try the same ?

Log in or register to post comments