dllexport

How can I handle DLL_EXPORT when compiling dll to a static library?

爱⌒轻易说出口 提交于 2020-08-07 09:49:08
问题 I have a project in visual c++ 2010, which contains preprocessor directives in a key header file. Actually, it is the ZMQ source code. The project is normally configured to be a dll, so the header uses DLL_EXPORT's status (defined/not defined). If the project is used to compile a dll, the header can be used by both the dll project or the client code, thanks to the following setup taken from zmq.h: #if defined _WIN32 # if defined DLL_EXPORT # define ZMQ_EXPORT __declspec(dllexport) # else #

c++ CLI Export void return __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention

我怕爱的太早我们不能终老 提交于 2020-07-10 08:18:11
问题 I'm trying to export some void/functions from a C++ Cli that wraps C# .Net Functions. In this moment I can properly export methods that return integer value, but when I try to export a Void, I get the error: Error C3395 'Test2': __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention ClassLibrary1 This is the full code: #pragma once using namespace System; using namespace System::Reflection; using namespace RobinHoodLibrary; namespace ClassLibrary1 { public

Build shared library with Clang++

柔情痞子 提交于 2020-06-11 05:07:38
问题 I am trying to build a shared library (dll for Windows) using Clang++. I have run the following commands: clang++ -c -o hello.o hello.cpp clang++ -shared -v -o hello.dll hello.o The first command works fine but when I try to build the dll I get this error: clang version 3.2 (tags/RELEASE_32/final) Target: i686-pc-mingw32 Thread model: posix "c:/MinGW/bin/g++.exe" -shared -v -m32 -o worker.dll worker.o Using built-in specs. COLLECT_GCC=c:/MinGW/bin/g++.exe COLLECT_LTO_WRAPPER=c:/mingw/bin/..

DLL : export as a C/C++ function?

一曲冷凌霜 提交于 2020-04-16 09:12:17
问题 I generated a DLL in Visual from a C++ code. Dependency Walker sees 3 functions exported as C functions. I made an SCons project to do the generate the DLL, and 2 of the 3 functions are not seen as C functions. What makes a function seen as a or C++ function, without modifying the code ? It must be in the compilation/linking options, but I didn't find any relevant thing. The function are prefixed by a macro : AM_LIB_EXPORT In the .h, I have : #ifdef _WIN32 #define AM_LIB_EXPORT __declspec

Exporting symbols in static library that is linked to dynamic library

╄→尐↘猪︶ㄣ 提交于 2020-04-16 02:51:46
问题 I have the following scenario in MSVC2017: A static library with the function bool foo() A dynamic link library that links to the static library above An application that loads the dynamic link library using explicit run-time linking and calls foo() via GetProcAddress In the static library, foo() is defined as follows: extern "C" __declspec(dllexport) bool foo() { return true; } Now, because foo() is not used by the dynamic link library, its symbol is not exported and thus not findable when

Using dllimport in place of dllexport

走远了吗. 提交于 2020-03-16 08:09:22
问题 I seem to be able to use __declspec(dllexport) and __declspec(dllimport) interchangeably when building my dll in Visual Studio 2015. I would have thought when making the DLL that the dllexport command would have been required but it seems either dllexport or dllimport is adequate.I have the following header file declaring a simple add() functions: add.h #pragma once #ifdef ADDDLL_EXPORTS #define ADDDLL_API __declspec(dllexport) #else #define ADDDLL_API __declspec(dllimport) #endif ADDDLL_API

Problems with exporting DLL in VS2010 (CUDA)

為{幸葍}努か 提交于 2020-01-30 08:07:44
问题 I have having trouble when building the DLL solution. I am making the DLL for use in LabVIEW 2010 in order to have CUDA capabilities. However, I am getting linker error LNK2019 on every single one of my functions I want exported. #include "LVCUDA.h" #include "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\cufft.h" #include "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include\cuda.h" #include <windows.h> #include <string.h> #include <ctype.h> BOOL WINAPI DllMain (

Calling a class defined function from a DLL file C++

孤人 提交于 2020-01-25 06:47:09
问题 I've built an example project from the Amazon IoT Device SDK which is the PubSub Sample project from the examples folder. I've had to output the project as a DLL file so that the sample can be used in RAD studio, which I have been able to build successfully. Using the tutorials from generating a DLL, I've added in the __declspec(dllexport) line to the function definitions in the class. PubSub.hpp file #ifdef PUBSNUB_EXPORTS #define PUBSNUB_API __declspec(dllexport) #else #define PUBSNUB_API _

Error: Calling C++ dll function in C#

China☆狼群 提交于 2020-01-24 09:29:33
问题 I am trying to use functions in C++ dll from C#, but I got an error: "attempt to read or write protected memory. This is often indication that other memory is corrupt" Anyone know how to fix ? Here is C++ functions: typedef void *DGNHandle; __declspec(dllexport) DGNHandle CPL_DLL DGNOpen( const char *, int ); __declspec(dllexport) DGNElemCore CPL_DLL *DGNReadElement( DGNHandle ) Here is structure in C++: typedef struct { int offset; int size; int element_id; /*!< Element number (zero based) *

How to handle destructors in DLL exported interfaces

≯℡__Kan透↙ 提交于 2020-01-23 12:29:09
问题 I'm trying to export a class from a DLL. I read this article on doing so: http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL The "mature" approach suggest, that an abstract class is used, so I have: // Header class IFoo{ public: virtual int getBar() = 0; } class Foo: public IFoo {...} DLLEXPORT IFoo* Create(); DLLEXPRT void Free(IFoo* inst); //DLL cpp IFoo* Create(){ return new Foo; } void Free(IFoo* inst){ delete inst; } What puzzles me: If I don't have a virtual