Just tried to use some very basic features with following source code:
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main() {
json j;
std::cin >> j;
std::cout << j["field1"];
}
The executable size is 3.05MB compiled with g++ (gcc version 9.1.0 (Rev3, Built by MSYS2 project)). Such a overhead is insane for a simple program. It is even bigger than the "json.hpp" header file (711KB).
I roughly viewed through the source code. Class methods are mostly defined in class body, which will be inlined automatically. And a lot of macros and templates are used. All these facts probably cause the bloat of binary size.
Is there any advice for reduce object file size?
Just tried to use some very basic features with following source code:
The executable size is 3.05MB compiled with g++ (gcc version 9.1.0 (Rev3, Built by MSYS2 project)). Such a overhead is insane for a simple program. It is even bigger than the "json.hpp" header file (711KB).
I roughly viewed through the source code. Class methods are mostly defined in class body, which will be inlined automatically. And a lot of macros and templates are used. All these facts probably cause the bloat of binary size.
Is there any advice for reduce object file size?