为什么会报错?是不是安卓库函数里面没有这个函数的实现呢?

在做ndk的开发时,应用的自己编写的类库里面有用到rand()srand(int)来求的随机数,但是在编译的时候报出:
E:/DeveloperTools/android-ndk-r9/toolchains/x86-4.6/prebuilt/windows/bin/../lib/gcc/i686-linux-android/4.6/../../../../i686-linux-android/bin/ld.exe: E:/MagickJava/Interactive_Sale_Assistant/jni/libs/odi/libQT_ODI_linux.a(ITextureHelper.o): in function ITextureHelper::RandList(std::list<Magick::Image, std::allocator<Magick::Image> >*):ITextureHelper.cpp(.text+0xd16): error: undefined reference to 'srand'

如何解决呢?
望大神帮助指点。谢谢!

环境:cygwin+ndk-r9;
Android.mk:
include $(CLEAR_VARS)  
LOCAL_MODULE := Magick++  
LOCAL_SRC_FILES := libs/magick/libMagick++-6.Q16.so
include $(PREBUILT_SHARED_LIBRARY)  

include $(CLEAR_VARS)  
LOCAL_MODULE := MagickCore  
LOCAL_SRC_FILES := libs/magick/libMagickCore-6.Q16.so  
include $(PREBUILT_SHARED_LIBRARY)  

include $(CLEAR_VARS)  
LOCAL_MODULE := MagickWand  
LOCAL_SRC_FILES := libs/magick/libMagickWand-6.Q16.so
include $(PREBUILT_SHARED_LIBRARY)  

include $(CLEAR_VARS)

LOCAL_MODULE := WellShaped
LOCAL_SRC_FILES := net_chinaeko_bis_isa_graphics_WellShapedToJNI.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include/ODI \
$(LOCAL_PATH)/include/ImageMagick-6
LOCAL_CFLAGS := -D__cplusplus -g -O4 -fpic \
-D_STLP_USE_NEWALLOC 
#LOCAL_CPPFLAGS += -fexceptions -frtti
LOCAL_LDFLAGS += -L$(prebuilt_stdcxx_PATH) -l gnustl_static -l supc++ 

LOCAL_SHARED_LIBRARIES := -l ODI_interfaceSO \
-l ODI_interfaceA \
-l Magick++ \
-l MagickCore \
-l MagickWand \
LOCAL_STATIC_LIBRARIES :=\
-l gnustl_static \
-l supc++ 

LOCAL_STATIC_LIBRARIES := ./libs/odi/libQT_ODI_linux.a

include $(BUILD_SHARED_LIBRARY)

Application.mk:

APP_STL := gnustl_static
APP_SUPC := supc++

APP_MODULES := libWellShaped
APP_ABI := x86
APP_PLATFORM := android-9

交互式爱情
浏览 124回答 2
2回答

弑天下

undefined reference to 'srand'srand没有定义就使用了,打开你的XXX.c或者XXX.cpp文件看看

紫衣仙女

把proj.android文件夹下的obj文件夹删除,重新编译试试
打开App,查看更多内容
随时随地看视频慕课网APP