Cocos2d-x 3.2 Slider undefined in Android - android

I have a game that I want to deploy on both android and ios. The ios version works fine, its compiled without errors. But when I run the build_native.py I got undefined error. I'll include my codes and the error message below. Thank in advance.
CODE
#ifndef __SETTING_SCENE_H__
#define __SETTING_SCENE_H__
#include "cocos2d.h"
#include "ui/CocosGUI.h"
USING_NS_CC;
using namespace ui;
class SettingScreen : public cocos2d::Layer {
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// implement the "static create()" method manually
CREATE_FUNC(SettingScreen);
int fontSize = 18;
int bgmVolume = 100;
int sfxVolume = 100;
void Back(Ref *pSender);
void BgmSliderEvent(Ref *pSender, Slider::EventType type);
void SfxSliderEvent(Ref *pSender, Slider::EventType type);
};
#endif // __SETTING_SCENE_H__
ERROR
The Selected NDK toolchain version was 4.8 !
Android NDK: WARNING:jni/../../cocos2d/cocos/./Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
Android NDK: WARNING:jni/../../cocos2d/cocos/platform/android/Android.mk:cocos2dxandroid_static: LOCAL_LDLIBS is always ignored for static libraries
make: Entering directory `/cocos2dx/TestGame/proj.android'
[armeabi] SharedLibrary : libcocos2dcpp.so
jni/../../Classes/Scenes/SettingScene.cpp:72: error: undefined reference to 'cocos2d::ui::Slider::create()'
jni/../../Classes/Scenes/SettingScene.cpp:73: error: undefined reference to 'cocos2d::ui::Slider::loadBarTexture(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cocos2d::ui::Widget::TextureResType)'
jni/../../Classes/Scenes/SettingScene.cpp:74: error: undefined reference to 'cocos2d::ui::Slider::loadSlidBallTextures(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cocos2d::ui::Widget::TextureResType)'
jni/../../Classes/Scenes/SettingScene.cpp:80: error: undefined reference to 'cocos2d::ui::Slider::setPercent(int)'
jni/../../Classes/Scenes/SettingScene.cpp:81: error: undefined reference to 'cocos2d::ui::Slider::addEventListener(std::__1::function<void (cocos2d::Ref*, cocos2d::ui::Slider::EventType)> const&)'
jni/../../Classes/Scenes/SettingScene.cpp:91: error: undefined reference to 'cocos2d::ui::Slider::create()'
jni/../../Classes/Scenes/SettingScene.cpp:92: error: undefined reference to 'cocos2d::ui::Slider::loadBarTexture(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cocos2d::ui::Widget::TextureResType)'
jni/../../Classes/Scenes/SettingScene.cpp:93: error: undefined reference to 'cocos2d::ui::Slider::loadSlidBallTextures(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, cocos2d::ui::Widget::TextureResType)'
jni/../../Classes/Scenes/SettingScene.cpp:99: error: undefined reference to 'cocos2d::ui::Slider::setPercent(int)'
jni/../../Classes/Scenes/SettingScene.cpp:100: error: undefined reference to 'cocos2d::ui::Slider::addEventListener(std::__1::function<void (cocos2d::Ref*, cocos2d::ui::Slider::EventType)> const&)'
jni/../../Classes/Scenes/SettingScene.cpp:113: error: undefined reference to 'cocos2d::ui::Slider::getPercent() const'
jni/../../Classes/Scenes/SettingScene.cpp:116: error: undefined reference to 'typeinfo for cocos2d::ui::Slider'
jni/../../Classes/Scenes/SettingScene.cpp:121: error: undefined reference to 'cocos2d::ui::Slider::getPercent() const'
jni/../../Classes/Scenes/SettingScene.cpp:124: error: undefined reference to 'typeinfo for cocos2d::ui::Slider'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make: Leaving directory `/cocos2dx/TestGame/proj.android'
Traceback (most recent call last):
File "TestGame/proj.android/build_native.py", line 159, in <module>
build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
File "TestGame/proj.android/build_native.py", line 146, in build
do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
File "TestGame/proj.android/build_native.py", line 82, in do_build
raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
Exception: Build dynamic library for project [ /cocos2dx/TestGame/proj.android ] fails!

