dllexport

c++ exporting and using dll function

白昼怎懂夜的黑 提交于 2019-12-17 19:54:47
问题 I can't quite figure out where there is a mistake. I am creating a DLL and then using it in a C++ console program (Windows 7, VS2008). But I get LNK2019 unresolved external symbol when trying to use the DLL functions. First the export: #ifndef __MyFuncWin32Header_h #define __MyFuncWin32Header_h #ifdef MyFuncLib_EXPORTS # define MyFuncLib_EXPORT __declspec(dllexport) # else # define MyFuncLib_EXPORT __declspec(dllimport) # endif #endif This is one header file I then use in: #ifndef __cfd

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

强颜欢笑 提交于 2019-12-17 19:33:42
问题 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 this from the application, I'd be using test_func but I have noticed due to name mangling it is not as simple as I'd thought. Through similar topics here I have come to the understanding that using extern "C" in combination with __declspec(dllexport)

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

时光总嘲笑我的痴心妄想 提交于 2019-12-17 15:51:44
问题 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 : //public CObject { ... class definition ... }; I have omitted the "public CObject" as that requires afx.h and implies it is an MFC Dll. I am not sure if this is a good thing or not but it differed from the DLL project default settings. From the above

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

丶灬走出姿态 提交于 2019-12-17 15:51:32
问题 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 : //public CObject { ... class definition ... }; I have omitted the "public CObject" as that requires afx.h and implies it is an MFC Dll. I am not sure if this is a good thing or not but it differed from the DLL project default settings. From the above

Exporting static data in a DLL

三世轮回 提交于 2019-12-17 09:38:04
问题 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 data. e.g. In DLL, Test.h class __declspec(dllexport) Test{ protected: static int d; public: static void m(){int x = a;} } In DLL, Test.cpp #include "Test.h" int Test::d; In the application which uses Test, I call m(). I also tried using _

C++ dll export undefined

只愿长相守 提交于 2019-12-14 03:36:30
问题 I am trying to create a C++ DLL that I can import in c#, but my code won't compile. Here is the code: //main.cpp #include "C:\Users\Mihai\Desktop\body.cpp" #include "C:\Users\Mihai\Desktop\header.h" extern "C"_declspec(dllexport) int sumTwo(int var_x, int var_y) { myClass MC(var_x, var_y); return MC.sumX_Y(); } //body.cpp #pragma once #include "Header.h" myClass::myClass(int var_x, int var_y) { x = var_x; y = var_y; } int myClass::sumX_Y() { return x + y; } //Header.h #pragma once class

Writing a DLL For Use With rundll32.exe

不想你离开。 提交于 2019-12-13 21:23:04
问题 I have the following codes: mydll.h: #include <Windows.h> __declspec(dllexport) void CALLBACK Entry(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow); mydll.c: #include "mydll.h" void CALLBACK Entry(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { FILE *f; f = fopen("C:\\Users\\user\\Desktop\\test.txt", "rw"); fprintf(f, "test"); fclose(f); } It compiles to mydll.dll. Then, when I try to do rundll32.exe mydll.dll,Entry It gives me the error message Error in mydll.dll

When to use __declspec(dllexport) in C++

喜欢而已 提交于 2019-12-13 12:31:09
问题 I am making this DLL project and do not include any of compiler-specific macros. The importer(.exe) files compiles clean and no error generated after importing methods in my DLL file. They are on different projects but same solution. Do I mess up things here because of not using any of those calling convention? My DLL files are in a namespace and implemented in OOP manner. But sometimes or most of the times, the .lib does not generated so I got to switch the setting of my DLL to LIB and copy

Exporting a function, cast into a pointer through a DLL

拈花ヽ惹草 提交于 2019-12-13 07:09:23
问题 This is an elaboration to an earlier question: How to reset state machines when unit testing C There is also a similar question but i don't the answer match my problem and i have some examples i wish to present: Exporting a function pointer from dll I have two sets of code that i expect should do the same but the latter crashes. Using mingw32 and Win7. The function to be exported. This is to be considered legacy and unmutable. addxy.c int addXY(int x, int y) { return x + y; } addxy.h int

How do I export and link to a dll using Qt Creator on Windows?

試著忘記壹切 提交于 2019-12-13 02:26:35
问题 I have got a few Qt projects building on my Mac and I am currently trying to get the same code to build on Windows. In among these projects there is one dll (call it LibraryA) that exports a class (call it ClassA) that is linked to by a second dll (call it LibraryB). I have the following code that defines the dll export code to be used based on the compiler being used. #ifdef _MSC_VER #if defined(LIBRARY_A) #define LIBRARY_A_EXPORT __declspec(dllexport) #else #define LIBRARY_A_EXPORT _