1
votes

I'm Android developer and engineer in computer vision.

I'm making a project of computer vision with OpenCV on a Mac, with OS X 10.9.5 in Xcode and it's cross-platform, so what I'm doing is a command line to compile into linux and access to it (server).

The problem that I'm having is that the library JSONCPP isn't being recognized. I compile it with:

g++ -I/home/ec2-user/project/opencv/include/249include/include/ -L/home/ec2-user/project/opencv/build/lib/ -L/home/ec2-user/project/lib/ -I/home/ec2-user/project/jsoncpp-master/include/ -g -o binary main.cpp facerecognition.cpp utils.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_stitching -lopencv_flann -w -std=c++11

Which part of the output is:

/home/ec2-user/project/utils.cpp:2475: undefined reference to `Json::Value::Value(Json::ValueType)'

/home/ec2-user/project/utils.cpp:2478: undefined reference to `Json::Value::Value(Json::ValueType)'

/home/ec2-user/project/utils.cpp:2479: undefined reference to `Json::Value::Value(Json::ValueType)'

/home/ec2-user/project/utils.cpp:2484: undefined reference to `Json::Value::Value(int)'

/home/ec2-user/project/utils.cpp:2484: undefined reference to `Json::Value::append(Json::Value const&)'

/home/ec2-user/project/utils.cpp:2484: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2486: undefined reference to `Json::Value::Value(std::string const&)'

/home/ec2-user/project/utils.cpp:2486: undefined reference to `Json::Value::operator[](char const*)'

/home/ec2-user/project/utils.cpp:2486: undefined reference to `Json::Value::operator=(Json::Value)'

/home/ec2-user/project/utils.cpp:2486: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2487: undefined reference to `Json::Value::Value(Json::Value const&)'

/home/ec2-user/project/utils.cpp:2487: undefined reference to `Json::Value::operator[](char const*)'

/home/ec2-user/project/utils.cpp:2487: undefined reference to `Json::Value::operator=(Json::Value)'

/home/ec2-user/project/utils.cpp:2487: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2488: undefined reference to `Json::Value::append(Json::Value const&)'

/home/ec2-user/project/utils.cpp:2479: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2489: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2491: undefined reference to `Json::StyledWriter::StyledWriter()'

/home/ec2-user/project/utils.cpp:2492: undefined reference to `Json::StyledWriter::write(Json::Value const&)'

/home/ec2-user/project/utils.cpp:2475: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2484: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2486: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2487: undefined reference to `Json::Value::~Value()'

/home/ec2-user/project/utils.cpp:2479: undefined reference to `Json::Value::~Value()'

I have to mention that I have compiled this for Android (NDK) before with a this Makefile:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

OPENCV_CAMERA_MODULES:=off

OPENCV_INSTALL_MODULES:=on

include $(LOCAL_PATH)/jsoncpp/Android.mk

include /Users/rafaelruizmunoz/Desktop/AndroidDevelopment/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk

OPENCV_LIB_TYPE:=SHARED

LOCAL_C_INCLUDES += $(LOCAL_PATH)

LOCAL_C_INCLUDES += /Users/rafaelruizmunoz/OpenCVtry/

LOCAL_C_INCLUDES += /Users/rafaelruizmunoz/Desktop/RD/OpenCVtry/Libraries/jsoncpp-master/include

LOCAL_PATH := jni

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

LOCAL_MODULE := libXYZ

LOCAL_MODULE_NAME := mylibXYZ

LOCAL_SRC_FILES := facerecognition.cpp androidClass.cpp main.cpp utils.cpp helper.cpp lbp.cpp

LOCAL_LDLIBS += -llog -ldl

LOCAL_CPPFLAGS := -std=c++11

LOCAL_CFLAGS := -w

CFLAGS=-w -g -Wall -Wextra -std=c++11 -Wno-write-strings ../../include/boost

LOCAL_SHARED_LIBRARIES := libJsoncpp libopencv_java

include $(BUILD_SHARED_LIBRARY)

which worked perfectly.

On my Mac it compiles perfectly. What I had to do is the JSONCPP Makefile with Xcode generator and adding as a project:

enter image description here

But I'm getting out of clues for compiling it into Linux.

Would you know what to do? Thanks in advance.

Regards.

1
You're getting errors compiling utils.cpp which feels more like you're either missing an #include line for the JSON stuff, or (depending what messages you've omitted) it's not finding the included file. It doesn't look like you've got to link/library problems yet. - TripeHound
Hi @TripeHound thank you for your reply. I added a new include: -I/home/ec2-user/project/json/ .... got other errors. Solved them but after that I get the same errors that I've mentioned.... :\ - Rafael Ruiz Muñoz
Can't do much more than repeat the earlier questions: does your utils.cpp have appropriate #include line(s) and are there earlier errors about not finding any include files? - TripeHound

1 Answers

0
votes

This is a guess based on your Android makefile, since I can't see the included "BUILD_SHARED_LIBRARIES", but I noticed you've got:

"LOCAL_SHARED_LIBRARIES := libJsoncpp libopencv_java"

I imagine you would need "-lJsoncpp -lopencv_java" on your g++ command line.

You have to be sure both libraries have been built and can be found in one of the "-L" paths