android catcake编译 ndk -r9,Android 3D引擎之CatCake----编译hello_catcake

1.下载Catcake:

svn下载:svn checkouthttp://catcake.googlecode.com/svn/trunk/ catcake-read-only

2.导入Eclipse:

hello_catcake的例子程序在这个路径:catcake-read-only/sample/project/android/hello_catcake

导入直接运行不能成功,因为没有编译出需要的库

3.用ndk编译库

用cygwin进入这个路径:catcake-read-only/sample/project/android/hello_catcake/jni

运行ndk-build命令

我这里出现了错误,说找不到头文件:

cly@topgun /cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni

$ ndk-build

Compile++ thumb  : hello_catcake <= main.cpp

G:/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni/main.cpp:24:26: error: catcake_main.h: No such file or directory

G:/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni/main.cpp:30: error: ISO C++ forbids declaration of 'ckMain' with no type

G:/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni/main.cpp: In function 'int ckMain()':

G:/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni/main.cpp:32: error: 'ckCreateCatcake' was not declared in this scope

G:/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni/main.cpp:40: error: 'ckResMgr' has not been declared

G:/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni/main.cpp:41: error: 'ckResMgr' has not been declared

G:/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni/main.cpp:49: error: 'ckStartCatcake' was not declared in this scope

/cygdrive/g/android-ndk-r7b/build/core/build-binary.mk:243: recipe for target `/cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/obj/local/armeabi/objs/hello_catcake/main.o' failed

make: *** [/cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/obj/local/armeabi/objs/hello_catcake/main.o] Error 1

打开Android.mk文件发现这一行:

LOCAL_C_INCLUDES := apps/catcake/include

从工程中可以看到,include目录在上一层目录中,与jni目录同等级,因此把这一行改成:

LOCAL_C_INCLUDES := ../include

再执行ndk-build

又出现错误:

cly@topgun /cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni

$ ndk-build

Compile++ thumb  : hello_catcake <= main.cpp

Compile++ thumb  : hello_catcake <= hello_catcake.cpp

SharedLibrary  : libhello_catcake.so

G:/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld.exe: cannot find -lcatcake

collect2: ld returned 1 exit status

/cygdrive/g/android-ndk-r7b/build/core/build-binary.mk:314: recipe for target `/cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/obj/local/armeabi/libhello_catcake.so' failed

make: *** [/cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/obj/local/armeabi/libhello_catcake.so] Error 1

连接器找不到lcatcake库。

看了工程中的lib目录,发现有这个库:

libcatcake.a, libfreetype.a, libpng.a, libz.a

再查看Android.mk文件,到这一行:

LOCAL_LDLIBS := -Lapps/catcake/lib -lcatcake -lfreetype -lpng -lz -lGLESv1_CM -lgcc

跟第一次出现的头文件找不到错误一样,路径有问题,改为:

LOCAL_LDLIBS := -L../lib -lcatcake -lfreetype -lpng -lz -lGLESv1_CM -lgcc

再运行ndk-build,编译成功:

cly@topgun /cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android/hello_catcake/jni

$ ndk-build

Compile++ thumb  : hello_catcake <= main.cpp

Compile++ thumb  : hello_catcake <= hello_catcake.cpp

SharedLibrary  : libhello_catcake.so

Install        : libhello_catcake.so => libs/armeabi/libhello_catcake.so

4.Eclipse运行为Android程序:

发现程序运行一闪而过。

看程序代码,发现在main.cpp中,有这么一段

/*

The resource files need to be copied to the target by using 'adb push' command like this:

adb push hello_catcake/data /data/data/catcake_application.hello_catcake/data

And they must be specified by the absolute paths in ckResMgr::loadResource.

*/

ckResMgr::loadResource("/data/data/catcake_application.hello_catcake/data/catcake_logo_71x14.png", true);

ckResMgr::loadResource("/data/data/catcake_application.hello_catcake/data/stonsans.ttf", true);

于是在hello_catcake目录的上级目录中运行adb push hello_catcake/data /data/data/catcake_application.hello_catcake/data命令

结果如下:

cly@topgun /cygdrive/g/3D/CatCake/catcake-read-only/sample/project/android

$ adb push hello_catcake/data /data/data/catcake_application.hello_catcake/data

push: hello_catcake/data/stonsans.ttf -> /data/data/catcake_application.hello_catcake/data/stonsans.ttf

push: hello_catcake/data/catcake_logo_71x14.png -> /data/data/catcake_application.hello_catcake/data/catcake_logo_71x14.png

2 files pushed. 0 files skipped.

1294 KB/s (15911 bytes in 0.012s)

点手机上的apk运行,运行成功,但界面有些错乱重叠,如下图:

1344484400_4641.png

感觉是分辨率有些问题,看代码main.cpp中,有这么一句:

ckCreateCatcake("Hello Catcake", 320, 480, 30);

于是改为我手机的分辨率480,854,重新编译库和apk,运行正常,结果如下:

1344484573_8259.png

5.疑问:

catcake怎么用这么种资源管理方式?

编译出一个apk,还得另外把资源文件导进去,这在产品上怎么用?

看来还需要研究,肯定不会只是这种方式。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值