SimpleJSON icon indicating copy to clipboard operation
SimpleJSON copied to clipboard

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

Open frans-fuerst opened this issue 10 years ago • 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

frans-fuerst avatar Dec 20 '15 11:12 frans-fuerst

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

eduard739 avatar Feb 05 '17 15:02 eduard739

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

eduard739 avatar Feb 06 '17 09:02 eduard739

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.

nbsdx avatar Feb 07 '17 04:02 nbsdx

@eduard739 thank you! totally solved my problem

jyesselm avatar Jan 01 '18 04:01 jyesselm

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

Amazonasmann avatar Dec 04 '18 13:12 Amazonasmann