#21 Build Error with mipsel-linux-android-g++

closed-fixed
nobody
None
5
2012-03-10
2011-11-16
Santhosh Ramani
No

I am trying to build libJSON as a shared library with the C-Style interface. The idea is to use libJSON inside an android native service on a mips platform. Below is the log.

make BUILD_TYPE=debug SHARED=1
make[1]: Entering directory `/Software/Broadcom/DLNA/G8/RTC-G8-MDK2.1.1.0104-BL/dbs/dbsjni/libjson'
============================================================
libjson version: 7.4.1 target: OS: Linux
============================================================
mkdir -p Objects_shared
/Software/Broadcom/Android/G8-SDK/cisco-android-sdk-bcm7425-g87425-0.0.2.3/toolchain/mipsel-linux-android-4.4.3-20110728/bin//mipsel-linux-android-g++ Source/internalJSONNode.cpp -o Objects_shared/internalJSONNode.o -c -g -DJSON_SAFE -DJSON_DEBUG -fPIC
In file included from Source/JSONDefs.h:10,
from Source/JSONDebug.h:4,
from Source/internalJSONNode.h:4,
from Source/internalJSONNode.cpp:1:
Source/../JSONOptions.h:46:1: warning: "JSON_SAFE" redefined
<command-line>: warning: this is the location of the previous definition
In file included from Source/JSONChildren.h:4,
from Source/internalJSONNode.h:5,
from Source/internalJSONNode.cpp:1:
Source/JSONMemory.h: In function 'T* json_malloc(size_t)':
Source/JSONMemory.h:53: error: 'malloc' is not a member of 'std'
Source/JSONMemory.h: In function 'void libjson_free(T*&)':
Source/JSONMemory.h:65: error: 'free' is not a member of 'std'
Source/JSONMemory.h: In function 'T* json_realloc(T*, size_t)':
Source/JSONMemory.h:74: error: 'realloc' is not a member of 'std'
In file included from Source/internalJSONNode.cpp:2:
Source/NumberToString.h: In static member function 'static json_string NumberToString::_ftoa(json_number)':
Source/NumberToString.h:139: error: 'snprintf' is not a member of 'std'
Source/internalJSONNode.cpp: In member function 'void internalJSONNode::FetchNumber() const':
Source/internalJSONNode.cpp:225: error: 'atof' is not a member of 'std'
make[1]: *** [Objects_shared/internalJSONNode.o] Error 1
make[1]: Leaving directory `/Software/Broadcom/DLNA/G8/RTC-G8-MDK2.1.1.0104-BL/dbs/dbsjni/libjson'

Discussion

  • Hmm... I need a configure.sh shell, I'll write one later that looks for safe version of sprintf. But atof, malloc, free, and realloc confuses me. What is in your cstdlib header? All of those methods should be present in it.

     
  • Hi
    Thanks for the comment. I got through the above error. And succeeded in building a static library of libjson. But when i try to link libjson.a along with a few other static libs of my own in to a shared library, there are lot of link errors. These are mainly due to the fact, that the Android stdc++ support is limited. We have to build C++ code for android with -fno-exceptions and -fno-rtti options. But if i build libjson with -fno-exceptions option, it gives error because libjson uses exceptions internally even if it is disabled in the interface. Is there a way to disable exceptions internally? I looked at the code and it is only 2 files, JSONWorker.cpp and JSONPreparse.cpp that exceptions are used a bit.

     
  • Hmm, no, unfortunately, there is no way to turn off internal exceptions. I will add a way to turn them off in the next release, but it may be a few weeks, we have a few things in the pipeline.

     
  • Okay, so I looked through it for you. I don't see any throws that come outside of a method so I can give you instructions for fixing it yourself.

    Add a endofcatch: label right after the try/catch block.
    Remove the try/catch (leaving whats inside it of course)
    Replace all the throw *** with goto endofcatch.

    That will work. I realize that the use of goto might be scary, but I'm sure that in this case, it will work. This will be acceptable for you to work with until a new version of libjson with a proper fix in released.

     
    • status: open --> closed-fixed