You should replace your Android.mk file under proj.android directory with the following code:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_ui_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
$(call import-module,audio/android)
$(call import-module,ui)
Pay attention to the LOCAL_WHOLE_STATIC_LIBRARIES += cocos_ui_static and $(call import-module,ui). These two lines add the ui dependency to your project.

Related

cannot find libmediandk.so with LOCAL_LDLIBS += -lmediandk. Android native shared library with ndk-build

Why can I not find libmediandk.so with the following command in the Android.mk file:
LOCAL_LDLIBS += -lmediandk
Application.mk
NDK_TOOLCHAIN_VERSION := 4.9
APP_ABI := x86
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -std=c++11
LOCAL_CFLAGS += -UNDEBUG
LOCAL_LDLIBS += -lmediandk
LOCAL_LDLIBS += -OpenMAXAL
LOCAL_LDLIBS += -landroid
LOCAL_SHARED_LIBRARIES += libmediandk
LOCAL_LDLIBS += -llog
CC=/home/c/Downloads/Openglxmlfour/i686-linux-android/bin/i686-linux-android-gcc
CXX=CC=/home/c/Downloads/Openglxmlfour/i686-linux-android/bin/i686-linux-android-g++
LOCAL_MODULE := native-codec-jni # name your module here.
LOCAL_SRC_FILES := native-codec-jni.cpp looper.cpp
LOCAL_C_INCLUDES=/home/c/Android/Sdk/ndk-bundle/platforms/android-21/arch-x86/usr/include
include $(BUILD_SHARED_LIBRARY)
Command Line
ndk-build clean && ndk-build
[x86] Clean : native-codec-jni [x86]
[x86] Clean : stdc++ [x86]
[x86] Compile++ : native-codec-jni <= native-codec-jni.cpp
[x86] Compile++ : native-codec-jni <= looper.cpp
[x86] StaticLibrary : libstdc++.a
[x86] SharedLibrary : libnative-codec-jni.so
/home/c/Android/Sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld: error: cannot find -lmediandk
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:94: error: undefined reference to 'AMediaCodec_dequeueInputBuffer'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:98: error: undefined reference to 'AMediaCodec_getInputBuffer'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:99: error: undefined reference to 'AMediaExtractor_readSampleData'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:105: error: undefined reference to 'AMediaExtractor_getSampleTime'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:108: error: undefined reference to 'AMediaCodec_queueInputBuffer'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:109: error: undefined reference to 'AMediaExtractor_advance'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:115: error: undefined reference to 'AMediaCodec_dequeueOutputBuffer'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:129: error: undefined reference to 'AMediaCodec_releaseOutputBuffer'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:137: error: undefined reference to 'AMediaCodec_getOutputFormat'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:138: error: undefined reference to 'AMediaFormat_toString'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:139: error: undefined reference to 'AMediaFormat_delete'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:172: error: undefined reference to 'AMediaExtractor_seekTo'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:173: error: undefined reference to 'AMediaCodec_flush'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:161: error: undefined reference to 'AMediaCodec_stop'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:162: error: undefined reference to 'AMediaCodec_delete'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:163: error: undefined reference to 'AMediaExtractor_delete'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:237: error: undefined reference to 'AMediaExtractor_new'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:240: error: undefined reference to 'AMediaExtractor_setDataSourceFd'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:247: error: undefined reference to 'AMediaExtractor_getTrackCount'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:275: error: undefined reference to 'AMediaFormat_delete'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:253: error: undefined reference to 'AMediaExtractor_getTrackFormat'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:254: error: undefined reference to 'AMediaFormat_toString'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:257: error: undefined reference to 'AMEDIAFORMAT_KEY_MIME'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:257: error: undefined reference to 'AMediaFormat_getString'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:263: error: undefined reference to 'AMediaExtractor_selectTrack'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:264: error: undefined reference to 'AMediaCodec_createDecoderByType'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:265: error: undefined reference to 'AMediaCodec_configure'
/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/jni/native-codec-jni.cpp:273: error: undefined reference to 'AMediaCodec_start'
collect2: error: ld returned 1 exit status
make: *** [/home/c/Downloads/android-ndk-master2/MyApplication/app/src/main/obj/local/x86/libnative-codec-jni.so] Error 1
libmediandk was first added to android-21 (https://android-review.googlesource.com/#/c/278674/1/media/ndk/Android.bp). You haven't stated an APP_PLATFORM in your Application.mk, so you're defaulting to android-9.
To get access to libmediandk, set APP_PLATFORM := android-21 in your Application.mk. Note that this will make Lollipop the minimum supported platform for your application.

Write a C++ method around a calling method

I face issues with writing a wrapper around a calling method. Here is my wrapper :
#include <jni.h>
#include <cassert>
#include <fstream>
#include "TextDetection.h"
#include <opencv/highgui.h>
#include <exception>
extern "C" {
JNIEXPORT int JNICALL Java_cgi_pi_detect() {
IplImage * byteQueryImage = loadByteImage ( "Image_utilisateur.png" );
if ( !byteQueryImage )
{
printf ( "couldn't load query image\n" );
return -1;
}
// Detect text in the image
IplImage * output = textDetection ( byteQueryImage, atoi(1));
cvReleaseImage ( &byteQueryImage );
cvSaveImage ( "Image_Tesseract.png", output );
cvReleaseImage ( &output );
return 0;
}
}
But when I try to compile the wrapper with the Android.mk, I got the error :
[armeabi] Compile++ thumb: wrapper <= wrapper.cpp
[armeabi] SharedLibrary : libwrapper.so
jni/wrapper.cpp:22: error: undefined reference to 'cvReleaseImage'
jni/wrapper.cpp:23: error: undefined reference to 'cvSaveImage'
jni/wrapper.cpp:24: error: undefined reference to 'cvReleaseImage'
jni/FeaturesMain.cpp:29: error: undefined reference to 'cvConvertScale'
jni/FeaturesMain.cpp:50: error: undefined reference to 'cvLoadImage'
jni/FeaturesMain.cpp:56: error: undefined reference to 'cvCvtColor'
jni/FeaturesMain.cpp:62: error: undefined reference to 'cvLoadImage'
jni/FeaturesMain.cpp:68: error: undefined reference to 'cvCvtColor'
jni/FeaturesMain.cpp:70: error: undefined reference to 'cvGetSize'
jni/FeaturesMain.cpp:70: error: undefined reference to 'cvCreateImage'
jni/FeaturesMain.cpp:71: error: undefined reference to 'cvConvertScale'
jni/FeaturesMain.cpp:72: error: undefined reference to 'cvReleaseImage'
jni/FeaturesMain.cpp:87: error: undefined reference to 'cvReleaseImage'
jni/FeaturesMain.cpp:88: error: undefined reference to 'cvSaveImage'
jni/TextDetection.cpp:132: error: undefined reference to 'cvSetZero'
jni/TextDetection.cpp:178: error: undefined reference to 'cvGetSize'
jni/TextDetection.cpp:178: error: undefined reference to 'cvCreateImage'
jni/TextDetection.cpp:191: error: undefined reference to 'cvGetSize'
jni/TextDetection.cpp:191: error: undefined reference to 'cvCreateImage'
jni/TextDetection.cpp:192: error: undefined reference to 'cvConvertScale'
jni/TextDetection.cpp:193: error: undefined reference to 'cvCvtColor'
jni/TextDetection.cpp:204: error: undefined reference to 'cvRectangle'
jni/TextDetection.cpp:231: error: undefined reference to 'cvGetSize'
jni/TextDetection.cpp:231: error: undefined reference to 'cvCreateImage'
jni/TextDetection.cpp:240: error: undefined reference to 'cvConvertScale'
jni/TextDetection.cpp:241: error: undefined reference to 'cvCvtColor'
jni/TextDetection.cpp:252: error: undefined reference to 'cvRectangle'
jni/boost/include/boost-1_53/boost/unordered/detail/unique.hpp:270: error: undefined reference to 'b
oost::throw_exception(std::exception const&)'
jni/TextDetection.cpp:299: error: undefined reference to 'cvCanny'
jni/TextDetection.cpp:300: error: undefined reference to 'cvSaveImage'
jni/TextDetection.cpp:306: error: undefined reference to 'cvSmooth'
jni/TextDetection.cpp:311: error: undefined reference to 'cvSobel'
jni/TextDetection.cpp:312: error: undefined reference to 'cvSobel'
jni/TextDetection.cpp:313: error: undefined reference to 'cvSmooth'
jni/TextDetection.cpp:314: error: undefined reference to 'cvSmooth'
jni/TextDetection.cpp:337: error: undefined reference to 'cvSaveImage'
collect2.exe: error: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libwrapper.so] Error 1
These methods are implemented in my other C++ files. Here is the Android.mk :
LOCAL_PATH := $(call my-dir)
# static library info
LOCAL_MODULE := Library
LOCAL_SRC_FILES := libSWT.a
include $(PREBUILT_STATIC_LIBRARY)
# wrapper info
include $(CLEAR_VARS)
LOCAL_MODULE := wrapper
LOCAL_C_INCLUDES := jni/opencv/include/
LOCAL_C_INCLUDES += jni/boost/include/boost-1_53
LOCAL_SRC_FILES := wrapper.cpp
LOCAL_STATIC_LIBRARIES := Library
include $(BUILD_SHARED_LIBRARY)
And this is how I get the libSWT.a :
LOCAL_PATH := $(call my-dir)
# static library info
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_core
LOCAL_SRC_FILES := opencv/lib/libopencv_core.a
include $(PREBUILT_STATIC_LIBRARY)
# static library info
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_highgui
LOCAL_SRC_FILES := opencv/lib/libopencv_highgui.a
include $(PREBUILT_STATIC_LIBRARY)
# static library info
include $(CLEAR_VARS)
LOCAL_MODULE := opencv_imgproc
LOCAL_SRC_FILES := opencv/lib/libopencv_imgproc.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := SWT
LOCAL_STATIC_LIBRARIES := opencv_core \
opencv_highgui \
opencv_imgproc
LOCAL_C_INCLUDES := jni/opencv/include/
LOCAL_C_INCLUDES += jni/boost/include/boost-1_53
LOCAL_SRC_FILES := FeaturesMain.cpp \
TextDetection.cpp
include $(BUILD_STATIC_LIBRARY)
I thought because I compile the libSWT.a with OpenCV and Boost, I didn't have to specify them in the Android.mk ?

