Static and dynamic linking in C++: what to choose for performance and size?
Hi everyone! I'm a beginner C++ developer, and I'm confused about the types of linking. I'm writing a small project — an image processing utility, using the libpng and zlib libraries. I built two versions: with static linking (the .exe file weighs 12 MB) and with dynamic linking (I use .dll, the exe size is 500 KB, but .dll files are needed alongside).\n\nHere's an example of simplified code I'm testing:\n\n```cpp\n#include \n#include \n\nint main() {\n png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);\n if (!png_ptr) {\n std::cerr << "Failed to create PNG struct";\n return 1;\n }\n std::cout << "PNG library initialized successfully";\n png_destroy_read_struct(&png_ptr, nullptr, nullptr);\n return 0;\n}\n```
No answers yet.
Log in to leave an answer