android 环境下使用socketcc和pthreadcc

1. 下载socketcc和pthreadcc的压缩包, 解压后将这两个文件夹丢入Classes目录.

android 环境下使用socketcc和pthreadcc_第1张图片


2.更新android.mk文件.

LOCAL_SRC_FILES := hellocpp/main.cpp \
                  ../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/network/NetManager.cpp \
../../Classes/pthreadcc/condition.cpp \
../../Classes/pthreadcc/mutualexclusion.cpp \
../../Classes/pthreadcc/semaphore.cpp \
../../Classes/pthreadcc/threadbase.cpp \
../../Classes/pthreadcc/threadexception.cpp \
../../Classes/socketcc/ipaddress.cpp \
../../Classes/socketcc/socketbase.cpp \
../../Classes/socketcc/socketexception.cpp \
../../Classes/socketcc/tcpsockets.cpp \
../../Classes/socketcc/udpsockets.cpp



                   
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
$(LOCAL_PATH)/../../Classes/network \
$(LOCAL_PATH)/../../Classes/socketcc \
$(LOCAL_PATH)/../../Classes/pthreadcc


其中红色部分内容可以用脚本生成, 我的脚本是:

for line in `find . -name "*.cpp"`
do
echo -n "../../Classes"
echo -n $line | sed 's/.//'
echo ' \'
done


3. 此时编译会报错, 异常未开启, 还有平台未定义, 在Application.mk中加入:

APP_STL := stlport_static
APP_CPPFLAGS := -frtti -DCOCOS2D_DEBUG=1 --fexceptions -DPLATFORM_linux


4. 修改bcmp为memcpy,否则会报未定义引用错误

(bcopy、bzero和bcmp是传统BSD的函数,属于POSIX标准;mem*是C90(以及C99)标准的C函数。区别在于,如果你打算把程序弄到一个符合C90/C99,但是不符合POSIX标准的平台时,后者比较有优势。)

5.



参考文章:

http://processors.wiki.ti.com/index.php/Code_Generation_Tools_FAQ#Q:_What_does_the__eh_mean_at_the_end_of_some_of_the_run_time_support_libraries.3F_For_example.2C_what_is_the_difference_between_rts64plus.lib_and_rts64plus_eh.lib.3F


你可能感兴趣的:(android 环境下使用socketcc和pthreadcc)