Search Results

Search found 74 results on 3 pages for 'dllexport'.

Page 1/3 | 1 2 3  | Next Page >

  • Symbol exporting problem using __declspec(dllexport)

    - by Gayan
    I use __declspec(dllexport) with several methods in a library. But one of the symbols do not get exported properly. The value in question is called "restart". I've given the output from dumpbin.exe, below: 1 0 0002DB27 ev_err = @ILT+2850(_ev_err) 2 1 0002DADC m_foutput = @ILT+2775(_m_foutput) 3 2 0002D361 m_free = @ILT+860(_m_free) 4 3 0002D505 m_free_vars = @ILT+1280(_m_free_vars) 5 4 0002D055 m_get = @ILT+80(_m_get) 6 5 0002D95B m_ident = @ILT+2390(_m_ident) 7 6 0002D80C m_inverse = @ILT+2055(_m_inverse) 8 7 0002D0F5 m_mlt = @ILT+240(_m_mlt) 9 8 0002D339 m_ones = @ILT+820(_m_ones) 10 9 0002D43D m_rand = @ILT+1080(_m_rand) 11 A 0002DC3F m_resize = @ILT+3130(_m_resize) 12 B 0002D465 m_zero = @ILT+1120(_m_zero) 13 C 0002D3A7 px_foutput = @ILT+930(_px_foutput) 14 D 0002DA2D px_free = @ILT+2600(_px_free) 15 E 00092DE0 restart = _restart 16 F 0002DB45 set_err_flag = @ILT+2880(_set_err_flag) 17 10 0002D550 v_foutput = @ILT+1355(_v_foutput) 18 11 0002D839 v_free = @ILT+2100(_v_free) This seems to indicate that restart did not get exported properly but I can't figure out why. I use the following line to export the method: extern __declspec(dllexport) jmp_buf restart; What is the reason for this anomaly and how can I resolve it?

    Read the article

  • Using DLLEXPORT to export DLL function With Class to C#

    - by SICGames2013
    In my previous revision game engine I deported major functions for the game editor for C#. Now, I'm beginning to revise the game engine with a static library. There's a already dynamic library created in C++ to use DLLEXPORT for C#. Just now I want to test out the newer functions and created a DLL file from C++. Because the DLL contains classes I was wondering how would I be able to use DLL Export. Would I do this: [DLLEXPORT("GameEngine.dll", EntryPoint="SomeClass", Conventional=_stdcall)] static extern void functionFromClass(); I have a feeling it's probably DLLImport and not DLLExport. I was wondering how would I go about this? Another way I was thinking was because I already have the DLL in C++ prepared already to go the C# Class Library. I could just keep the new engine as a lib, and link the lib with the old DLL C++ file. Wouldn't the EntryPoint be able to point to the class the function is in?

    Read the article

  • Exporting static data in a DLL

    - by Gayan
    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(){} } In DLL, Test.cpp #include "Test.h" int Test::d; In the application which uses Test, I call m(). I also tried using __declspec(dllexport) for each method separately but I still get the same link errors for the static members. If I check the DLL (the .lib) using dumpbin, I could see that the symbols have been exported. For instance, the app gives the following error at link time: 1>Main.obj : error LNK2001: unresolved external symbol "protected: static int CalcEngine::i_MatrixRow" (?i_MatrixRow@CalcEngine@@1HA) But the dumpbin of the .lib contains: Version : 0 Machine : 14C (x86) TimeDateStamp: 4BA3611A Fri Mar 19 17:03:46 2010 SizeOfData : 0000002C DLL name : CalcEngine.dll Symbol name : ?i_MatrixRow@CalcEngine@@1HA (protected: static int CalcEngine::i_MatrixRow) Type : data Name type : name Hint : 31 Name : ?i_MatrixRow@CalcEngine@@1HA I can't figure out how to solve this. What am I doing wrong? How can I get over these errors? P.S. The code was originally developed for Linux and the .so/binary combination works without a problem

    Read the article

  • DLL Exports: not all my functions are exported

    - by carmellose
    I'm trying to create a Windows DLL which exports a number of functions, howver all my functions are exported but one !! I can't figure it out. The macro I use is this simple one : __declspec(dllexport) void myfunction(); It works for all my functions except one. I've looked inside Dependency Walker and here they all are, except one. How can that be ? What would be the cause for that ? I'm stuck. Edit: to be more precise, here is the function in the .h : namespace my { namespace great { namespace namespaaace { __declspec(dllexport) void prob_dump(const char *filename, const double p[], int nx, const double Q[], const double xlow[], const char ixlow[], const double xupp[], const char ixupp[], const double A[], int my, const double bA[], const double C[], int mz, const double clow[], const char iclow[], const double cupp[], const char icupp[] ); }}} And in the .cpp file it goes like this: namespace my { namespace great { namespace namespaaace { namespace { void dump_mtx(std::ostream& ostr, const double *mtx, int rows, int cols, const char *ind = 0) { /* some random code there, nothing special, no statics whatsoever */ } } // end anonymous namespace here // dump the problem specification into a file void prob_dump( const char *filename, const double p[], int nx, const double Q[], const double xlow[], const char ixlow[], const double xupp[], const char ixupp[], const double A[], int my, const double bA[], const double C[], int mz, const double clow[], const char iclow[], const double cupp[], const char icupp[] ) { std::ofstream fout; fout.open(filename, std::ios::trunc); /* implementation there */ dump_mtx(fout, Q, nx, nx); } }}} Thanks

    Read the article

  • C++ DLL-Linking UnResolved Externals

    - by Undawned
    I have a rather big Core project that I'm working with, I'm attempting to adapt it to use a DLL Engine I've built, I'm getting a bunch of errors like: unresolved external symbol "private: static class When including some of the headers from the Core in the DLL, the class is exported via __declspec(dllexport) but any header with static members throws out a crapload of errors regarding the static members. This is a rather big project, I can't exactly run around removing every static class member I see, is there anyway around this kind of thing?

    Read the article

  • DLL export of a static function

    - by Begbie00
    Hi all - 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 confirmed by both the absence of dllexport in the source code and tools such as DLL Export Viewer). I tried to follow the general advice here (create an exportable wrapper function within the header) to no avail...functions still don't appear to be exported.

    Read the article

  • Unresolved external symbol

    - by kriau
    I have two WIN32 DLL projects in the solution, main.dll should call a function in mgn.dll. mgn.dll has mgn.h header file: #ifdef MGN_EXPORTS #define MGN_API __declspec(dllexport) #else #define MGN_API __declspec(dllimport) #endif extern "C" bool MGN_API AttachMGN(void); and mgn.cpp source file: #include "stdafx.h" #include "mgn.h" MGN_API bool AttachMGN(void) { ... } main.dll calls AttachMGN function from one of the source file: #include "stdafx.h" #include "..\mgn\mgn.h" bool CreateClient() { return ::AttachMGN(); } mgn.dll compiles successfully. main.dll doesn't show any errors in VS text editor, I can navigate using "Go To Definition" function. However during build I get the error: error LNK2019: unresolved external symbol _imp_AttachMGN referenced in function "bool __cdecl CreateClient(void)" (?CreateClient@@AW4XZ) Both DLLs compile into the same folder. DependencyWalker shows the function AttachMGN as exported. Main project has a dependency set to Mgn project, if that matters. I believe that I simply have overlooked something.... Thanks in advance.

    Read the article

  • How to wrap two unmannaged C++ functions into two managed C# functions?

    - by Gbps
    I've got two unmanaged C++ functions, Compress and Decompress. The arguments and returns go as followed: unsigned char* Compress (unsigned char*,int) unsigned char* Decompress (unsigned char*,int) Where all uchars are arrays of uchars. Could someone please help me lay out a way to convert these into managed C# code using the Byte[] array instead of unsigned char*? Thank you very much!

    Read the article

  • Problem invoking C DLL in C#

    - by CristiC
    I'm currently trying to invoke a method made in C from C# C code looks like this: extern "C" int addSum(int a, int b) { return a*b; } extern "C" int getCount() { return 12; } and C# code looks like this: [DllImport("mydll.dll", SetLastError=true)] private static extern int addSum(IntPtr a, IntPtr b); [DllImport("mydll.dll", SetLastError = true)] private static extern int getCount(); public static int mySum(int a, int b) { return suma(a, b); } public static int getMyCount() { return getCount(); } The code returns the right values but i'm getting the following error: addSum' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature. Any sugestion regarding this issue ? Thanks

    Read the article

  • How to export a C++ class library to C# using a dll?

    - by SICGames2013
    In my previous revision game engine I deported major functions for the game editor for C#. Now, I'm beginning to revise the game engine with a static library. There's a already dynamic library created in C++ to use DLLEXPORT for C#. Just now I want to test out the newer functions and created a DLL file from C++. Because the DLL contains classes I was wondering how would I be able to use DLL Export. Would I do this: [DLLEXPORT("GameEngine.dll", EntryPoint="SomeClass", Conventional=_stdcall)] static extern void functionFromClass(); I have a feeling it's probably DLLImport and not DLLExport. I was wondering how would I go about this? Another way I was thinking was because I already have the DLL in C++ prepared already to go the C# Class Library. I could just keep the new engine as a lib, and link the lib with the old DLL C++ file. Wouldn't the EntryPoint be able to point to the class the function is in?

    Read the article

  • how to use serial port in UDK using windows DLL and DLLBind directive?

    - by Shayan Abbas
    I want to use serial port in UDK, For that purpose i use a windows DLL and DLLBind directive. I have a thread in windows DLL for serial port data recieve event. My problem is: this thread doesn't work properly. Please Help me. below is my code SerialPortDLL Code: // SerialPortDLL.cpp : Defines the exported functions for the DLL application. // #include "stdafx.h" #include "Cport.h" extern "C" { // This is an example of an exported variable //SERIALPORTDLL_API int nSerialPortDLL=0; // This is an example of an exported function. //SERIALPORTDLL_API int fnSerialPortDLL(void) //{ // return 42; //} CPort *sp; __declspec(dllexport) void Open(wchar_t* portName) { sp = new CPort(portName); //MessageBox(0,L"ha ha!!!",L"ha ha",0); //MessageBox(0,portName,L"ha ha",0); } __declspec(dllexport) void Close() { sp->Close(); MessageBox(0,L"ha ha!!!",L"ha ha",0); } __declspec(dllexport) wchar_t *GetData() { return sp->GetData(); } __declspec(dllexport) unsigned int GetDSR() { return sp->getDSR(); } __declspec(dllexport) unsigned int GetCTS() { return sp->getCTS(); } __declspec(dllexport) unsigned int GetRing() { return sp->getRing(); } } CPort class code: #include "stdafx.h" #include "CPort.h" #include "Serial.h" CSerial serial; HANDLE HandleOfThread; LONG lLastError = ERROR_SUCCESS; bool fContinue = true; HANDLE hevtOverlapped; HANDLE hevtStop; OVERLAPPED ov = {0}; //char szBuffer[101] = ""; wchar_t *szBuffer = L""; wchar_t *data = L""; DWORD WINAPI ThreadHandler( LPVOID lpParam ) { // Keep reading data, until an EOF (CTRL-Z) has been received do { MessageBox(0,L"ga ga!!!",L"ga ga",0); //Sleep(10); // Wait for an event lLastError = serial.WaitEvent(&ov); if (lLastError != ERROR_SUCCESS) { //LOG( " Unable to wait for a COM-port event" ); } // Setup array of handles in which we are interested HANDLE ahWait[2]; ahWait[0] = hevtOverlapped; ahWait[1] = hevtStop; // Wait until something happens switch (::WaitForMultipleObjects(sizeof(ahWait)/sizeof(*ahWait),ahWait,FALSE,INFINITE)) { case WAIT_OBJECT_0: { // Save event const CSerial::EEvent eEvent = serial.GetEventType(); // Handle break event if (eEvent & CSerial::EEventBreak) { //LOG( " ### BREAK received ###" ); } // Handle CTS event if (eEvent & CSerial::EEventCTS) { //LOG( " ### Clear to send %s ###", serial.GetCTS() ? "on":"off" ); } // Handle DSR event if (eEvent & CSerial::EEventDSR) { //LOG( " ### Data set ready %s ###", serial.GetDSR() ? "on":"off" ); } // Handle error event if (eEvent & CSerial::EEventError) { switch (serial.GetError()) { case CSerial::EErrorBreak: /*LOG( " Break condition" );*/ break; case CSerial::EErrorFrame: /*LOG( " Framing error" );*/ break; case CSerial::EErrorIOE: /*LOG( " IO device error" );*/ break; case CSerial::EErrorMode: /*LOG( " Unsupported mode" );*/ break; case CSerial::EErrorOverrun: /*LOG( " Buffer overrun" );*/ break; case CSerial::EErrorRxOver: /*LOG( " Input buffer overflow" );*/ break; case CSerial::EErrorParity: /*LOG( " Input parity error" );*/ break; case CSerial::EErrorTxFull: /*LOG( " Output buffer full" );*/ break; default: /*LOG( " Unknown" );*/ break; } } // Handle ring event if (eEvent & CSerial::EEventRing) { //LOG( " ### RING ###" ); } // Handle RLSD/CD event if (eEvent & CSerial::EEventRLSD) { //LOG( " ### RLSD/CD %s ###", serial.GetRLSD() ? "on" : "off" ); } // Handle data receive event if (eEvent & CSerial::EEventRecv) { // Read data, until there is nothing left DWORD dwBytesRead = 0; do { // Read data from the COM-port lLastError = serial.Read(szBuffer,33,&dwBytesRead); if (lLastError != ERROR_SUCCESS) { //LOG( "Unable to read from COM-port" ); } if( dwBytesRead == 33 && szBuffer[0]=='$' ) { // Finalize the data, so it is a valid string szBuffer[dwBytesRead] = '\0'; ////LOG( "\n%s\n", szBuffer ); data = szBuffer; } } while (dwBytesRead > 0); } } break; case WAIT_OBJECT_0+1: { // Set the continue bit to false, so we'll exit fContinue = false; } break; default: { // Something went wrong //LOG( "Error while calling WaitForMultipleObjects" ); } break; } } while (fContinue); MessageBox(0,L"kka kk!!!",L"kka ga",0); return 0; } CPort::CPort(wchar_t *portName) { // Attempt to open the serial port (COM2) //lLastError = serial.Open(_T(portName),0,0,true); lLastError = serial.Open(portName,0,0,true); if (lLastError != ERROR_SUCCESS) { //LOG( "Unable to open COM-port" ); } // Setup the serial port (115200,8N1, which is the default setting) lLastError = serial.Setup(CSerial::EBaud115200,CSerial::EData8,CSerial::EParNone,CSerial::EStop1); if (lLastError != ERROR_SUCCESS) { //LOG( "Unable to set COM-port setting" ); } // Register only for the receive event lLastError = serial.SetMask(CSerial::EEventBreak | CSerial::EEventCTS | CSerial::EEventDSR | CSerial::EEventError | CSerial::EEventRing | CSerial::EEventRLSD | CSerial::EEventRecv); if (lLastError != ERROR_SUCCESS) { //LOG( "Unable to set COM-port event mask" ); } // Use 'non-blocking' reads, because we don't know how many bytes // will be received. This is normally the most convenient mode // (and also the default mode for reading data). lLastError = serial.SetupReadTimeouts(CSerial::EReadTimeoutNonblocking); if (lLastError != ERROR_SUCCESS) { //LOG( "Unable to set COM-port read timeout" ); } // Create a handle for the overlapped operations hevtOverlapped = ::CreateEvent(0,TRUE,FALSE,0);; if (hevtOverlapped == 0) { //LOG( "Unable to create manual-reset event for overlapped I/O" ); } // Setup the overlapped structure ov.hEvent = hevtOverlapped; // Open the "STOP" handle hevtStop = ::CreateEvent(0,TRUE,FALSE,_T("Overlapped_Stop_Event")); if (hevtStop == 0) { //LOG( "Unable to create manual-reset event for stop event" ); } HandleOfThread = CreateThread( NULL, 0, ThreadHandler, 0, 0, NULL); } CPort::~CPort() { //fContinue = false; //CloseHandle( HandleOfThread ); //serial.Close(); } void CPort::Close() { fContinue = false; CloseHandle( HandleOfThread ); serial.Close(); } wchar_t *CPort::GetData() { return data; } bool CPort::getCTS() { return serial.GetCTS(); } bool CPort::getDSR() { return serial.GetDSR(); } bool CPort::getRing() { return serial.GetRing(); } Unreal Script Code: class MyPlayerController extends GamePlayerController DLLBind(SerialPortDLL); dllimport final function Open(string portName); dllimport final function Close(); dllimport final function string GetData();

    Read the article

  • Creating a C++ DLL and then using it in C#

    - by Major
    Ok I'm trying to make a C++ DLL that I can then call and reference in a c# App. I've already made a simple dll using the numberous guides out there, however when I try to reference it in the C# app I get the error Unable to load DLL 'SDES.dll': The specified module could not be found. The code for the program is as follows (bear with me I'm going to include all the files) //These are the DLL Files. ifndef TestDLL_H define TestDLL_H extern "C" { // Returns a + b __declspec(dllexport) double Add(double a, double b); // Returns a - b __declspec(dllexport) double Subtract(double a, double b); // Returns a * b __declspec(dllexport) double Multiply(double a, double b); // Returns a / b // Throws DivideByZeroException if b is 0 __declspec(dllexport) double Divide(double a, double b); } endif //.cpp include "test.h" include using namespace std; extern double __cdecl Add(double a, double b) { return a + b; } extern double __cdecl Subtract(double a, double b) { return a - b; } extern double __cdecl Multiply(double a, double b) { return a * b; } extern double __cdecl Divide(double a, double b) { if (b == 0) { throw new invalid_argument("b cannot be zero!"); } return a / b; } //C# Program using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Program { [DllImport("SDES.dll")] public static extern void SimulateGameDLL(int a, int b); static void Main(string[] args) { SimulateGameDLL(1, 2); //Error here... } } } Anyone have any idea's what I may be missing in my program? Let me know if I missed some code or if you have any questions.

    Read the article

  • C++ DLL creation for C# project - No functions exported

    - by Yeti
    I am working on a project that requires some image processing. The front end of the program is C# (cause the guys thought it is a lot simpler to make the UI in it). However, as the image processing part needs a lot of CPU juice I am making this part in C++. The idea is to link it to the C# project and just call a function from a DLL to make the image processing part and allow to the C# environment to process the data afterwards. Now the only problem is that it seems I am not able to make the DLL. Simply put the compiler refuses to put any function into the DLL that I compile. Because the project requires some development time testing I have created two projects into a C++ solution. One is for the Dll and another console application. The console project holds all the files and I just include the corresponding header into my DLL project file. I thought the compiler should take out the functions that I marked as to be exported and make the DLL from them. Nevertheless this does not happens. Here it is how I defined the function in the header: extern "C" __declspec(dllexport) void _stdcall RobotData(BYTE* buf, int** pToNewBackgroundImage, int* pToBackgroundImage, bool InitFlag, ObjectInformation* robot1, ObjectInformation* robot2, ObjectInformation* robot3, ObjectInformation* robot4, ObjectInformation* puck); extern "C" __declspec(dllexport) CvPoint _stdcall RefPointFinder(IplImage* imgInput, CvRect &imgROI, CvScalar &refHSVColorLow, CvScalar &refHSVColorHi ); Followed by the implementation in the cpp file: extern "C" __declspec(dllexport) CvPoint _stdcall RefPointFinder(IplImage* imgInput, CvRect &imgROI,&refHSVColorLow, CvScalar &refHSVColorHi ) { \\... return cvPoint((int)( M10/M00) + imgROI.x, (int)( M01/M00 ) + imgROI.y) ;} extern "C" __declspec(dllexport) void _stdcall RobotData(BYTE* buf, int** pToNewBackgroundImage, int* pToBackgroundImage, bool InitFlag, ObjectInformation* robot1, ObjectInformation* robot2, ObjectInformation* robot3, ObjectInformation* robot4, ObjectInformation* puck) { \\ ...}; And my main file for the DLL project looks like: #ifdef _MANAGED #pragma managed(push, off) #endif /// <summary> Include files. </summary> #include "..\ImageProcessingDebug\ImageProcessingTest.h" #include "..\ImageProcessingDebug\ImageProcessing.h" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; } #ifdef _MANAGED #pragma managed(pop) #endif Needless to say it does not work. A quick look with DLL export viewer 1.36 reveals that no function is inside the library. I don't get it. What I am doing wrong ? As side not I am using the C++ objects (and here it is the C++ DLL part) such as the vector. However, only for internal usage. These will not appear in the headers of either function as you can observe from the previous code snippets. Any ideas? Thx, Bernat

    Read the article

  • GetLongPathName Undeclared

    - by iwizardpro
    When I try to compile my code with the function GetLongPathName(), the compiler tells me that the function is undeclared. I have already read the MSDN documentation located @ http://msdn.microsoft.com/en-us/library/aa364980%28VS.85%29.aspx. But, even though I included those header files, I am still getting the undeclared function error. Which header file(s) am I supposed to include when using the function? #include <Windows.h> #include <WinBase.h> #define DLLEXPORT extern "C" __declspec(dllexport) DLLEXPORT char* file_get_long(char* path_original) { long length = 0; TCHAR* buffer = NULL; if(!path_original) { return "-10"; } length = GetLongPathName(path_original, NULL, 0); if(length == 0) { return "-10"; } buffer = new TCHAR[length]; length = GetLongPathName(path_original, buffer, length); if(length == 0) { return "-10"; } return buffer; } And, if it makes a difference, I am currently compiling using Dev-C++ on a Windows Vista 64-bit.

    Read the article

  • Dynamic libraries are not allowed on iOS but what about this?

    - by tapirath
    I'm currently using LuaJIT and its FFI interface to call C functions from LUA scripts. What FFI does is to look at dynamic libraries' exported symbols and let the developer use it directly form LUA. Kind of like Python ctypes. Obviously using dynamic libraries is not permitted in iOS for security reasons. So in order to come up with a solution I found the following snippet. /* (c) 2012 +++ Filip Stoklas, aka FipS, http://www.4FipS.com +++ THIS CODE IS FREE - LICENSED UNDER THE MIT LICENSE ARTICLE URL: http://forums.4fips.com/viewtopic.php?f=3&t=589 */ extern "C" { #include <lua.h> #include <lualib.h> #include <lauxlib.h> } // extern "C" #include <cassert> // Please note that despite the fact that we build this code as a regular // executable (exe), we still use __declspec(dllexport) to export // symbols. Without doing that FFI wouldn't be able to locate them! extern "C" __declspec(dllexport) void __cdecl hello_from_lua(const char *msg) { printf("A message from LUA: %s\n", msg); } const char *lua_code = "local ffi = require('ffi') \n" "ffi.cdef[[ \n" "const char * hello_from_lua(const char *); \n" // matches the C prototype "]] \n" "ffi.C.hello_from_lua('Hello from LUA!') \n" // do actual C call ; int main() { lua_State *lua = luaL_newstate(); assert(lua); luaL_openlibs(lua); const int status = luaL_dostring(lua, lua_code); if(status) printf("Couldn't execute LUA code: %s\n", lua_tostring(lua, -1)); lua_close(lua); return 0; } // output: // A message from LUA: Hello from LUA! Basically, instead of using a dynamic library, the symbols are exported directly inside the executable file. The question is: is this permitted by Apple? Thanks.

    Read the article

  • Cython - properly declaring C funs

    - by deepblue
    I'm having trouble with running a bare example. I'm using this to declare a function in Cython coming from cinterf.h header: cdef extern from 'cinterf.h': int xsb_init_string(char* p_xsb_path) The declaration in the C header file is: DllExport extern int call_conv xsb_init_string(char *); both DllExport and call_conv are macros defined elsewhere, and resolve to GCC compiler directives. do I have to use those as well inside cdef to fully match the declaration? When I call xsb_init_string() as: xsb_init_string('some string') The python interpreter gives me: 'ImportError: ./py_ext.so: undefined symbol: xsb_init_string' Am I declaring the xsb_init_string() signature properly, inside cdef?

    Read the article

  • Making Visual C++ DLL from C++ class

    - by prosseek
    I have the following C++ code to make dll (Visual Studio 2010). class Shape { public: Shape() { nshapes++; } virtual ~Shape() { nshapes--; }; double x, y; void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; }; class __declspec(dllexport) Circle : public Shape { private: double radius; public: Circle(double r) : radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class __declspec(dllexport) Square : public Shape { private: double width; public: Square(double w) : width(w) { }; virtual double area(void); virtual double perimeter(void); }; I have the __declspec, class __declspec(dllexport) Circle I could build a dll with the following command CL.exe /c example.cxx link.exe /OUT:"example.dll" /DLL example.obj When I tried to use the library, Square* square; square->area() I got the error messages. What's wrong or missing? example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall ... Square::area(void)" (?area@Square@@UAENXZ) ADDED Following wengseng's answer, I modified the header file, and for DLL C++ code, I added #define XYZLIBRARY_EXPORT However, I still got errors. example_unittest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __th iscall Circle::Circle(double)" (__imp_??0Circle@@QAE@N@Z) referenced in function "protected: virtual void __thiscall TestOne::SetUp(void)" (?SetUp@TestOne@@MAEXXZ) example_unittest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __th iscall Square::Square(double)" (__imp_??0Square@@QAE@N@Z) referenced in function "protected: virtual void __thiscall TestOne::SetUp(void)" (?SetUp@TestOne@@MAEXXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Square::area(void)" (?area@Square@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Square::perimeter(void)" (?perimeter@Square@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Circle::area(void)" (?area@Circle@@UAENXZ) example_unittest.obj : error LNK2001: unresolved external symbol "public: virtual double __thiscall Circle::perimeter(void)" (?perimeter@Circle@@UAENXZ)

    Read the article

  • Access Violation When Accessing an STL Object Through A Pointer or Reference In A Different DLL or E

    - by Yan Cheng CHEOK
    I experience the following problem while using legacy VC6. I just cann't switch to modern compiler, as I am working on a legacy code base. http://support.microsoft.com/kb/172396 Since there are no way to export map, my planned workaround is using static linking instead of dynamic linking. I was wondering whether you all had encountered the similar situation? What is your workaround for this? Another workaround is to create wrapper class around the stl map, to ensure creation and accessing stl map, are within the same DLL space. Note that, fun0, which uses wrapper class will just work fine. fun1 will crash. Here is the code example : // main.cpp. Compiled it as exe. #pragma warning (disable : 4786) #include <map> #include <string> template <class K, class V> class __declspec(dllimport) map_wrapper { public: map_wrapper(); ~map_wrapper(); map_wrapper(const map_wrapper&); map_wrapper& operator=(const map_wrapper&); V& operator[](const K&); const V& operator[](const K&) const; const V& get(const K&) const; void put(const K&, const V&); int size() const; private: std::map<K, V> *m; }; __declspec(dllimport) void fun0(map_wrapper<std::string, int>& m); __declspec(dllimport) void fun1(std::map<std::string, int>& m); int main () { map_wrapper<std::string, int> m0; std::map<std::string, int> m1; m0["hello"] = 888; m1["hello"] = 888; // Safe. The we create std::map and access map both in dll space. fun0(m0); // Crash! The we create std::map in exe space, and access map in dll space. fun1(m1); return 0; } // dll.cpp. Compiled it as dynamic dll. #pragma warning (disable : 4786) #include <map> #include <string> #include <iostream> /* In map_wrapper.h */ template <class K, class V> class __declspec(dllexport) map_wrapper { public: map_wrapper(); ~map_wrapper(); map_wrapper(const map_wrapper&); map_wrapper& operator=(const map_wrapper&); V& operator[](const K&); const V& operator[](const K&) const; const V& get(const K&) const; void put(const K&, const V&); int size() const; private: std::map<K, V> *m; }; /* End */ /* In map_wrapper.cpp */ template <class K, class V> map_wrapper<K, V>::map_wrapper() : m(new std::map<K, V>()) { } template <class K, class V> map_wrapper<K, V>::~map_wrapper() { delete m; } template <class K, class V> map_wrapper<K, V>::map_wrapper(const map_wrapper<K, V>& map) : m(new std::map<K, V>(*(map.m))) { } template <class K, class V> map_wrapper<K, V>& map_wrapper<K, V>::operator=(const map_wrapper<K, V>& map) { std::map<K, V>* tmp = this->m; this->m = new std::map<K, V>(*(map.m)); delete tmp; return *this; } template <class K, class V> V& map_wrapper<K, V>::operator[](const K& key) { return (*this->m)[key]; } template <class K, class V> const V& map_wrapper<K, V>::operator[](const K& key) const { return (*this->m)[key]; } template <class K, class V> const V& map_wrapper<K, V>::get(const K& key) const { return (*this->m)[key]; } template <class K, class V> void map_wrapper<K, V>::put(const K& key, const V& value) { (*this->m)[key] = value; } template <class K, class V> int map_wrapper<K, V>::size() const { return this->m->size(); } // See : http://www.parashift.com/c++-faq-lite/templates.html#faq-35.15 // [35.15] How can I avoid linker errors with my template classes? template class __declspec(dllexport) map_wrapper<std::string, int>; /* End */ __declspec(dllexport) void fun0(map_wrapper<std::string, int>& m) { std::cout << m["hello"] << std::endl; } __declspec(dllexport) void fun1(std::map<std::string, int>& m) { std::cout << m["hello"] << std::endl; }

    Read the article

  • Use auto_ptr in VC6 dll cause crash

    - by Yan Cheng CHEOK
    // dll #include <memory> __declspec(dllexport) std::auto_ptr<int> get(); __declspec(dllexport) std::auto_ptr<int> get() { return std::auto_ptr<int>(new int()); } // exe #include <iostream> #include <memory> __declspec(dllimport) std::auto_ptr<int> get(); int main() { { std::auto_ptr<int> x = get(); } std::cout << "done\n"; getchar(); } The following code run perfectly OK under VC9. However, under VC6, I will experience an immediate crash with the following message. Debug Assertion Failed! Program: C:\Projects\use_dynamic_link\Debug\use_dynamic_link.exe File: dbgheap.c Line: 1044 Expression: _CrtIsValidHeapPointer(pUserData) Is it exporting auto_ptr under VC6 is not allowed? It is a known problem that exporting STL collection classes through DLL. http://stackoverflow.com/questions/2451714/access-violation-when-accessing-an-stl-object-through-a-pointer-or-reference-in-a However, I Google around and do not see anything mention for std::auto_ptr. Any workaround?

    Read the article

  • Not all symbols of an DLL-exported class is exported (VS9)

    - by mandrake
    I'm building a DLL from a group of static libraries and I'm having a problem where only parts of classes are exported. What I'm doing is declaring all symbols I want to export with a preprocessor definition like: #if defined(MYPROJ_BUILD_DLL) //Build as a DLL # define MY_API __declspec(dllexport) #elif defined(MYPROJ_USE_DLL) //Use as a DLL # define MY_API __declspec(dllimport) #else //Build or use as a static lib # define MY_API #endif For example: class MY_API Foo{ ... } I then build static library with MYPROJ_BUILD_DLL & MYPROJ_USE_DLL undefined causing a static library to be built. In another build I create a DLL from these static libraries. So I define MYPROJ_BUILD_DLL causing all symbols I want to export to be attributed with __declspec(dllexport) (this is done by including all static library headers in the DLL-project source file). Ok, so now to the problem. When I use this new DLL I get unresolved externals because not all symbols of a class is exported. For example in a class like this: class MY_API Foo{ public: Foo(char const* ); int bar(); private: Foo( char const*, char const* ); }; Only Foo::Foo( char const*, char const*); and int Foo::bar(); is exported. How can that be? I can understand if the entire class was missing, due to e.g. I forgot to include the header in the DLL-build. But it's only partial missing. Also, say if Foo::Foo( char const*) was not implemented; then the DLL build would have unresolved external errors. But the build is fine (I also double checked for declarations without implementation). Note: The combined size of the static libraries I'm combining is in the region of 30MB, and the resulting DLL is 1.2MB. I'm using Visual Studio 9.0 (2008) to build everything. And Depends to check for exported symbols.

    Read the article

  • Does the LGPL allow me to do this?

    - by user1229892
    I am planning to develop a commercial software using a LGPL software. In the LGPL software that I am using some functions in a class are not fully implemented. I want to modify the LGPL code so that the class and not-implemented functions are made visible outside the dll by adding dllexport infront of class and by adding virtual keyword infront of function. Then I plan to implement those functions in my proprietary software. I am ready to distribute the modified LGPL code but not proprietary software that implements functions in the way I want. Does that violate LGPL terms and conditions?

    Read the article

  • About inconsistent dll linkage

    - by baris_a
    How can I remove this link warning? You can see code segment that causes this warning. Also Thanks in advance. static AFX_EXTENSION_MODULE GuiCtrlsDLL = { NULL, NULL }; //bla bla // Exported DLL initialization is run in context of running application extern "C" void WINAPI InitGuiCtrlsDLL() { // create a new CDynLinkLibrary for this app new CDynLinkLibrary(GuiCtrlsDLL); // nothing more to do } warning C4273: 'InitGuiCtrlsDLL' : inconsisten t dll linkage I have also export and import definitions, like: #ifdef _GUICTRLS #define GUI_CTRLS_EXPORT __declspec(dllexport) #else #define GUI_CTRLS_EXPORT __declspec(dllimport) #endif

    Read the article

1 2 3  | Next Page >