dllexport

inconsistent dll linkage & definition of dllimport static data member not allowed

好久不见. 提交于 2019-12-01 03:53:27
Assuming I have these two files: Header.h class DLL ExportClass{ public: ExportClass(); static int test; }; Source.cpp #ifdef EXPORT #define DLL __declspec(dllexport) #else #define DLL __declspec(dllimport) #endif #include "Header.h" int ExportClass::test = 0; ExportClass::ExportClass(){ } And I won't define EXPORT (to import a already exported class with a static member), why do I get these warnings: 1>source.cpp(11): warning C4273: 'test' : inconsistent dll linkage 1> header.h(4) : see previous definition of 'public: static int ExportClass::test' 1>source.cpp(13): warning C4273: 'ExportClass

Automatically generate a DLL .DEF file in Visual Studio?

六月ゝ 毕业季﹏ 提交于 2019-12-01 02:53:55
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. user2577497 I have found a place to generate the .DEF file for you here: expdef - def file generator This works amazing and has a list of options you could also generate besides the method names of the functions and symbols. 0xC0000022L Simply put: write a script that suits your needs. I for one created a small Perl script at some to create a .def file from an existing DLL that would then be used to create an import library (

inconsistent dll linkage & definition of dllimport static data member not allowed

人盡茶涼 提交于 2019-12-01 01:23:57
问题 Assuming I have these two files: Header.h class DLL ExportClass{ public: ExportClass(); static int test; }; Source.cpp #ifdef EXPORT #define DLL __declspec(dllexport) #else #define DLL __declspec(dllimport) #endif #include "Header.h" int ExportClass::test = 0; ExportClass::ExportClass(){ } And I won't define EXPORT (to import a already exported class with a static member), why do I get these warnings: 1>source.cpp(11): warning C4273: 'test' : inconsistent dll linkage 1> header.h(4) : see

Automatically generate a DLL .DEF file in Visual Studio?

偶尔善良 提交于 2019-11-30 23:32:44
问题 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. 回答1: I have found a place to generate the .DEF file for you here: expdef - def file generator This works amazing and has a list of options you could also generate besides the method names of the functions and symbols. 回答2: Simply put: write a script that suits your needs. I for one created a small Perl script at some to create a

Use C++ DLL with VB6

做~自己de王妃 提交于 2019-11-30 23:22:43
I just created a DLL for my boss in MSVC++2010. I selected "New Win32 DLL" with option "Export symbols", so, everything is completely standard. There are some predefined exports in the new project files, a class, its constructor, a global function and variable with bogus values and a file dllmain.cpp with an APIENTRY function. I changed nothing yet. Now my boss wants to use the exported things in his VB6 project. He started a VB6 project, did menu "Project" - "Links" (translated from German to English, so it might be somewhat different but I'm sure you know what I mean) and selected a DLL file

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

て烟熏妆下的殇ゞ 提交于 2019-11-30 08:17:04
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 to be used by clients of class 'Foo' I am correctly declaring the Foo class as exported via __declspec(dllexport) . Is this a warning I can safely ignore or am I doing something wrong? The DLL project settings are set to dynamically link with ATL, but this doesn't seem to make any difference. For example: #ifdef DLLTEST_EXPORTS #define DLLTEST_API _

Call C# DLL from Inno Setup with callback

♀尐吖头ヾ 提交于 2019-11-29 10:56:30
I have a running Inno Setup script, wherein I use innocallback.dll by Sherlock Software. This DLL wraps a procedure of mine so that it can be passed to a C# DLL. I don't want to use this DLL, I want to call my exported C# method directly and pass to it the callback procedure. My question is: How can I pass my Inno Setup procedure ( @mycallback ) to my C# DLL so that I can use it as my delegate / UnmanagedFunctionPointer ? As I said this code works, but I want to use as little external DLL's as possible. Here is my code: Inno Setup Script type TTimerProc=procedure(); TProgressCallback=procedure

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

房东的猫 提交于 2019-11-29 05:53:53
问题 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 to be used by clients of class 'Foo' I am correctly declaring the Foo class as exported via __declspec(dllexport) . Is this a warning I can safely ignore or am I doing something wrong? The DLL project settings are set to dynamically link with ATL, but

Can a standard executable have an export table?

二次信任 提交于 2019-11-29 04:33:17
I have an executable written in C that has some functions in it that I would like to use from a c# application. I have written plenty of dlls before and was able to use functions in them by prepending __declspec(dllexport) to the function declaration. Can I do this from an executable? will the executable actually export the function? Yes you can! Yes the executable will export the functions. This is not done very often, but it works pretty good. According the Specification ( http://msdn.microsoft.com/en-us/gg463119.aspx ) of the Executable, there is no difference between DLL and Executable as

__declspec(dllimport) how to load library

Deadly 提交于 2019-11-29 03:49:29
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 myfunc(){} And now I would like to use it in my executable: __declspec(dllimport) void myfunc(void); But how my program will know where to find this function? CharlesB This is the compiler/linker job, it's done automatically as long as you include the .lib in the Linker options provide the DLL at runtime so that it's found by the exe The .lib file is