2011-09-15 8 views
5

Android NDKプロジェクトでGLM(glm.g-truc.net)ヘッダのみのC++ライブラリを使用したいが、コンパイルエラーが発生する。 Android.mkにおいて、IはAndroid-NDKでヘッダ専用C++ライブラリ(GLM)がコンパイルされない

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

ヘッダ検索パスを追加したと私はまたCPLUSPLUS支持文書に記載のようApplication.mkに次のように設定することにより、STLportのとGNU-STLを使用してコンパイルしようとしている:

APP_STL := stlport_static 

または

APP_STL := gnustl_static 

それぞれ。何も助けません。それらは、<glm/glm.h>を含み、glm::ivec2を使用するときに得られるエラーです。 ndk-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に)

+0

あなたは '代わりLOCAL_CFLAGSのLOCAL_C_INCLUDES + = /ユーザ/ヨハネス/開発/ glm_include /'を試したことがありますか? –

+0

はい、これと同じ効果があります。上記のエラーはインクルードされたファイルにあるため、コンパイラは明らかにファイルを検出します。 – j00hi

+0

glm/glm.hを含む前にコードを表示 – fazo

答えて

2

どうにか私はそれをコンパイルすることができました。 Application.mkで次のオプションを指定すると、トリックでした:

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

をそして、私がのSTLportで考えて、あなたはRTTIや例外を使用することはできませんので、Android.mk

1

を使用していますが、このような小さなサンプルテストアプリケーションを構築してみてください。

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

は、その仕事をしていますか?

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

glm.hインクルードを他の#includeや#defineの上に移動すると、問題を回避できるファイルの最初のものにすることができます。

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

こちらがお役に立てば幸いです。

+0

私はそれを試しましたが、これには ''だけが含まれていましたが、同じエラーが発生しています。それはコンパイラの問題だろうか? STLライブラリを変更しても効果はないようです。 – j00hi

+0

NDKアプリケーション(r5cとr6b)の2.3+(ターゲットAPI-10)でGLMをテストしましたが、うまくいきました。多分Crystaxは問題ですか? – kibab

0

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

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

3

-frttiまたは-fexceptionsを有効にしないでくださいちょっとしたヘッダーホッピングの後、私はこれをGNU libstdC++ランタイムでどのように修正するかを考え出しました。

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

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

<glm.hpp>は、順番に<math.h>を含む、<cmath>を含んでいます。 _GLIBCXX_USE_C99_MATHマクロ力そうisnan()のようないくつかのglmの機能を隠します<math.h>から<cmath>#undefにいくつかのマクロ、isinf()など

関連する問題