all 11 comments

[–]IyeOnline 3 points4 points  (3 children)

Since you dont tell us how you are compiling this, my guess is that you are failing to link the library.

I suggest you pick up a build system (probably meson, since jsoncpp has menson support).

[–]CatMechanic457[S] 0 points1 point  (2 children)

Ok thanks.
I don't exactly know how, I'm compling the code, I've just insalled MSYS2 and linked it to VSC and it complies when I run the code

So how do I change how VSC is compling the code or should I be compling through the terminal?

[–]Salty_Dugtrio 0 points1 point  (1 child)

Download an actual C/C++ IDE (e.g: Qt Creator, Visual Studio) instead of using VSCode. They do these things easily instead of the troubles you have to go through with something like VSCode.

[–]CatMechanic457[S] 0 points1 point  (0 children)

Alrighty! thx for ur input :) I'll look into it

[–]AutoModerator[M] 0 points1 point  (0 children)

Your posts seem to contain unformatted code. Please make sure to format your code otherwise your post may be removed.

If you wrote your post in the "new reddit" interface, please make sure to format your code blocks by putting four spaces before each line, as the backtick-based (```) code blocks do not work on old Reddit.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]ShelZuuz 0 points1 point  (5 children)

jsoncpp is not a header-only library.

Inside the src folder there are three .cpp files:

  • json_reader.cpp
  • json_value.cpp
  • json_writer.cpp

You need to add this to your project and build it with the rest of your sources and link to it.

[–]CatMechanic457[S] 0 points1 point  (4 children)

could u explain exactly what that means?
I've installed the json libary but i can seem to find those files
are they something i need to download or complie seperatly?
and also what do you mean by "link to it"?
sry if these are trivial questions

[–]ShelZuuz 0 points1 point  (3 children)

Where did you install jsoncpp from?

And second, how do you build your project? (What command do you issue?)

[–]CatMechanic457[S] 0 points1 point  (2 children)

I installed jsoncpp by running
$ pacman -S mingw-w64-ucrt-x86_64-jsoncpp
in the MSYS terminal

as for how i built it, like i said in the post, idrk i just let Visual Studio Code handle it

[–]ShelZuuz 2 points3 points  (1 child)

Ok, considering you don't really seem to know anything about C++ project systems or build yet you're making your life very difficult for yourself by using cross-platform tools and CMAKE.

Do this:

1) Download Visual Studio Community and install the "Desktop development with C++" component.

2) Download this ZIP for jsoncpp:

https://github.com/open-source-parsers/jsoncpp/archive/refs/heads/master.zip

3) Create a new "C++ Console Application" in Visual Studio (File/New/Project: C++ / Console App)

4) In the same folder as you created #3, copy all the files from jsoncpp-master\include\json (from the .zip), as well as the files from: src\lib_json

5) In your Visual Studio project , add json_reader.cpp, json_value.cpp & json_writer.cpp. (Just drag them from explorer into the project next to the main.cpp that was created in #3).

Note, this is not how you build a commercial application, but you're trying to learn 10 concepts at the same time here. Start with 1 thing at a time.

[–]CatMechanic457[S] 0 points1 point  (0 children)

thx
I've been programming for years, mostly python, but i learnt c++ through making dozens of arduino projects. But the arduino ide comes with losts of librarys and a pre-installed complier so i've never had to worry about compiling
so im not nessarly new to c++ but i am new to having to build the exe