Cheeso
Cheeso

Reputation: 192417

In a VC++ project in Visual Studio, how to I specify /EXPORT symbols?

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?

Upvotes: 3

Views: 8597

Answers (4)

Toby
Toby

Reputation: 21

or you can try:

cl /LD hellodll.cpp /link /EXPORT:func01 /EXPORT:func01

for functions that is not specified by "_declspec(dllexport)"

Upvotes: 2

ChrisW
ChrisW

Reputation: 56083

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.

Upvotes: 4

Michael Burr
Michael Burr

Reputation: 340168

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.

Upvotes: 3

Promit
Promit

Reputation: 3507

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.

Upvotes: 1

Related Questions