I downloaded C++ libJSON from this link: https://sourceforge.net/projects/libjson/ How can I create a library using the code they have provided?
I installed MinGW, added it to the path in the environment variable and did cd to the directory, where I have the makefile and tried using mingw32-make.exe. BUT I get this error:
I understand that I need to add arguments, but I don't know what to add.. Could you please assist? thanks!
I am working on v7.6.1 (latest at this point). Downloaded it from [SourceForge]: ninja9578/libjson - libjson_7.6.1.zip.
At the beginning, I thought it was a half hour problem (minor changes in the makefile, since Win's mkdir creates nested dirs by default, and doesn't accept a -p argument).
To make things clear, I tried running MinGW's mingw32-make from Win's cmd window (no additional wrappers involved).
So, I started inserting (in the makefile) conditional commands (based on OS), but it was not enough. The changes needed by the original makefile to accommodate this scenario, seemed simply too large (making the file harder to understand) compared to the gain: work on an environment that too few people care about, so the logical solution was to create a separate makefile (called it Makefile.mak)
Nevertheless, the official doc ("${LIBJSON_SRC_DIR}/Documentation.pdf") states that:
I didn't get through the whole .pdf to see what are the required conditions for that to happen, but (besides that it doesn't work - hence the existence of this question) looking at the makefile, there are some things that don't look right:
rm -f
vs.del /Q /S
)cd
- which doesn't change the environment (cwd), leading to the next command failure), also the command separator (;), doesn't work as expectedI "converted" the makefile, considering that current Nix (Lnx) behavior should be preserved on Win, and I also found some (syntax) errors (so, apparently the Nix version was not working either - well the library was built, but that's about it). Fixed the errors, and then wanted to post the answer on the official site (so that anyone who used to follow it, should be aware of the changes).
Briefly looked, and noticed that last action is from 180622 (there are more, around that date). But when took a closer look, it seems that the last actual work was done 5 years ago (2013), so I'm not sure if it's maintained (also quick browsed GitHub, but didn't find it).
Anyway, I contacted the author, as I don't have permissions to open tickets (submit patches), but I got no reply, so I started a thread: [SourceForge]: ninja9578/libjson - Request for permissions to submit a patch. I will submit the patch (provided that the permissions will be granted to me).
Long story short
Anyway, here's the Win makefile (mostly copied from original one):
Makefile.mak:
Steps:
mingw32-make -f Makefile.mak
)set SHARED=1
before invoking mingw32-makeWhen building the lib, I've encountered a strange thing that you should be aware of. Here are the tool versions / environments that I've worked on:
3 of those worked fine, but for #3., I got:
I don't know why this happens (probably a g++ config issue?), but in order to get around it, you should add the -fpermissive compile flag (as instructed by the error message) to cxxflags_default variable in line #146:
This is for the default build, if you choose another variant (debug, small) you'll have to modify the appropriate variable.
Although it wasn't required in the question, I'm also posting the fixes for the Nix part (which are somehow related, since I've discovered them while working on this answer).
libjson-7.6.1-nix_makefile.patch:
The above is a diff. See [SO]: Run/Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (@CristiFati's answer) (Patching utrunner section) for how to apply patches on Win (basically, every line that starts with one "+" sign goes in, and every line that starts with one "-" sign goes out). I am using Cygwin, btw.