user489066
user489066

Reputation: 21

Converting static linked library to dynamic linked library under windows

I am in the midst of evaluating the benefits of changing our program from 30+ statically linked libraries to 30+ dynamically linked libraries. We hope by changing to DLL, it will reduce the link time.

One immediate problem is the requirement to add __declspec in front of all the classes to create the lib file for other dlls to link. Is there a way to get around that? Is there a flag in the compiler to force a lib generation so to make all classes inside the DLL available for export? If not, is there any existing script/program that will do that? That will certainly make the switch from statically linked library to a dynamic one a lot easier. If not, what is the rationale behind __declspec? Why not an option to make all dll functions exportable?

Thank you.

Upvotes: 2

Views: 482

Answers (2)

Sweekritee Singh
Sweekritee Singh

Reputation: 182

There is one another way to solve your problem.

You just need to create one definition file(.def) and export all the methods or class you want to share.

U will also have to set : Properties->Linker->Input->Module Definition File -> add name of your created .def file.

Now use run time dynamic linking: In project where you want to call the exported methods use LoadLibrary to get handle of your Dll and call the required method using GetProcAddress.

Upvotes: 0

MPelletier
MPelletier

Reputation: 16687

Perhaps it's too late, but have you looked into using a DEF file?

Upvotes: 1

Related Questions