3

I've created both a static lib and an EXE file (which uses the static lib), but when I open up the EXE in IDA pro, the exports are listed in the EXE as well.

I know they should be exported in the .lib itself, but why are they showing up as exports in the EXE too?

EDIT: Here is an export/import (they are in separate header files)

Here is the export:

#define NC_LIBEXPORT(a) extern "C" __declspec(dllexport) a __cdecl
NC_LIBEXPORT(VOID) rol8(unsigned char* a, unsigned char b);

and the import:

extern "C" VOID rol8(unsigned char* a, unsigned char b);
Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
  • 2
    It doesn't come from the header file, the attribute is attached to the identifier in the .obj file inside the .lib. You would have to build a special version of the .lib that prevents the __declspec being applied. Not so sure that's worth it if you also link the .lib into a DLL, it's not like any code is actually going to use the export. – Hans Passant May 19 '12 at 14:11
  • @Hans Yes, I just worked that out the slow way. By building a test project! – David Heffernan May 19 '12 at 14:19
  • Thank you @HansPassant :] That did it! Didn't realize static libs don't need `dllexport` :] Two static libs is, for this project, fine with me. Just a macro edit. – Qix - MONICA WAS MISTREATED May 19 '12 at 14:20

1 Answers1

5

You need to make sure that when you build the static lib, you do not use __declspec(dllexport).

If you want to use the same lib in a DLL and in your executable, and you don't want the executable to export the symbols, then you'll need to use a DEF file rather than __declspec(dllexport).

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490