dllexport

C++ Dynamically load arbitrary function from DLL into std::function

心已入冬 提交于 2019-12-04 20:35:37
问题 How can I load an arbitrary dynamic-link library (dll) function into a std::function object using a single function? For example I would like to compile two functions into a dll: // test.dll int plusFive(int value) { return value + 5; } void printHello() { std::cout << "Hello!" << std::endl; } And load them both at runtime using a single function like this: // main.cc #include <functional> int main() { std::function<int(int)> func1(loadDllFunc("test.dll", "plusFive")); std::function<void()>

how to use an exported class (__declspec(dllexport))in an stl template?

只谈情不闲聊 提交于 2019-12-04 11:16:43
I am using an exported class class __declspec(dllexport) myclass { private: template __declspec(dllexport) class std::map<myclass*,int>; std::map<myclass*,int>m_map; //something }; When I do this, I get a warning C4251 saying m_map:class 'std::map<_Kty,_Ty>' needs to have dll-interface to be used by clients of class myclass. Any ideas about how i can resolve this ? Atul You should not be using __declspec(dllexport) into the header files that code using your DLL will be using, as they need to be using __declspec(dllimport). Therefore you should create a macro that uses dllexport if a particular

How to compile C program as dll in Mingw for use with Inno Setup & callback

为君一笑 提交于 2019-12-04 06:54:10
问题 I have the following program that's been written with lots of help. It will explode PKWare DCL compressed .vol archives (file id RESLIST) and extract the files to the specified output folder giving the extracted files the modification date of the original .vol file. It's meant to be used in an Inno Setup installer and I'd like to see if I can compile it as a .dll library I can import in my .iss script ie: function VolEx( filename, outputpath: String ): Integer; external 'VolExA@volex.dll

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

你离开我真会死。 提交于 2019-12-04 03:05:41
问题 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 = "Test", CallingConvention = CallingConvention.StdCall)] public static extern int Test(); Why I need the extern "C" ? 回答1: The main reason is to prevent the C++ name mangler from mangling the name of the function. Try exporting it without the extern "C" and

What is dllspec(dllimport) and dllspec(dllexport) means

折月煮酒 提交于 2019-12-03 04:02:08
After googling, i came to know that Dllimport makes the function available for other modules, is it mandatory to declare function with extern "c" identifier? Also, Dllexport means, Dll itself uses the function while compiling it says. so by default all functions present in DLL are dllexport? __declspec(dllexport) exports a symbol. It makes it available from outside a DLL. __declspec(dllimport) imports a symbol. It practically says "this symbol is not defined in this application, it needs to be imported from a DLL file". You don't have to declare it with extern "C" . If you don't use extern "C"

How to compile C program as dll in Mingw for use with Inno Setup & callback

前提是你 提交于 2019-12-02 12:58:33
I have the following program that's been written with lots of help. It will explode PKWare DCL compressed .vol archives (file id RESLIST) and extract the files to the specified output folder giving the extracted files the modification date of the original .vol file. It's meant to be used in an Inno Setup installer and I'd like to see if I can compile it as a .dll library I can import in my .iss script ie: function VolEx( filename, outputpath: String ): Integer; external 'VolExA@volex.dll stdcall'; I read through http://www.mingw.org/wiki/sampleDLL but was having a hard time understanding all

DLL example in Oxygene

泪湿孤枕 提交于 2019-12-02 07:30:33
Can somebody tell me where to find an example in how to make an DLL (WindowsControlLibrary) in Oxygene for .NET? In the old Delphi, you make an export section. To create an Unmanaged DLL Export using Delphi Prism and call it with Delphi 2010 you must do the following: In Delphi Prism: File | New | Project In the Tree View on the Left, select Delphi Prism Select Windows Class Library Press OK. This will create the template for the Windows Class Library Right Click on the Project "ClassLibraryX" and Select Properties: Under Compatibility select "Allow unsafe code" Under Build, find the General

export function with clr parameters from dll?

旧街凉风 提交于 2019-12-02 00:28:44
I've got a legacy managed c++ dll, and I need to call some function which is returning a managed type. For dllexports without managed types, this is easy, I just define my static c(++) function in a header like this: extern "C" { __declspec(dllexport) int __cdecl InitSystem(); } But now the static c(++) function should return a managed type, and here I got a problem. If I try (for example): extern "C" { __declspec(dllexport) System::Collections::Generic::List<System::String^>^ __cdecl InitSystem(); } I get a compiler error (function definition needs __clrcall signature). Since the DLL is not

DLL export of a static function

一曲冷凌霜 提交于 2019-12-01 09:11:11
I have the following static function: static inline HandVal StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards ) Can I export this function in a DLL? If so, how? Thanks, Mike Background information: I'm doing this because the original source code came with a VS project designed to compile as a static (.lib) library. In order to use ctypes/Python, I'm converting the project to a DLL. I started a VS project as a DLL and imported the original source code. The project builds into a DLL, but none of the functions (including functions such as the one listed above) are exported (as

DLL export of a static function

天大地大妈咪最大 提交于 2019-12-01 06:29:45
问题 I have the following static function: static inline HandVal StdDeck_StdRules_EVAL_N( StdDeck_CardMask cards, int n_cards ) Can I export this function in a DLL? If so, how? Thanks, Mike Background information: I'm doing this because the original source code came with a VS project designed to compile as a static (.lib) library. In order to use ctypes/Python, I'm converting the project to a DLL. I started a VS project as a DLL and imported the original source code. The project builds into a DLL,