hi,

 we are trying to modify the android filesystem.we are trying to use
the camera service from a c++ code.we are using the cameralistner
class present in  /root/Desktop/froyo/frameworks/base/include/camera/
Camera.h . we have followed what you have asked to but still get the
same problem

the cameralistner class consists of only 3 pure virtual functions and
inherits from Refbase class

when i try compiling the the .so i get the following error :

undefined reference to `typeinfo for android::RefBase'

we have then added all the libraries but still have the same
problem.below is my c++ files and makefile

please help !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


******************************************************************************
MAIN.CPP
******************************************************************************
#include <testcameralistner.h>
#include <qdebug.h>


// provides persistent context for calls from native code to Java

int main(int argc, char *argv[])
{
    sp<Camera> camera=Camera::connect();
    if (camera->getStatus() != NO_ERROR) {
          qDebug()<<"an error has occured"<<"\n";
          return 1;
      }

    TestCameraListner *context = new TestCameraListner(camera);
   // camera->setListener(context);

    sleep(10);
    camera->takePicture();


    return 0;
}

******************************************************************************
TestCameraListner.h
******************************************************************************
#ifndef TESTCAMERALISTNER_H
#define TESTCAMERALISTNER_H

#include <camera/Camera.h>
#include <binder/IMemory.h>
#include <utils/threads.h>
//#include <utils/RefBase.h>


using namespace android;
class RefBase;
class TestCameraListner: public CameraListener
{
public:
    TestCameraListner(const sp<Camera>& camera);
    virtual ~ TestCameraListner ();
    virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2);
    virtual void postData(int32_t msgType, const sp<IMemory>&
dataPtr);
    virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType,
const sp<IMemory>& dataPtr);
    //void addCallbackBuffer(QByteArray cbb);
    //void setCallbackMode(JNIEnv *env, bool installed, bool
manualMode);
    //sp<Camera> getCamera() {/* Mutex::Autolock _l(mLock);*/ return
mCamera; }
    void release();

private:
    //void copyAndPost(const sp<IMemory>& dataPtr, int msgType);
    sp<Camera>  mCamera;                // strong reference to native
object
    //Mutex       mLock;

    //Vector<jbyteArray> mCallbackBuffers; // Global reference
application managed byte[]
    //bool mManualBufferMode;              // Whether to use
application managed buffers.
    //bool mManualCameraCallbackSet;       // Whether the callback has
been set, used to reduce unnecessary calls to set the callback.
};

#endif // TESTCAMERALISTNER_H

******************************************************************************
TestCameraListner.cpp
******************************************************************************
#include <testcameralistner.h>
//#include <utils/RefBase.h>
extern "C"
{
#include <fcntl.h>
}

static void dump_to_file(const char *fname, uint8_t *buf, uint32_t
size);

TestCameraListner::TestCameraListner(const sp<Camera>& camera)
{
    mCamera = camera;
//    mManualBufferMode = false;
//    mManualCameraCallbackSet = false;
}

TestCameraListner::~TestCameraListner()
{
       release ();
}

void TestCameraListner::postData(int32_t msgType, const sp<IMemory>&
dataPtr)
{
    // VM pointer will be NULL if object is released
    //Mutex::Autolock _l(mLock);
    ssize_t offset;
    size_t size;
    sp<IMemoryHeap> heap = dataPtr->getMemory(&offset, &size);

    // return data based on callback type
    switch(msgType) {
    case CAMERA_MSG_COMPRESSED_IMAGE:

        LOGV("rawCallback");
        dump_to_file("/data/photo.jpg",(uint8_t *)heap->base() +
offset, size);
        break;

    default:
        break;
    }


}

void TestCameraListner::notify(int32_t msgType, int32_t ext1, int32_t
ext2)
{


}



void TestCameraListner::postDataTimestamp(nsecs_t timestamp, int32_t
msgType, const sp<IMemory>& dataPtr)
{

}


    void TestCameraListner::release()
    {
        LOGV("release");
        //Mutex::Autolock _l(mLock);
        mCamera.clear();
    }


    static void dump_to_file(const char *fname,
                             uint8_t *buf, uint32_t size)
    {
        int nw, cnt = 0;
        uint32_t written = 0;

        LOGV("opening file [%s]\n", fname);
        int fd = open(fname, O_RDWR | O_CREAT);
        if (fd < 0) {
            LOGE("failed to create file [%s]: %s", fname,
strerror(errno));
            return;
        }

        LOGV("writing %d bytes to file [%s]\n", size, fname);
        while (written < size) {
            nw = ::write(fd,
                         buf + written,
                         size - written);
            if (nw < 0) {
                LOGE("failed to write to file [%s]: %s",
                     fname, strerror(errno));
                break;
            }
            written += nw;
            cnt++;
        }
        LOGV("done writing %d bytes to file [%s] in %d passes\n",
             size, fname, cnt);
        ::close(fd);
    }

**************************************************************************************
Makefile

************************************************************************************

CC            = /root/Desktop/android-ndk-r5/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
CXX           = /root/Desktop/android-ndk-r5/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++
DEFINES       = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -
DQT_CORE_LIB -DQT_SHARED
CFLAGS        = -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -
fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-
protector -fno-short-enums -DANDROID -D__ARM_ARCH_5__ -
D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Os -g -fomit-
frame-pointer -fno-strict-aliasing -finline-limit=64 -Wall -W -
D_REENTRANT $(DEFINES)
CXXFLAGS      = -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -
fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-
protector -fno-short-enums -DANDROID -D__ARM_ARCH_5__ -
D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -
DQT_NO_QWS_TRANSFORMED -Os -g -fomit-frame-pointer -fno-strict-
aliasing -finline-limit=64 -Wall -W -D_REENTRANT $(DEFINES)
INCPATH       = -I/data/local/qt/mkspecs/android-g++ -I. -I/data/local/
qt/include/QtCore -I/data/local/qt/include/QtNetwork -I/data/local/qt/
include/QtGui -I/data/local/qt/include -I../Desktop/froyo/frameworks/
base/include -I../Desktop/froyo/system/core/include -I. -I../Desktop/
android-ndk-r5/platforms/android-8/arch-arm/usr/include -I../Desktop/
android-ndk-r5/sources/cxx-stl/gnu-libstdc++/include -I../Desktop/
android-ndk-r5/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include
LINK          = /root/Desktop/android-ndk-r5/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++
LFLAGS        = -Wl,-z,noexecstack -shared --sysroot=/root/Desktop/
android-ndk-r5/platforms/android-8/arch-arm/ -L/root/Desktop/android-
ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/
bin/../lib/gcc/arm-linux-androideabi/4.4.3 -Wl,-rpath-link=/root/
Desktop/android-ndk-r5/platforms/android-8/arch-arm//usr/lib -Wl,-O1 -
Wl,--whole-archive /data/local/qt/lib/libQtAndroidMain.a -Wl,--no-
whole-archive -Wl,-rpath=/data/local/qt/lib -Wl,-rpath=/data/local/lib
-Wl,-rpath=/system/lib/data/local/qt/lib
LIBS          = $(SUBLIBS)  -L/root/Desktop/android-ndk-r5/sources/cxx-
stl/gnu-libstdc++/libs/armeabi -L/root/Desktop/android-ndk-r5/
platforms/android-8/arch-arm//usr/lib -L/data/local/qt/lib -L/root/
Desktop/froyo/out/target/product/generic/system/lib -lui -lutils -
lcutils -lbinder -lmedia -lQtGui -L/data/local/qt/lib -L/root/Desktop/
android-ndk-r5/sources/cxx-stl/gnu-libstdc++/libs/armeabi -L/root/
Desktop/android-ndk-r5/platforms/android-8/arch-arm//usr/lib -
lQtNetwork -lQtCore -lstdc++ -lsupc++ -llog -lz -lm -ldl -lc -lgcc
AR            = /root/Desktop/android-ndk-r5/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar cqs
RANLIB        = /root/Desktop/android-ndk-r5/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ranlib
QMAKE         = /data/local/qt/bin/qmake
TAR           = tar -cf
COMPRESS      = gzip -9f
COPY          = cp -f
SED           = sed
COPY_FILE     = $(COPY)
COPY_DIR      = $(COPY) -r
STRIP         = /root/Desktop/android-ndk-r5/toolchains/arm-linux-
androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-strip
INSTALL_FILE  = install -m 644 -p
INSTALL_DIR   = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE      = rm -f
SYMLINK       = ln -f -s
DEL_DIR       = rmdir
MOVE          = mv -f
CHK_DIR_EXISTS= test -d
MKDIR         = mkdir -p

####### Output directory

OBJECTS_DIR   = ./

####### Files

SOURCES       = main.cpp \
                testcameralistner.cpp
OBJECTS       = main.o \
                testcameralistner.o
DIST          = /data/local/qt/mkspecs/common/g++-base.conf \
                /data/local/qt/mkspecs/common/g++-unix.conf \
                /data/local/qt/mkspecs/common/unix.conf \
                /data/local/qt/mkspecs/common/linux.conf \
                /data/local/qt/mkspecs/common/qws.conf \
                /data/local/qt/mkspecs/qconfig.pri \
                /data/local/qt/mkspecs/features/qt_functions.prf \
                /data/local/qt/mkspecs/features/qt_config.prf \
                /data/local/qt/mkspecs/features/exclusive_builds.prf \
                /data/local/qt/mkspecs/features/default_pre.prf \
                /data/local/qt/mkspecs/features/release.prf \
                /data/local/qt/mkspecs/features/default_post.prf \
                /data/local/qt/mkspecs/features/warn_on.prf \
                /data/local/qt/mkspecs/features/qt.prf \
                /data/local/qt/mkspecs/features/unix/thread.prf \
                /data/local/qt/mkspecs/features/moc.prf \
                /data/local/qt/mkspecs/features/resources.prf \
                /data/local/qt/mkspecs/features/uic.prf \
                /data/local/qt/mkspecs/features/yacc.prf \
                /data/local/qt/mkspecs/features/lex.prf \
                /data/local/qt/mkspecs/features/include_source_dir.prf \
                untitled2.pro
QMAKE_TARGET  = untitled2
DESTDIR       =
TARGET        = untitled2

first: all
####### Implicit rules

.SUFFIXES: .o .c .cpp .cc .cxx .C

.cpp.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cc.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.cxx.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.C.o:
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"

.c.o:
        $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"

####### Build rules

all: Makefile $(TARGET)

$(TARGET):  $(OBJECTS)
        $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)

Makefile: untitled2.pro  /data/local/qt/mkspecs/android-g++/
qmake.conf /data/local/qt/mkspecs/common/g++-base.conf \
                /data/local/qt/mkspecs/common/g++-unix.conf \
                /data/local/qt/mkspecs/common/unix.conf \
                /data/local/qt/mkspecs/common/linux.conf \
                /data/local/qt/mkspecs/common/qws.conf \
                /data/local/qt/mkspecs/qconfig.pri \
                /data/local/qt/mkspecs/features/qt_functions.prf \
                /data/local/qt/mkspecs/features/qt_config.prf \
                /data/local/qt/mkspecs/features/exclusive_builds.prf \
                /data/local/qt/mkspecs/features/default_pre.prf \
                /data/local/qt/mkspecs/features/release.prf \
                /data/local/qt/mkspecs/features/default_post.prf \
                /data/local/qt/mkspecs/features/warn_on.prf \
                /data/local/qt/mkspecs/features/qt.prf \
                /data/local/qt/mkspecs/features/unix/thread.prf \
                /data/local/qt/mkspecs/features/moc.prf \
                /data/local/qt/mkspecs/features/resources.prf \
                /data/local/qt/mkspecs/features/uic.prf \
                /data/local/qt/mkspecs/features/yacc.prf \
                /data/local/qt/mkspecs/features/lex.prf \
                /data/local/qt/mkspecs/features/include_source_dir.prf \
                /data/local/qt/lib/libQtGui.prl \
                /data/local/qt/lib/libQtCore.prl \
                /data/local/qt/lib/libQtNetwork.prl
        $(QMAKE) -o Makefile untitled2.pro
/data/local/qt/mkspecs/common/g++-base.conf:
/data/local/qt/mkspecs/common/g++-unix.conf:
/data/local/qt/mkspecs/common/unix.conf:
/data/local/qt/mkspecs/common/linux.conf:
/data/local/qt/mkspecs/common/qws.conf:
/data/local/qt/mkspecs/qconfig.pri:
/data/local/qt/mkspecs/features/qt_functions.prf:
/data/local/qt/mkspecs/features/qt_config.prf:
/data/local/qt/mkspecs/features/exclusive_builds.prf:
/data/local/qt/mkspecs/features/default_pre.prf:
/data/local/qt/mkspecs/features/release.prf:
/data/local/qt/mkspecs/features/default_post.prf:
/data/local/qt/mkspecs/features/warn_on.prf:
/data/local/qt/mkspecs/features/qt.prf:
/data/local/qt/mkspecs/features/unix/thread.prf:
/data/local/qt/mkspecs/features/moc.prf:
/data/local/qt/mkspecs/features/resources.prf:
/data/local/qt/mkspecs/features/uic.prf:
/data/local/qt/mkspecs/features/yacc.prf:
/data/local/qt/mkspecs/features/lex.prf:
/data/local/qt/mkspecs/features/include_source_dir.prf:
/data/local/qt/lib/libQtGui.prl:
/data/local/qt/lib/libQtCore.prl:
/data/local/qt/lib/libQtNetwork.prl:
qmake:  FORCE
        @$(QMAKE) -o Makefile untitled2.pro

dist:
        @$(CHK_DIR_EXISTS) .tmp/untitled21.0.0 || $(MKDIR) .tmp/
untitled21.0.0
        $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/untitled21.0.0/ && $
(COPY_FILE) --parents testcameralistner.h .tmp/untitled21.0.0/ && $
(COPY_FILE) --parents main.cpp testcameralistner.cpp .tmp/
untitled21.0.0/ && (cd `dirname .tmp/untitled21.0.0` && $(TAR)
untitled21.0.0.tar untitled21.0.0 && $(COMPRESS) untitled21.0.0.tar)
&& $(MOVE) `dirname .tmp/untitled21.0.0`/untitled21.0.0.tar.gz . && $
(DEL_FILE) -r .tmp/untitled21.0.0


clean:compiler_clean
        -$(DEL_FILE) $(OBJECTS)
        -$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
        -$(DEL_FILE) $(TARGET)
        -$(DEL_FILE) Makefile


check: first

mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

compiler_moc_header_make_all:
compiler_moc_header_clean:
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
        -$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean:

####### Compile

main.o: main.cpp testcameralistner.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp

testcameralistner.o: testcameralistner.cpp testcameralistner.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o testcameralistner.o
testcameralistner.cpp

####### Install

install:   FORCE

uninstall:   FORCE

FORCE:


*******************************the end*****************************

thanks and regards,
Ajay

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting

Reply via email to