Embedding in C++ Project using MinGW

Help
Screeze
2014-03-08
2014-03-08
  • Screeze
    Screeze
    2014-03-08

    Hi,
    Sorry for my newbie question, but I'm trying to include libjson into my c++ project since more than 4 hours but all i do is failing :D

    So, here's my setup:
    - Windows 8.1 64 bit
    - eclipse IDE for c++ project
    - latest libjson zip file
    - mingw as compiler in eclipse project

    So on stackoverflow i found the following "step-by-step-guide":

    Comment out #define JSON_LIBRARY in JSONOptions.h
    Run make
    Add libjson.a to your project
    Add libjson.h to your project
    Add JSONOptions.h to your project
    Add #include "libjson.h" to your main project file
    

    So i commented out JSON_LIBRARY. I opened cmd in libjson folder and tried to use mingw32-make:

    E:.....\libs\libjson>mingw32-make
    process_begin: CreateProcess(NULL, uname, ...) failed.
    process_begin: CreateProcess(NULL, uname, ...) failed.
    process_begin: CreateProcess(NULL, uname, ...) failed.
    "============================================================"
    "libjson version: "7.6.1 "target: " "OS: "
    "============================================================"
    mkdir -p Objects_static
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/internalJSONNode.cpp -o Objects_static/internalJSONNode.o -
    c -O3 -ffast-math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONAllocator.cpp -o Objects_static/JSONAllocator.o -c -O3
    -ffast-math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONChildren.cpp -o Objects_static/JSONChildren.o -c -O3 -f
    fast-math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONDebug.cpp -o Objects_static/JSONDebug.o -c -O3 -ffast-m
    ath -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONIterators.cpp -o Objects_static/JSONIterators.o -c -O3
    -ffast-math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONMemory.cpp -o Objects_static/JSONMemory.o -c -O3 -ffast
    -math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONNode.cpp -o Objects_static/JSONNode.o -c -O3 -ffast-mat
    h -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONNode_Mutex.cpp -o Objects_static/JSONNode_Mutex.o -c -O
    3 -ffast-math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONPreparse.cpp -o Objects_static/JSONPreparse.o -c -O3 -f
    fast-math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONStream.cpp -o Objects_static/JSONStream.o -c -O3 -ffast
    -math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONValidator.cpp -o Objects_static/JSONValidator.o -c -O3
    -ffast-math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONWorker.cpp -o Objects_static/JSONWorker.o -c -O3 -ffast
    -math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/JSONWriter.cpp -o Objects_static/JSONWriter.o -c -O3 -ffast
    -math -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    g++ _internal/Source/libjson.cpp -o Objects_static/libjson.o -c -O3 -ffast-math
    -fexpensive-optimizations -DNDEBUG
    process_begin: CreateProcess(NULL, uname, ...) failed.
    process_begin: CreateProcess(NULL, uname, ...) failed.
    "Archive"
    cd Objects_static ; \ ar -cvq libjson.a internalJSONNode.o JSONAllocator.o JSONChildren.o JSONDebug.o
    JSONIterators.o JSONMemory.o JSONNode.o JSONNode_Mutex.o JSONPreparse.o JSONStre
    am.o JSONValidator.o JSONWorker.o JSONWriter.o libjson.o ; \ mv -f libjson.a ../
    Der Dateiname oder die Erweiterung ist zu lang.
    makefile:231: recipe for target 'libjson.a' failed
    mingw32-make: *** [libjson.a] Error 1

    So it seems like uname is not found (well I'm on windows, no wonder). But i read it should be able to build it with mingw, so what am I doing wrong?

    Thanks in advance.

     
  • Screeze
    Screeze
    2014-03-08

    Ok, finally i found a way to include it in my project. but this seems a bit hacky, so I would love to get instructions how to do it properly.

    Here is my way:
    1. Add libjson folder into libs/ in my project
    2. delete all files beginning with a "."
    3. delete all files ending with a "~"
    4. delete both TestSuite folders (eclipse complained about weird compile errors in there)
    5. in makefile comment line "test:" and every line after this one
    4. run mingw console from C:\MinGW\msys\1.0\msys.bat
    5. navigate to libjson folder in mingw console
    6. run "make"
    7. build eclipse project and start it.

    This worked for me. First i had compile errors in files starting with a "." or ending with "~". Probably they were added by a MacOS? Then i had compile errors within the TestSuites, which is why i had to remove them completely and exclude the tests from makefile.

    As I said - this seems to work - but I would prefer a clean compiling.. so if anyone can help, i would appreciate.

     
    Last edit: Screeze 2014-03-08