dllexport

Exporting cpp mangled functions from a 3rd party library

断了今生、忘了曾经 提交于 2021-02-20 05:19:26
问题 I have a third party library as source code. It comes with a Visual Studio project that builds a .lib from it. I want to access the functionality from C# though, so I copied the project and changed it to create a dll. The DLL didn't contain any exported functions though, so I also created a module definition (.def) file, and added the functions I need in the EXPORTS section. This works for all the functions that are declared in extern "C" blocks. However, some of the functions that I need are

Using __declspec( dllexport )

纵然是瞬间 提交于 2021-02-10 17:55:36
问题 Hi I'm little bit confused with dllexport.When I use __declspec( dllexport ) for example in class #define DllExport __declspec( dllexport ) class DllExport C { int i; virtual int func( void ) { return 1; } }; do I export class C to dll file or do I export C class from dll file? 回答1: When compiling the DLL you have to write __declspec(dllexport) as you did. This tells the compiler you want it to be exported. When using the DLL you want __declspec(dllimport) in your included files. The compiler

dllimport /dllexport and static libraries compilation under visual c++

不羁岁月 提交于 2021-02-08 19:55:35
问题 I desperatly need your help. Im trying to compile statically the poppler library (specially for qt4) on windows with the visual c++ 2008 compiler. To achieve this task I needed to compile a bunch of other libraries as dependencies for poppler statically too. When I finally generate the static version of poppler I got a linking error when building my app: error LNK2019: unresolved external symbol "__declspec(dllimport)... I already added the new include path and linked the poppler-qt4.lib but

DLL exporting causing issues with unique pointers

走远了吗. 提交于 2021-02-05 06:25:05
问题 I've got two files: Header.h #pragma once #ifdef UNIQUEPTRISSUE_EXPORTS #define UNIQUEPTRISSUE_API __declspec(dllexport) #else #define UNIQUEPTRISSUE_API __declspec(dllimport) #endif UniquePtrIssue.cpp #include "stdafx.h" #include "Header.h" #include <memory> #include <vector> class UNIQUEPTRISSUE_API ClassA { }; class UNIQUEPTRISSUE_API ClassB { private: std::vector<std::unique_ptr<ClassA>> x; }; Compiling raises the following error: 1>d:\program files (x86)\microsoft visual studio\2017

How to call MessageBox with GetProcAddress function?

我的未来我决定 提交于 2021-02-04 05:59:27
问题 I want to call MessageBox() function in such way: 1). load needed library 2). get the function address 3). call it So, for such aim as I understand, I should define new type with all types of arguments in MessageBox function. It returnes INT and accepts: HWND, LPCSTR, LPCSTR, UNIT. So I registred new type: typedef int(__stdcall *msgbox)(HWND, LPCSTR, LPCSTR, UINT); I have problems with calling such function. Does such way work for all functions or only for exported? How can I call MessageBox

How to call MessageBox with GetProcAddress function?

时光怂恿深爱的人放手 提交于 2021-02-04 05:59:04
问题 I want to call MessageBox() function in such way: 1). load needed library 2). get the function address 3). call it So, for such aim as I understand, I should define new type with all types of arguments in MessageBox function. It returnes INT and accepts: HWND, LPCSTR, LPCSTR, UNIT. So I registred new type: typedef int(__stdcall *msgbox)(HWND, LPCSTR, LPCSTR, UINT); I have problems with calling such function. Does such way work for all functions or only for exported? How can I call MessageBox

Linking errors while exporting std::vector from dll

邮差的信 提交于 2021-01-28 04:55:15
问题 I have a dll ( my_library.dll ) that exports a struct using __ declspec(dllexport) . Since this struct contains an std::vector<std::wstring> member , I've also exported functions for it like so: template class __declspec(dllexport) std::allocator<std::wstring>; template class __declspec(dllexport) std::vector<std::wstring>; Please note that I've defined macros such that dll exports above struct and vector when compiling and they are imported (via __declspec(dllimport)) when the dll is being

How to overwrite macro definition in CMake

杀马特。学长 韩版系。学妹 提交于 2021-01-27 21:40:51
问题 I am on Windows 10, Visual Studio 2015. Suppose I am building library A with CMakeLists looking like cmake_minimum_required(VERSION 3.7) project(A) set(DLLIMPORT "__declspec(dllimport)") set(DLLEXPORT "__declspec(dllexport)") set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/src/TestA.cpp) set(PROJECT_INCS ${PROJECT_SOURCE_DIR}/include/TestA.h) add_library(${PROJECT_NAME} SHARED ${PROJECT_SRCS} ${PROJECT_INCS}) target_compile_definitions(${PROJECT_NAME} INTERFACE WINDOWS_DLL_API=${DLLIMPORT}) target

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

房东的猫 提交于 2020-08-07 09:50: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 #

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

↘锁芯ラ 提交于 2020-08-07 09:49:45
问题 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 #