Matin Lotfaliee Matin Lotfaliee - 1 year ago 95
C++ Question

How to build an standalone shared library in C++ using qmake?

I have written a shared library in C++ using qt creator and QMake

When I compile my project with MinGW compiler, I need the libraries

to be copied next to my DLL in order to work. Which has about 1.5 megabytes size.

When I compile my project with MSVC 2015 compiler, I need to install the
Visual C++ Redistributable 2015 x86
on the deployment system. Which has about 13 megabytes size.

My project has less than 100 kiloobytes size so these dependencies are so big.

How can I embed them into my library? or How can I have fewer dependencies to be installed or copied next to my project in Windows 7 or upper?

PS 1: I have read this, but the MinGW method was the same as before. And I encountered errors in Microsoft Tools method.

PS 2: Maybe .Net Framework 2.0 is a better option because it is preinstalled on Windows 7 and we can force .Net 4.5 to run it in Windows 8/8.1/10. Don't you agee?

Answer Source

Just link standard libraries statically. Your DLL size will increase obviously (I hope it isn't a problem) but not that much (<1 MB).

To do that:

If you use MSVC add /MT to command line (you can find it in project properties window too).

If you use g++ add '--static' .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download