Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I'm currently trying to migrate a legacy application from VS2003 to VS 2010. Unfortunately, after eliminating compiler errors and most warnings, I fail to link most of the libraries. The problem is that the old lib files that the linker is relying on are apparently not sufficient for the linker, and I cannot create new ones because of cyclic dependencies.

The application consists of a dozen of our own libraries as well as a few hundred external ones. Two of these libraries and the main executable are dependend on each other, and thus cannot be built.

Removing these dependencies would be the proper solution, but the project is so huge, it would take weeks, if not months, and I don't have that time right now. I've searched for ways to create just the lib files, without the DLLs, but after half a day of searching and trying various options I'm stuck.

The most promising idea I've found is the LIB tool, and using a .def file (Module Definition File). It worked well on the smaller DLL, as it already had an existigng .def file. Then I turned to the bigger one, but I couldn't locate any .def file, and didn't find any easy way to create one. All the info I've found indicates I have to manually create it, but there are hundreds of files involved, and thousands of exported functions! Not to mention I've never done it before and am unsure of what info to include, and what syntax to use.

Is there any way to automatically create a .def file from the source of a DLL that I cannot properly link? Or is there another way to create the .lib file for a DLL, even if the .lib files it itself depends on are not all present?
Posted

1 solution

There's an article here:

How to create .lib file when you only have .dll and .h files[^]

And there is a MS kb article here:

http://support.microsoft.com/kb/131313[^]

Basically, take the dll's that were built with VS2003 and use

dumpbin.exe /export mydll.dll

to get a full list of the exports.

You'll then need to modify the output of that into a valid .DEF format. The codeproject article gives you a brief description of .DEF file formats.

I think you'll need a specific column from the dumpbin output that you'll use as the EXPORTS section of your .DEF file. You can either extract the column with an editor that lets you select columns, or you can use your favorite regular expression editor or search and replace function (personnally I'd use sed or awk, but I'm old school).

Then use the lib tool.
 
Share this answer
 
Comments
Stefan_Lang 15-Jun-11 6:34am    
Thanks for pointing out the connections. I had already found the first article before but dismissed it on the basis that it required an already existing DLL. My mistake was that I didn't think to use the old DLL for this purpose.

Took me a while to find out how to properly invoke the LIB tool, but eventually it worked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900