-
Notifications
You must be signed in to change notification settings - Fork 7
Allow to disable jsoncpp #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
If a software tries to integrate rapidlib but already uses jsoncpp, then this is undefined behaviour which gets flagged by addresssanitizer for instance. I encountered this while trying to integrate RapidLib with https://ossia.io : ossia integrates sh4lt which is a completely different package for sharing video frames across processes on Linux. sh4lt also uses jsoncpp as part of its implementation thus jsoncpp symbols are defined twice (and the unlucky software crashes on startup).
Does it work if json.cpp is included privately? Like:
? |
oops, I should fix that on my PR, a .cpp should never be target_sources(PUBLIC) |
I was wondering if there was a conflict if RapidLib integrates json.cpp privately. I think it should not conflict with sh4lt then. That's what "private" means, right? |
I just pushed some changes that might resolve your issue. |
heya! sadly this is not what
For instance if I do, given example.cpp:
then the following build commands will be run:
e.g. each target will build the file independently just like if I had done
In the case of building a library like rapidlib we never want this because this will cause duplicate symbols and the build will just fail: if you do:
then There's really zero way to have multiple times the same symbol in a given single C++ executable, this is against the standard: https://en.wikipedia.org/wiki/One_Definition_Rule At the root this isn't even a C++ issue but an operating system issue: the operating systems' executable formats (PE on windows, ELF on Linux and MachO on Mac) only support one symbol with a given name per binary as those are basically just a hashmap (symbol name -> offset in the binary) ; if a build creates two symbols with the same name at best one gets picked at random, and if it's from two versions of say, jsoncpp, then you could have one method taken from version A and another from version B and if the data structures have changed between versions then crashes will 100% happen. The two options are: 1/ allow to enable / disable the third-party libraries What I do in my libs is leave the choice so that people using them can either use the quick way or have more control depending on their needs and the existing libraries they may already have in their build infrastructure: https://github.com/ossia/libossia/blob/master/cmake/deps/ctre.cmake |
If a software tries to integrate rapidlib but already uses jsoncpp, then
this is undefined behaviour which gets flagged by addresssanitizer for instance.
I encountered this while trying to integrate RapidLib with https://ossia.io :
ossia integrates sh4lt which is a completely different package for sharing
video frames across processes on Linux.
sh4lt also uses jsoncpp as part of its implementation thus jsoncpp symbols are defined twice
(and the unlucky software crashes on startup).