Cannot run new cocos2d-x project

I tried to solve this problem by own but i don't have more ideas;(
I created with the cocos2d-x console an new project.
Now i want to compile this but alway i get this error(s).
I use actually the newest at bundle for mac, apache-ant-1.9.4 & android NDK-r9d
MacBook-Air:3sCube to-dev$ cocos run -p android -v
Running command: compile
Building mode: debug
building native
NDK build mode: debug
The Selected NDK toolchain version was 4.8 !
running: '/Users/to-dev/Desktop/android-ndk-r9d/ndk-build -C /Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android -j1 NDK_MODULE_PATH=/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d:/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos:/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/external NDK_DEBUG=1'
Android NDK: WARNING:/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./Android.mk:cocos2dx_static: LOCAL_LDLIBS is always ignored for static libraries
Android NDK: WARNING:/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/platform/android/Android.mk:cocos2dxandroid_static: LOCAL_LDLIBS is always ignored for static libraries
make: Entering directory `/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android'
[armeabi] StaticLibrary : libcocos2d.a
[armeabi] StaticLibrary : libcocosdenshion.a
[armeabi] StaticLibrary : libchipmunk.a
[armeabi] StaticLibrary : libcocos2dandroid.a
[armeabi] StaticLibrary : libcpufeatures.a
[armeabi] SharedLibrary : libcocos2dcpp.so
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCActionManager.cpp:81: error: undefined reference to 'cocos2d::ccArrayNew(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCActionManager.cpp:100: error: undefined reference to 'cocos2d::ccArrayRemoveObjectAtIndex(cocos2d::_ccArray*, int, bool)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCAtlasNode.cpp:93: error: undefined reference to 'cocos2d::TextureAtlas::initWithTexture(cocos2d::Texture2D*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCAtlasNode.cpp:138: error: undefined reference to 'cocos2d::QuadCommand::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCFontAtlas.cpp:76: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCFontAtlas.cpp:268: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCFontAtlas.cpp:312: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCGrid.cpp:133: error: undefined reference to 'cocos2d::Texture2D::initWithData(void const*, int, cocos2d::Texture2D::PixelFormat, int, int, cocos2d::Size const&)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCLabel.cpp:1326: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCLabelAtlas.cpp:208: error: undefined reference to 'cocos2d::TextureAtlas::increaseTotalQuadsWith(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCLabelAtlas.cpp:219: error: undefined reference to 'cocos2d::TextureAtlas::resizeCapacity(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCLabelAtlas.cpp:250: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParallaxNode.cpp:68: error: undefined reference to 'cocos2d::ccArrayNew(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParallaxNode.cpp:126: error: undefined reference to 'cocos2d::ccArrayRemoveObjectAtIndex(cocos2d::_ccArray*, int, bool)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:100: error: undefined reference to 'cocos2d::TextureAtlas::initWithTexture(cocos2d::Texture2D*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:459: error: undefined reference to 'cocos2d::TextureAtlas::fillWithEmptyQuadsFromIndex(int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:465: error: undefined reference to 'cocos2d::TextureAtlas::moveQuadsFromIndex(int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:469: error: undefined reference to 'cocos2d::TextureAtlas::increaseTotalQuadsWith(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:291: error: undefined reference to 'cocos2d::TextureAtlas::moveQuadsFromIndex(int, int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:379: error: undefined reference to 'cocos2d::TextureAtlas::removeQuadsAtIndex(int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:382: error: undefined reference to 'cocos2d::TextureAtlas::fillWithEmptyQuadsFromIndex(int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleBatchNode.cpp:433: error: undefined reference to 'cocos2d::TextureAtlas::resizeCapacity(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleExamples.cpp:52: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleSystem.cpp:403: error: undefined reference to 'cocos2d::ZipUtils::inflateMemory(unsigned char*, int, unsigned char**)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleSystem.cpp:409: error: undefined reference to 'cocos2d::Image::initWithImageData(unsigned char const*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCParticleSystemQuad.cpp:377: error: undefined reference to 'cocos2d::QuadCommand::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCRenderTexture.cpp:526: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCRenderTexture.cpp:530: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSprite.cpp:336: error: undefined reference to 'cocos2d::Image::initWithRawData(unsigned char const*, int, int, int, int, bool)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSprite.cpp:568: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSprite.cpp:595: error: undefined reference to 'cocos2d::QuadCommand::init(float, unsigned int, cocos2d::GLProgramState*, cocos2d::BlendFunc, cocos2d::V3F_C4B_T2F_Quad*, int, cocos2d::Mat4 const&)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSprite.cpp:913: error: undefined reference to 'cocos2d::TextureAtlas::updateQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSpriteBatchNode.cpp:99: error: undefined reference to 'cocos2d::TextureAtlas::initWithTexture(cocos2d::Texture2D*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSpriteBatchNode.cpp:548: error: undefined reference to 'cocos2d::TextureAtlas::insertQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSpriteBatchNode.cpp:560: error: undefined reference to 'cocos2d::TextureAtlas::removeQuadAtIndex(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSpriteBatchNode.cpp:405: error: undefined reference to 'cocos2d::TextureAtlas::resizeCapacity(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCSpriteBatchNode.cpp:639: error: undefined reference to 'cocos2d::TextureAtlas::insertQuad(cocos2d::V3F_C4B_T2F_Quad*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTMXLayer.cpp:91: error: undefined reference to 'cocos2d::ccCArrayNew(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTMXLayer.cpp:448: error: undefined reference to 'cocos2d::ccCArrayInsertValueAtIndex(cocos2d::_ccCArray*, void*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTMXLayer.cpp:384: error: undefined reference to 'cocos2d::ccCArrayInsertValueAtIndex(cocos2d::_ccCArray*, void*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTMXLayer.cpp:585: error: undefined reference to 'cocos2d::ccCArrayRemoveValueAtIndex(cocos2d::_ccCArray*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTMXLayer.cpp:595: error: undefined reference to 'cocos2d::TextureAtlas::removeQuadAtIndex(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTMXLayer.cpp:565: error: undefined reference to 'cocos2d::ccCArrayRemoveValueAtIndex(cocos2d::_ccCArray*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTMXXMLParser.cpp:646: error: undefined reference to 'cocos2d::ZipUtils::inflateMemoryWithHint(unsigned char*, int, unsigned char**, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./2d/CCTileMapAtlas.cpp:226: error: undefined reference to 'cocos2d::TextureAtlas::increaseTotalQuadsWith(int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./3d/CCBundle3D.cpp:451: error: undefined reference to 'cocos2d::BundleReader::init(char*, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./3d/CCBundle3D.cpp:456: error: undefined reference to 'cocos2d::BundleReader::read(void*, int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./3d/CCBundle3D.cpp:465: error: undefined reference to 'cocos2d::BundleReader::read(void*, int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./3d/CCBundle3D.cpp:484: error: undefined reference to 'cocos2d::BundleReader::read(void*, int, int)'
/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android/../cocos2d/cocos/./3d/CCBundle3D.cpp:497: error: undefined reference to 'cocos2d::BundleReader::read(void*, int, int)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [obj/local/armeabi/libcocos2dcpp.so] Error 1
make: Leaving directory `/Users/to-dev/Desktop/cocos2d-x-3.2/3sCube/proj.android'
Error running command, return code: 2
What do i wrong? Thanks for your help!
t333o
Thanks for all answers and comments!
My Solution was that i reinstall cocos2d-x 3.2 and all the environmental variables.
Thanks!
1) Have you tried to run : cocos run -p android ?
2) Did you check cocos2d lib added to the Android.mk ?
3) You can try to use to the following Makefiles:
Application.mk
APP_STL := c++_static
NDK_TOOLCHAIN_VERSION=clang
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char
APP_LDFLAGS := -latomic
APP_DEBUG := $(strip $(NDK_DEBUG))
ifeq ($(APP_DEBUG),1)
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
else
APP_CPPFLAGS += -DNDEBUG
APP_OPTIM := release
endif
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/HelloWorldScene.cpp \
../../Classes/MenuScene.cpp
LOCAL_CFLAGS := -std=c++11
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
# LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static
# LOCAL_WHOLE_STATIC_LIBRARIES += spine_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,.)
$(call import-module,audio/android)
# $(call import-module,Box2D)
# $(call import-module,editor-support/cocosbuilder)
# $(call import-module,editor-support/spine)
# $(call import-module,editor-support/cocostudio)
# $(call import-module,network)
# $(call import-module,extensions)

