Ask Your Question
1

Invalid arguments for standard function calls

asked 2013-02-11 13:12:07 -0600

seismic gravatar image

updated 2013-04-11 01:43:43 -0600

Andrey Pavlenko gravatar image

*Update: I need to mention that this error only occurs when I open the cpp file. When I close the file and close and open the project, the errors disappear (till I open the file again)*


I want to reuse my native c++ files in a android project. When I paste the files into the jni folder the compiler gives me invalid argument errors for functions like substr or fwrite.

The example:

#include <string>
#include <vector>
using namespace std;
using namespace cv;
...
std::string str="We think in generalities, but we live in details.";   
std::string str2 = str.substr (12,12);   // "generalities"

image description does the compiler quit with:


Invalid arguments ' Candidates are: std::basic_string<char,std::char_traits<char>,std::allocator<char>> 
 substr(?, ?) '

I obviously missed something general! I'm using OpenCV 2.4.3.2 for Android and C/C++ Dev. Tools 8.0 for Eclipse.

My Application.mk:

APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8

Android.mk:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include ../../sdk/native/jni/OpenCV.mk
LOCAL_MODULE    := native_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl
include $(BUILD_SHARED_LIBRARY)

image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-02-12 23:37:05 -0600

It looks like you forgot to add STL support to your project. You need to add include paths to your C project in Eclipse and define STL type in Application.mk. You can use any OpenCV Sample with native code as reference. There is jni/Application.mk file and valid Eclipse CDT project config there. See Tutorial-3 and Tuturial-4 if you use OpenCV 2.4.2 or 2.4.3.x and Tutorial-2 if you use 2.4.4b.

edit flag offensive delete link more

Comments

It even happens when I post the code into the tutorial 4's jni folder (see http://i956.photobucket.com/albums/ae49/realnetzonk/screenshot_zpsbcebad58.png). Without the substr. function call, the tutorial compiles and runs just finde. STL and CDT Settings should be ok, I guess. But I just saw that I'm using old 8.0.3 version of cdt. I updated to 8.1.1 now. But this is also not the reason.

seismic gravatar imageseismic ( 2013-02-14 12:06:53 -0600 )edit

I'm desperate now, I don't get this error fixed and really need a solution. I installed everything on Mac, migrated to ndk8e, opencv 2.4.3.2 and cdt 8.1.2 and it doesn't work. Has it anything to do with my Toolchain settings (No Toolchain, GnuBuilder)? Do you get errors when you copy these two lines of code into the appropriate tutorial project? std::string str="We think in generalities, but we live in details."; std::string str2 = str.substr (12,12);

seismic gravatar imageseismic ( 2013-04-03 09:49:37 -0600 )edit
1

This looks like a bug(s) of CDT editor/syntax parser, so you just need to find a way to disable this check in Eclipse.

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2013-04-04 03:19:24 -0600 )edit

Thanks! I disabled the syntax check in eclipse. Now I don't have syntax check for most errors but at least I can compile now.

seismic gravatar imageseismic ( 2013-04-10 09:29:42 -0600 )edit

Question Tools

Stats

Asked: 2013-02-11 13:12:07 -0600

Seen: 3,330 times

Last updated: Apr 11 '13