6

I'm creating a COM DLL in Visual Studio. The linker generates an import library for the DLL. I don't need the import library.

Is there any way to tell the linker not to generate it?

Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380

2 Answers2

8

Nine years later, this may not be useful to the OP, but it may prove useful to others coming by looking for a solution.

LINK.EXE supports the /NOIMPLIB option that prevents creation of an import library, even in the presence of a __declspec(dllexport) routine in the DLL or EXE being linked.

Go to Project Properties, open up the Linker section. The very last option is Command Line. Select that, and there's a place at the bottom to add additional options to the linker. Enter /NOIMPLIB in the edit field, save and apply, and it'll prevent the creation of the .lib file.

-- Edit --

Unfortunately, while it does prevent creation of the .lib file, empirically I've found that the .exp file is still created. I'd file a bug report with MS, but based on past experience with their developer tools team, trying to get something like this fixed will be akin to trying to roll a boulder up hill.

-- Edit -- four years later --

As noted in the comments, VS 2019 finally has this fixed, so that /NOIMPLIB now suppresses the creation of both the .lib and .exp files.

dgnuff
  • 3,195
  • 2
  • 18
  • 32
  • `/NOEXP` suppresses the `.exp` for me on Visual Studio 2019, as inspired by [this bug ticket](https://developercommunity.visualstudio.com/t/when-using-def-and-noimplib-with-linkexe-it-create/1495047). – Krishty May 25 '22 at 15:28
  • 1
    @Krishty It would indeed appear to have been fixed. "All hail Sisyphus!" – dgnuff May 28 '22 at 07:12
-1

This answer seems to be the solution: https://stackoverflow.com/a/15214141/660440

"Using a .def file containing your exported functions marked with the PRIVATE keyword will tell the linker to skip placing the symbol in your import library."

Community
  • 1
  • 1
Russ Freeman
  • 1,480
  • 1
  • 8
  • 6