nbsdx/SimpleJSON

cannot include json.hpp from more than one cpp file due to multiply defined symbols

frans-fuerst opened this issue · 5 comments

including json.hpp in multiple cpp files leads to linker errors:

file1.o: In function `json::Array()':
json.hpp:410: multiple definition of `json::Array()'
file2.o:json.hpp:410: first defined here
file1.o: In function `json::Object()':
json.hpp:421: multiple definition of `json::Object()'

Compiler is gcc 5.1.1 building on Fedora 22

i have the same problem. tried everything. it wont go away

fixed the issue: although i created a cpp file, and i do not know how to developer wanted the lib to be(i think it meant to be only hpp file) so i will not commit. all you have to do it to take JSON::load implementation and put it in a cpp file. and add template <typename... T> above the functions:
JSON Object, operator<< and JSON Array

nbsdx commented

Not gonna lie, I totally forgot this issue was here.

I have to rewrite the parser because of #8 so I'll likely fix this at the same time. Things need to be restructured anyways.

Unfortunately it might be a little while until I can fix it, I'm in the middle of changing jobs and moving so I'm kinda swamped.

@eduard739 thank you! totally solved my problem

Just a reminder.. I started using this lib and now I am encountering the same problem!