views:

1209

answers:

4

I have a makefile project that builds and links a DLL, using the command-line cl.exe compiler, which is included in the VC++ Express (free) tool. I now want to convert that makefile project into a Visual Studio project.

The DLL is not actually C++; it's all written in C.

The DLL exports a small number of symbols, functions that are called by other programs that link to the DLL. I believe that in order to produce this DLL, I need to include an /EXPORT:Foo statement on the link command line, for each exported symbol.

How do I do the same in Visual Studio 2008? How do I specify the linker options to export a specific, small set of functions from the DLL?

+1  A: 

I don't see a GUI option for it, so you could just add it manually under Command Line under Linker in the project's Properties. I think most people use a DEF file for this, though.

Promit
+2  A: 

You will have to use the "Additional Options" in the linker "Command Line" property and add the options explicitly.

I think that most people use the __declspec(dllexport) attributes along with macros to make it more usable and to make the declspec a dllimport version in the headers for clients of the library.

Michael Burr
+3  A: 

See the first couple of subsections of Exporting from a DLL, which says,

You can export functions from a DLL using two methods:

Create a module definition (.def) file and use the .def file when building the DLL. Use this approach if you want to export functions from your DLL by ordinal rather than by name.

Use the keyword __declspec(dllexport) in the function's definition.

ChrisW
A: 

or you can try: cl /LD hellodll.cpp /link /EXPORT:func01 /EXPORT:func01 for functions that is not specified by "_declspec(dllexport)"

Toby
Right, but the question was how to do it within Visual Studio, not how to do it on the command line. In fact in my question I even stated that I could do it on the command line with the `/EXPORT` option.
Cheeso