OpenCV, Android and JNI

I'm developing a Android application which JNI code and this code makes use of OpenCV library.
The .c class of JNI code is "sintetica.c":
#include <jni.h>
#include "sintetica.h"
#include <opencv/cv.h>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/imgproc/types_c.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
jint Java_com_example_imagen3d_Imagen3DActivity_sintetica(JNIEnv *env, jobject thiz,jint argc, jchar *argv[]) {
...
return 0;
}
The Android.mk file :
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=off
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=STATIC
include /home/vmg/workspace/android/OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE :=sintetica
LOCAL_LDLIBS += -llog -ldl
LOCAL_SRC_FILES :=sintetica.c
include $(BUILD_SHARED_LIBRARY)
The Application.mk file :
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a armeabi x86
APP_PLATFORM := android-8
And the Java class:
![public class Imagen3DActivity extends Activity {
...
public native int Java_com_example_imagen3d_Imagen3DActivity_sintetica(int argc, char argv\[\]);
static {
System.loadLibrary("sintetica");
}
}]
I'm a Linux user and I'm using Eclipse Juno and Opencv 2.4.5, although for the .c class i used OpenCV library of linux repositories and i don't know what version is it.
A part of the errors which happen is as follows:
20:10:55 **** Incremental Build of configuration Default for project Imagen3D ****
/home/vmg/android/android-ndk-r8c/ndk-build
SharedLibrary : libsintetica.so
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x86): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x94): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0xa4): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x11c): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x9c4): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0xb78): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_S_empty_rep_storage'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x2058): error: undefined reference to '__cxa_end_cleanup'
/home/vmg/android/android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libopencv_photo.a(inpaint.cpp.o): in function cvInpaint:inpaint.cpp(.text.cvInpaint+0x2146): error: undefined reference to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)'
...
Thanks!

