0

I'm getting a ton of these undefined reference to errors in my code.

The errors are only coming in the functions where I am using Json. The only two functions throwing these errors are my MovieLibrary::toJsonFile(string jsonFileName) function and my MovieLibrary::MovieLibrary(string jsonFileName) function.

At the top of all of my .cpp and .h files and even the main.cpp file I have:

#include jsoncpp/json/json.h (surrounded by < >)

I'm just confused as to why I'm getting these errors. I even did:

sudo apt-get install libjsoncpp-dev and all of the installs I was supposed to for the setup.

I even went as far as to trying to add to the build.xml file because I am using Ant. I tried to add libset dir="/usr/lib" libs="libjsoncpp"/ in the "build.cpp" target. That gets rid of all of those errors but then gives me the error of:

/usr/bin/ ld: cannot find - llibjsoncpp

collect2: error: ld returned 1 exit status

So I then went back to my original build.xml file and went back to the other undefined reference errors.

Here are the errors for the undefined references stuff: undefined references errors

Codet
  • 15
  • 1
  • 1
  • 8
  • I dont know your library. But you want to look up in the documentation how you can link to the library. – hetepeperfan Sep 13 '16 at 22:28
  • Specific to your case, you are missing the reference to libjsoncpp.a in your linker settings. – Adrian Colomitchi Sep 13 '16 at 22:50
  • @AdrianColomitchi so how would I change my linker settings? or at least see what my linker settings are? – Codet Sep 13 '16 at 22:58
  • After reading the one you duplicate, I'm sure you'll find the answer (perhaps even learning how to do it next time). But in short, yes, you need to add one more library at link time, which will result in adding something to the linker CLI options. – Adrian Colomitchi Sep 13 '16 at 23:35

0 Answers0