title: Compiling command line with libraries in Linux with GCC
body: <p>I'm Android developer and engineer in computer vision.</p>
  
  <p>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).</p>
  
  <p>The problem that I'm having is that the library <code>JSONCPP</code> isn't being recognized. I compile it with:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>Which part of the output is:</p>
  
  <blockquote>
    <p>/home/ec2-user/project/utils.cpp:2475: undefined
    reference to `Json::Value::Value(Json::ValueType)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2478: undefined
    reference to `Json::Value::Value(Json::ValueType)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2479: undefined
    reference to `Json::Value::Value(Json::ValueType)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2484: undefined
    reference to `Json::Value::Value(int)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2484: undefined
    reference to `Json::Value::append(Json::Value const&amp;)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2484: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2486: undefined
    reference to `Json::Value::Value(std::string const&amp;)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2486: undefined
    reference to `Json::Value::operator[](char const*)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2486: undefined
    reference to `Json::Value::operator=(Json::Value)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2486: undefined
    reference to  `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2487: undefined
    reference to `Json::Value::Value(Json::Value const&amp;)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2487: undefined
    reference to `Json::Value::operator[](char const*)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2487: undefined
    reference to `Json::Value::operator=(Json::Value)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2487: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2488: undefined
    reference to `Json::Value::append(Json::Value const&amp;)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2479: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2489: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2491: undefined
    reference to `Json::StyledWriter::StyledWriter()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2492: undefined
    reference to `Json::StyledWriter::write(Json::Value const&amp;)'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2475: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2484: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2486: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2487: undefined
    reference to `Json::Value::~Value()'</p>
    
    <p>/home/ec2-user/project/utils.cpp:2479: undefined
    reference to `Json::Value::~Value()'</p>
  </blockquote>
  
  <p>I have to mention that I have compiled this for Android (NDK) before with a this Makefile:</p>
  
  <blockquote>
    <p>LOCAL_PATH := $(call my-dir)</p>
    
    <p>include $(CLEAR_VARS)</p>
    
    <p>OPENCV_CAMERA_MODULES:=off</p>
    
    <p>OPENCV_INSTALL_MODULES:=on</p>
    
    <p>include $(LOCAL_PATH)/jsoncpp/Android.mk</p>
    
    <p>include
    /Users/rafaelruizmunoz/Desktop/AndroidDevelopment/OpenCV-2.4.9-android-sdk/sdk/native/jni/OpenCV.mk</p>
    
    <p>OPENCV_LIB_TYPE:=SHARED</p>
    
    <p>LOCAL_C_INCLUDES += $(LOCAL_PATH)</p>
    
    <p>LOCAL_C_INCLUDES += /Users/rafaelruizmunoz/OpenCVtry/</p>
    
    <p>LOCAL_C_INCLUDES +=
    /Users/rafaelruizmunoz/Desktop/RD/OpenCVtry/Libraries/jsoncpp-master/include</p>
    
    <p>LOCAL_PATH := jni</p>
    
    <p>LOCAL_ALLOW_UNDEFINED_SYMBOLS := true</p>
    
    <p>LOCAL_MODULE    := libXYZ</p>
    
    <p>LOCAL_MODULE_NAME    := mylibXYZ</p>
    
    <p>LOCAL_SRC_FILES := facerecognition.cpp androidClass.cpp main.cpp
    utils.cpp helper.cpp lbp.cpp</p>
    
    <p>LOCAL_LDLIBS     += -llog -ldl</p>
    
    <p>LOCAL_CPPFLAGS    := -std=c++11</p>
    
    <p>LOCAL_CFLAGS := -w</p>
    
    <p>CFLAGS=-w -g -Wall -Wextra -std=c++11 -Wno-write-strings
    ../../include/boost</p>
    
    <p>LOCAL_SHARED_LIBRARIES := libJsoncpp libopencv_java</p>
    
    <p>include $(BUILD_SHARED_LIBRARY)</p>
  </blockquote>
  
  <p>which worked perfectly.</p>
  
  <p>On my Mac it compiles perfectly. What I had to do is the JSONCPP Makefile with Xcode generator and adding as a project:</p>
  
  <p><img src="https://i.stack.imgur.com/AYJDw.png" alt="enter image description here"></p>
  
  <p>But I'm getting out of clues for compiling it into Linux.</p>
  
  <p>Would you know what to do?
  Thanks in advance.</p>
  
  <p>Regards.</p>