1

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

一二三
  • 21,059
  • 11
  • 65
  • 74
  • .map file? I think VS can generate .map files. – fefe Jan 03 '12 at 14:39
  • Possible duplicate: http://stackoverflow.com/questions/225432/export-all-symbols-when-creating-a-dll – Asaf Jan 03 '12 at 15:20
  • Are you certain LGPL does not allow you to link the library statically? That isn't my understanding. (For one thing, wasn't LGPL invented *before* dynamic linking was invented?) – Harry Johnston Jan 05 '12 at 01:00
  • Fete-> Sorry for the typo, I mean to say .def file, not .map. – user1128000 Jan 05 '12 at 10:21
  • Harry Johnson-> You are right, LGPL is old, but LGPL 3.0 is from June 2007 :). You can check here: http://www.gnu.org/licenses/lgpl.html Among other things it says: 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. – user1128000 Jan 05 '12 at 10:23
  • Yes, it's possible with newest version of the CMake. Look at my answer for clarification: http://stackoverflow.com/a/32284832/3001953 – Maks Aug 29 '15 at 10:50

2 Answers2

1

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.

parapura rajkumar
  • 24,045
  • 1
  • 55
  • 85
  • Thank you for your answer. Well, they are open to dynamic linking. However, they are academic people writing for Linux (the library is for numerical modelling) and even if they approve the addition of the export statements they won't be motivated to maintain them, as it's not needed under Linux. – user1128000 Jan 03 '12 at 14:49
0

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

cppKoder
  • 1
  • 2