Link error with Boost on Android

I've successfully built some of the boost-libraries but when I include them in a test project I get link errors.
Gdbserver : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup : libs/armeabi/gdb.setup
Compile++ thumb : hello-jni <= test.cpp
SharedLibrary : libhello-jni.so
libboost_timer.a(cpu_timer.o): In function `~basic_iostream':
/opt/android-ndk-r7/sources/boost/../../sources/cxx-stl/gnu-libstdc++/include/istream:795: undefined reference to `VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >'
libboost_timer.a(cpu_timer.o): In function `show_time':
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:61: undefined reference to `VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >'
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:61: undefined reference to `vtable for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >'
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:61: undefined reference to `vtable for std::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >'
libboost_timer.a(cpu_timer.o): In function `boost::timer::format(boost::timer::cpu_times const&, short, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/opt/android-ndk-r7/sources/boost/libs/timer/src/cpu_timer.cpp:177: undefined reference to `std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()'
collect2: ld returned 1 exit status
Application.mk
APP_STL := gnustl_static
APP_CPPFLAGS = -fexceptions
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c test.cpp
LOCAL_STATIC_LIBRARIES := boost_timer, boost_system
LOCAL_LDLIBS := libboost_system.a libboost_timer.a libboost_chrono.a libboost_iostreams.a
include $(BUILD_SHARED_LIBRARY)
$(call import-module,boost)
And test.cpp
#include "test.hpp"
#include <string>
#include <boost/timer/timer.hpp>
void mytest() {
boost::timer::cpu_timer t;
}
we had very similar problem. What helped for us is to add -lgnustl_static at the end of the LOCAL_LDLIBS line in Android.mk. Like this:
LOCAL_LDIBS := -lboost_system .... -lgnustl_static
I think this is because boost libraries depend on STL but don't have it statically compiled in, so it needs to be mentioned explicitly like that.
Also, it seems you don't have to add the APP_STL := gnustl_static line to the Application.mk.

Categories

Resources