5

Android NDKプロジェクトでGLM( glm.g-truc.net)ヘッダーのみのC ++ライブラリを使用したいのですが、コンパイルエラーが発生します。にAndroid.mk、ヘッダー検索パスを追加しました

LOCAL_CFLAGS += -I/Users/Johannes/Development/glm_include/

Application.mkまた、CPLUSPLUS-SUPPORTドキュメントで説明されているように、次のように設定して、STLportとGNU-STLを使用してコンパイルしようとしました。

APP_STL := stlport_static

また

APP_STL := gnustl_static

それぞれ。何も役に立ちません。<glm/glm.h>これらは、を含めて使用するときに発生するエラーですglm::ivec2ndk-build出力:

Compile++ arm    : wbar <= QCARBase.cpp
In file included from /Users/Johannes/Development/glm_include/glm/glm.hpp:66,
                 from /Users/Johannes/proj/WirtschaftsblattAR/app/android/wbar/jni/QCARBase.cpp:45:
/Users/Johannes/Development/glm_include/glm/./core/func_common.hpp:240: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.hpp:240: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.hpp:240: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.hpp:251: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.hpp:251: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.hpp:251: error: expected ')' before 'sizeof'
In file included from /Users/Johannes/Development/glm_include/glm/./core/func_common.hpp:335,
                 from /Users/Johannes/Development/glm_include/glm/glm.hpp:66,
                 from /Users/Johannes/proj/WirtschaftsblattAR/app/android/wbar/jni/QCARBase.cpp:45:
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1202: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1202: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1202: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1217: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1217: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1217: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1228: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1228: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1228: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1240: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1240: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1240: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1253: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1253: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1253: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1268: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1268: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1268: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1279: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1279: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1279: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1291: error: expected unqualified-id before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1291: error: expected ')' before 'sizeof'
/Users/Johannes/Development/glm_include/glm/./core/func_common.inl:1291: error: expected ')' before 'sizeof'
make: *** [/Users/Johannes/proj/WirtschaftsblattAR/app/android/wbar/obj/local/armeabi/objs/wbar/QCARBase.o] Error 1

Crystax NDK r6(www.crystax.net)を使用しています

4

4 に答える 4

3

少しヘッダーをホッピングした後、GNU libstdc++ ランタイムでこれを修正する方法を見つけました。

次のように、_GLIBCXX_USE_C99_MATHを含める前に 1 に定義してみてください。<glm.hpp>

#define _GLIBCXX_USE_C99_MATH 1
#include <glm/glm.hpp>

<glm.hpp>を含み<cmath>、次に含む<math.h>。マクロは、そうでなければ、 などのいくつかの機能を隠すいくつかのマクロを_GLIBCXX_USE_C99_MATH強制<cmath>#undefます。<math.h>glmisnan()isinf()

于 2012-09-26T21:06:43.913 に答える
2

なんとかコンパイルできました。で次のオプションを指定すると、Application.mkうまくいきました。

APP_OPTIM := release
APP_STL := stlport_static
LOCAL_ARM_MODE := thumb
APP_ABI := armeabi armeabi-v7a 

-frttiまた、STLport では RTTIや例外を使用できないと思います-fexceptionsAndroid.mk

于 2011-10-15T13:37:18.753 に答える
1

次のような小さなサンプル テスト アプリを作成してみてください。

#include <glm/glm.h>
int main(int argc, char* argv[])
{
    return 0;
}

それは動作しますか?

もしそうなら、私はあなたのアプリで、glm.h が glm で使用されているシンボルとのシンボル衝突を持つ #define の後にインクルードしていることに賭けます。あなたの #define はおそらく sizeof キーワードを利用しており、それはエラーのある glm 行で置き換えられています。

考えられる解決策は、glm.h インクルードを他の #includes や #defines の上に移動することです。ファイル内の最初のものにすると、問題を回避できます。

より良い解決策は、#defines を避け、可能な限りインライン関数を使用することです。

これが役立つことを願っています。

于 2011-09-15T19:45:00.990 に答える
0

glmに対してコンパイルしようとすると同じ問題が発生しますgnustl_staticが、でコンパイルしようとすると問題は発生しませんstlport_static。私の唯一の提案は、共有ライブラリ モジュールstlportを使用して依存関係を宣言することです。LOCAL_STATIC_LIBRARIES

また、使ってみましたstlport_sharedか?stlportには共有ライブラリと静的ライブラリの両方がありますgnustlが、静的バージョンしかありません (例外/RTTI をサポートしています)。

于 2011-10-01T23:25:58.383 に答える