dllexport

Trouble loading Unmanaged C++ DLL from WPF application

隐身守侯 提交于 2019-12-24 05:52:40
问题 First of all I would like to thank anyone reading this for their time! I'm a pretty well-informed C# programmer with WinForms and I'm giving WPF a shot. I've been having trouble calling functions from my WPF application so I decided to create a very easy example project to illustrate my problem. In this application I'm creating a C++ Dll (using Visual Studio 2012 -> Visual C++ -> Win32 Console Application -> .DLL Project). In this DLL, I'm simply creating a function to return a DWORD. My DLL

How to add definitions for cuda source code in cmake

ぐ巨炮叔叔 提交于 2019-12-24 00:48:01
问题 I am on Visual Studio 2013, Windows 10, CMake 3.5.1. Everything compiles properly with standard C++, for example: CMakeLists.txt project(Test) add_definitions(/D "WINDOWS_DLL_API=__declspec(dllexport)") add_definitions(/D "FOO=1") set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/src/Test.cpp) set(PROJECT_INCS ${PROJECT_SOURCE_DIR}/include/Test.h) include_directories(${PROJECT_SOURCE_DIR}/include) add_library(${PROJECT_NAME} SHARED ${PROJECT_SRCS} ${PROJECT_INCS}) Test.h class WINDOWS_DLL_API Test{

Calling Unmanaged C++ from C#

荒凉一梦 提交于 2019-12-23 18:34:12
问题 I'm running VS2012 on Win7 with .NET 4.0. I've tried the following: Create C++ DLL project Checked\Unchecked the export symbols box I've made sure my platform targets are the same. In my case, win32 I've added the necessary extern "C" and __declspec(dllexport) where needed. I've successfully compiled my DLL and have tried to reference it in a C# project. Unfortunately, I get an error telling my it can't be added and that I need to make sure it's a valid assembly or COM object. I've given up

DLL without exported functions?

China☆狼群 提交于 2019-12-23 07:49:51
问题 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() does get executed on LoadLibrary(), but whats the point? Why would anyone create a DLL without exported functions? thanks! :-) 回答1: One way of dealing with versions of a program destined for different languages is to put all of the resources into a

Correct way to export a DLL function on Mac OSX

流过昼夜 提交于 2019-12-23 03:35:14
问题 I'm trying to compile a simple DLL on a Mac OS X 10.6, and am confused about the proper way to declare a function that the DLL offers up for the world to use. Following sample code from a reliable source, I came up with: __declspsec(dllexport) pascal int ReturnTheNumberFive(void) but gcc barfs on it. What the sample code actually had was MACPASCAL and DLLExport, which I assumed were macros. I grepped through the sample codes, SDKs, etc for #defines and plugged in what I found. These

How do decorated names get into import libraries when I only provide the undecorated name?

。_饼干妹妹 提交于 2019-12-23 00:49:11
问题 I'm working in Visual C++, VS2015 Community. I've written this tiny little DLL: #include "stdafx.h" int showMsgBox(wchar_t* caption, wchar_t* message) { MessageBox(NULL, message, caption, 0); return 0; } And this tiny little client: #include "stdafx.h" __declspec(dllimport) int showMsgBox(wchar_t* caption, wchar_t* message); int main() { showMsgBox(L"SimpleDLLClient", L"Hello DLL World!"); return 0; } To export the showMsgBox function, I've created this module definition file: LIBRARY

How do decorated names get into import libraries when I only provide the undecorated name?

夙愿已清 提交于 2019-12-23 00:49:09
问题 I'm working in Visual C++, VS2015 Community. I've written this tiny little DLL: #include "stdafx.h" int showMsgBox(wchar_t* caption, wchar_t* message) { MessageBox(NULL, message, caption, 0); return 0; } And this tiny little client: #include "stdafx.h" __declspec(dllimport) int showMsgBox(wchar_t* caption, wchar_t* message); int main() { showMsgBox(L"SimpleDLLClient", L"Hello DLL World!"); return 0; } To export the showMsgBox function, I've created this module definition file: LIBRARY

export function with clr parameters from dll?

与世无争的帅哥 提交于 2019-12-20 03:37:26
问题 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

Use C++ DLL with VB6

寵の児 提交于 2019-12-19 04:20:53
问题 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

__declspec(dllimport) how to load library

核能气质少年 提交于 2019-12-18 03:22:28
问题 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? 回答1: This is the compiler/linker job, it's done automatically as long as you include the .lib