user1128000
user1128000

Reputation: 11

how to automatically export names in C++ source to be used in DLL

I have a library, written in C++ (and I have its full source). Due to its LGPL license I can only use it with the proprietary software of my company via dynamic linkage (static linkage works fine). So, I need to build it into a DLL. However, the library is quite big and doesn't export anything (hence no .def file and no __declspec(dllexport) statatements in front of the class and global function names). So, when I build a dll, it's useless, as it doesn't have exported names, so it won't link. In our company we are using MS Visual C++, which by default does not export names (while, for instance, GNU GCC, when run via MINGW on Windows does). So, the only option I see at the moment is placing __declspec(dllexport) in front of every name in the library that I'm using (and there are thousands), or writing a .def file for those names. But even if I did that, I will not be able to use the next version of the library, as I'll have to do this job again. I was looking for a tool that does these exports, or generates a .map file, but none really do this specific task (there are some DEF generators, but they mostly search the result of DUMPBIN /EXPORT which gives nothing in my case). I was searching the web for answers for two days now, but no good result.

Best regards, Andriy

Upvotes: 1

Views: 418

Answers (2)

cppKoder
cppKoder

Reputation: 1

I don't think that there is such a automation you want.

My suggestion is editing the source code (as you said); using Notepad++'s macros or using Replace Pioneer

Regards

Upvotes: 0

parapura rajkumar
parapura rajkumar

Reputation: 24413

IANAL But if the library is LPGL they should be open to dynamic linking.

Have you considered modifying the source file and updating Makefile to give a way to generate the dynamic library and getting it approved by the maintainer ? Chances are they will be open to it and future versions will just work.

Upvotes: 1

Related Questions