1

I got this massive project with many classes with definitions in dll files. I need to extract a part of this project and create a new project from that part. I have managed to find some dll files by using the Code Map in Visual Studio but some classes are not shown up there.

#   ifdef FCBase
#       define BaseExport  __declspec(dllexport)
#   else
#       define BaseExport  __declspec(dllimport)
#   endif

class BaseExport Handled
{.
 .
};

What is specifying which dll files are linked to what?

Rasmus
  • 65
  • 2
  • 11
  • The linker's Additional Dependencies setting. It might also be done in source code with #pragma comment. And you can always find out from the executable files itself with Dumpbin.exe /imports – Hans Passant Nov 17 '15 at 13:59
  • The thing is that that folder stores 273 lib files, I only need a few but I cant figure out how to find them. How is Dumpbin.exe /imports working? could you supply me with a link? – Rasmus Nov 17 '15 at 14:28

1 Answers1

1

Directive __declspec(dllexport) indicates that anything declared with this directive will be exported from a DLL to be used in some other application that links to that DLL. So when writing header files for code that will be compiled into a DLL, functions declarations and class definitions are decorated with this directive. On the other hand, code that will use these functions and classes will need to declare them with __declspec(dllimport), to let the linker know they will be imported from a DLL.

Both directives are often replaced by a single macro, which resolves to appropriate value depending on project settings. This way, you can include the same header in DLL implementation files and implementation files for some other application that will use this DLL. For instance, in your case the project for DLL will have FCBase defined so BaseExport will resolve to __declspec(dllexport) during preprocessing step. That indicates that this project is for implementation of DLL. Project that does not have FCBase defined, which means that the project is importing functions an classes from DLL.

Marko Popovic
  • 3,999
  • 3
  • 22
  • 37
  • Can I found which DLL it is importing from? – Rasmus Nov 17 '15 at 11:46
  • @Rasmus Not sure how this massive project is ogranized, is it one VS solution with multiple VS projects? Anyway, the header files declaring exported functions and classes should reside within the corresponding DLL project folder (on the filesystem, not in VS solution explorer). This way, you can determine from which DLL a certain function or class is exported. – Marko Popovic Nov 17 '15 at 12:45
  • yes it is multiple vs projects in one solution.That is not the way this project is organized. All the header files are located in one folder and all the DLL are in one same bin folder. – Rasmus Nov 17 '15 at 12:48
  • 1
    @Rasmus Then you can use dumpbin utility that ships with Visual Studio. For VS2015, it is located in folder "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin", but you can access it directly by opening VS command prompt window. Example of usage: dumpbin.exe /EXPORTS dll_file.dll This will print some details about DLL file and a table of exports (containing names, ordinals, RVAs, ...) – Marko Popovic Nov 17 '15 at 13:13