Trying to build a static library from the jsoncpp library (amalgamated version) so I can link it with my main project that uses it (but errors due to multiple "undefined references" from the library). However, it errored to (including full log):
-------------- Build: Debug in jsoncpp (compiler: GNU GCC Compiler)---------------
WARNING: Can't read file's timestamp: D:\_a\jsoncpp\main.c
cmd /c if exist bin\Debug\libjsoncpp.a del bin\Debug\libjsoncpp.a
ar.exe -r -s bin\Debug\libjsoncpp.a obj\Debug\main.o
ar.exe: creating bin\Debug\libjsoncpp.a
ar.exe: obj\Debug\main.o: No such file or directory
Process terminated with status 1 (0 minute(s), 1 second(s))
1 error(s), 1 warning(s) (0 minute(s), 1 second(s))
When I was creating the project via the wizard, I changed no options other than name of the project. Is there something I missed or is there something wrong?
Does D:\_a\jsoncpp\main.c exist? Can you remove the underscore from the path and try again?
Well, that's the actual folder's name ("_a") since I want it above other folders when I access D:\. Anyways, should it be a .c file and not a .cpp file? The JsonCPP library is in .cpp source file format, with some header files in a separate folder in it.
File hierarchy of jsoncpp (amalgamated):
./
|
---- jsoncpp
|
---- json.h
---- json-forwards.h
|
---- jsoncpp.cpp
So it's not D:\_a\jsoncpp\main.c but D:\_a\jsoncpp.cpp
Oops. Sorry to confuse you about the path. The full path is actually D:\_a\jsoncpp\jsoncpp.cpp.
What I meant there is the projects folder being named "_a". I forgot to mention that "jsoncpp" is under that folder, of which this folder was created by Code::Blocks from the wizard.
You must remove main.c from the project and add jsoncpp.cpp. Probably main.c is the default file created by the wizard, and it is not necessary.
Quote from: Miguel Gimenez on September 04, 2021, 01:23:26 PM
You must remove main.c from the project and add jsoncpp.cpp. Probably main.c is the default file created by the wizard, and it is not necessary.
I just did. I did replace it, as well as copying in also the jsoncpp folder containing its header files.
Does it work now?
nope. same thing.
The log must be different, please post it.
The log was the same as the first post. However I just solved my problem.
So, I was quite curious what the .cbp file looks like inside, which I then found out to be in an XML format. Looking through the tags, I found the tag '<Unit filename="main.c">'. I tinkered it by replacing it with "jsoncpp.cpp".
At first, I thought it didn't do anything when I try to rebuild it.
Then I thought of relaunching Code::Blocks and open the project file afterwards to load up from the modded .cbp file.
And so I did, then opened the "jsoncpp.cpp" file, pressed F9, and it is fixed.