Questions tagged [dllexport]

__declspec(dllexport) is a C and C++ compiler directive, which automates exporting of functions or variables when creating a DLL (Dynamic-link library).

This directive originates from Microsoft. It eliminates the need for providing .def files and (along with the corresponding __declspec(dllimport) directive) makes it easier to work with DLL files.

Other compilers, like GCC or DMC, also support this directive, but the exact behavior varies.

747 questions
43
votes
4 answers

Is is possible to export functions from a C# DLL like in VS C++?

In VS C/C++ you could use extern "C" __declspec(dllexport) -function declaration-. How do I accomplish this in a C# dll? Is there C# code equivalent to the above code? Edit: More info I am trying to create an add in for Notepad++ and I want to use…
Mike Webb
  • 8,855
  • 18
  • 78
  • 111
36
votes
6 answers

Exporting static data in a DLL

I have a DLL which contains a class with static members. I use __declspec(dllexport) in order to make use of this class's methods. But when I link it to another project and try to compile it, I get "unresolved external symbol" errors for the static…
Gayan
  • 1,697
  • 7
  • 26
  • 35
27
votes
3 answers

error C1854: cannot overwrite information formed during creation of the precompiled header in object file

foo.cpp(33918) : fatal error C1854: cannot overwrite information formed during creation of the precompiled header in object file: 'c:\somepath\foo.obj' Consulting MSDN about this gives me the following information: You specified the /Yu (use…
rtn
  • 127,556
  • 20
  • 111
  • 121
24
votes
4 answers

How to use a class in DLL?

Can I put a class inside a DLL? The class i wrote is this: class SDLConsole { public: SDLConsole(); ~SDLConsole(){}; void getInfo(int,int); void initConsole(char*, char*, SDL_Surface*,…
r1cebank
  • 345
  • 1
  • 3
  • 12
24
votes
4 answers

Warning C4251 when building a DLL that exports a class containing an ATL::CString member

I am converting an ATL-based static library to a DLL and am getting the following warning on any exported classes that use the ATL CString class (found in atlstr.h): warning C4251: 'Foo::str_' : class 'ATL::CStringT' needs to have dll-interface…
Rob
  • 76,700
  • 56
  • 158
  • 197
17
votes
2 answers

unresolved external symbol for __declspec(dllimport) when using dll to export class

I want to define a derived class based on a dll exported class. The base class is defined in Project A, and the derived class is in Project B. Firstly, in Project A, preprocessor MYDLL_BUILD is defined. And I use a header file to specify…
Chtoucas
  • 171
  • 1
  • 1
  • 4
17
votes
2 answers

stdcall name mangling using extern c and dllexport vs module definitions (msvc++)

I was trying to export a simple test function for a dll to work with an application (fyi: mIRC) that specifies the calling convention as: int __stdcall test_func(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause) Now, to call…
mina
  • 439
  • 2
  • 7
  • 13
17
votes
1 answer

How to dllexport a class derived from std::runtime_error?

I have set up a library providing an exception class derived from the standard exception: #include #include class BaseException : public std::runtime_error { public: BaseException( std::string const & msg ); }; So…
DevSolar
  • 67,862
  • 21
  • 134
  • 209
16
votes
4 answers

Export dll method from C++ to C#. Why I need: " extern "C" "

In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) //Wont work __declspec(dllexport) C++ Export: extern "C" __declspec(dllexport) int Test(); C# import: [DllImport("CircleGPU2_32.DLL", EntryPoint =…
Pedro77
  • 5,176
  • 7
  • 61
  • 91
15
votes
1 answer

Export function to DLL without class

Is there a way to export only a function to DLL cos in tutorials they always export classes with something like: static __declspec(dllexport) double Add(double a, double b); Inside a class the statement above does not cause any problem, but…
Shibli
  • 5,879
  • 13
  • 62
  • 126
15
votes
5 answers

How do I DllExport a C++ Class for use in a C# Application

I have created a C++ Dll project which contains a class "myCppClass" and tried to Dll export it using the following code as described by: http://msdn.microsoft.com/en-us/library/a90k134d(v=vs.80).aspx class __declspec(dllexport) CExampleExport :…
Toymakerii
  • 1,510
  • 2
  • 12
  • 26
14
votes
8 answers

Creating a C# DLL and using it from unmanaged C++

I have a native (unmanaged) C++ application (using wxWidgets for what it's worth). I'm considering a separate tool application to be written in C# which would contain winform-based dialogs. putting some of those dialogs in a separate DLL would be…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
13
votes
3 answers

__declspec(dllimport) how to load library

http://msdn.microsoft.com/en-us/library/9h658af8.aspx MSDN says I can export function from the library with __declspec(dllexport) but how can I load this library in my executable? I've got an exported function in DLL: __declspec(dllexport) void…
deepspace
  • 771
  • 3
  • 11
  • 25
12
votes
3 answers

Automatically generate a DLL .DEF file in Visual Studio?

Is there any way to automatically generate the DEF file for a DLL in Visual Studio? I've always just manually created them before, but there's gotta be an easier way.
Adam Haile
  • 30,705
  • 58
  • 191
  • 286
11
votes
5 answers

DLL without exported functions?

I've snooped around a little bit in MS-Office DLLs, and I noticed that some of the DLLs don't have any exported functions. What I don't quite understand, how an application can use these DLLs without any functions exported ?! I mean, the dllmain()…
TCS
  • 5,790
  • 5
  • 54
  • 86
1
2 3
49 50