openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.97k stars 2.55k forks source link

Android studio not finding std c++ headers using ofxPoco #6872

Open fred-dev opened 2 years ago

fred-dev commented 2 years ago

I am working with the current master as of today and when I try to add ofxPoco to a project I get a lot of errors, mostly related to this:

 error: no type named 'string' in namespace 'std'
        Exception(const std::string& msg, int code = 0);

The compile stops as there are too many errors, but here is some more verbose output:

/Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:74:32: error: unknown type name 'string' explicit logic_error(const string&); ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:91:34: error: unknown type name 'string' explicit runtime_error(const string&); ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:106:59: error: unknown type name 'string' _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {} ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:116:63: error: unknown type name 'string' _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {} ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:126:59: error: unknown type name 'string' _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {} ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:136:59: error: unknown type name 'string' _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {} ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:146:58: error: unknown type name 'string' _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {} ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:156:61: error: unknown type name 'string' _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {} ^ /Users/fredrodrigues/Library/Android/sdk/ndk/android-ndk-r15c/sources/cxx-stl/llvm-libc++/include/stdexcept:166:62: error: unknown type name 'string' _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {}

If I remove ofxPoco from my addons.mk file then I can compile and run the apps on my device or simulator.

I am using Android studio 3.14 and android-ndk-r15c as advised.

roymacdonald commented 2 years ago

I guess that the #include <string> is missing somewhere. It is quite odd though. is this error being thrown in the Poco files? cant you fix it just by putting #include <string> where needed?

fred-dev commented 2 years ago

Adding #include <string> anywhere does not solve the issue.

fred-dev commented 2 years ago

Just a bump on this after a little more digging. When the build variant is set to x86 using ofxPoco with openframeworks compiles perfectly on Android. Using any other build variant gives the errors I listed above.