I am currently working on a project which requires me to instantiate objects of a class. The class is in a dll which is accessed via its header file. I suspect that the dll does not work with visual c++ express edition which I am using. I would like some second opinions on this before I go back to the original programmer of the dll. Here are my reasons for believing it is incompattible.

The dll was originally written and compiled in VC++ 6.0. I then could not instantiate. When I emailed a copy of the program in which I tried to instantiate to the creator of the dll, he could compile and run it in VC++ 6.0. Afterwards he recompiled the dll in VC++ dot net 2003 and I could instantiate. However I then got warnings which basically stated that C++ allows but could not support certain methods or actions and so forth. This was fine since I could write programs which did not use graphical user interfaces. I then designed the GUI in Visual Basic and I execute the C++ programs by using the shell command which allows visual basic to execute the C++ programs in some command line interface.

However. When I want to design GUI programs in VC++ 2005 express edition I get all sorts of errors and warnings down the lines of ... this should not be declared as such... or ...not allowed except to declare... All of these errors are thrown by the header file of the dll. I am sure that I have the include command right. I checked with the STL. Also I am sure that the dll and header file are seen by VC++ express. I am going to paste a few lines of error message so that others can see and give an opinion. Could some of you guys be kind enough to take a look and tell me what you think?

There are more errors but I believe that these errors should be enough for someone to give a second opinion.

errors and warnings

c:\catcenterclient\include\gud\CATCenterClient.h(61) : warning C4272: 'GUD::CATCenterClient::~CATCenterClient' : is marked __declspec(dllimport); must specify native calling convention when importing a function.

c:\catcenterclient\include\gud\CATCenterClient.h(81) : warning C4394: 'const GUD::CATCenterClient::`vftable'' : per-appdomain symbol should not be marked with __declspec(dllimport)

c:\catcenterclient\include\gud\CATCenterClient.h(60) : error C3641: 'GUD::CATCenterClient::CATCenterClient' : invalid calling convention '__thiscall ' for function compiled with /clr:pure or /clr:safe

C:\catcenterclient\include\GUD\CATCenterNetClient.h(22) : warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)

the issuse is that your program is written in C++/CLI, the dll is in pure C++. to use the dll, you would need to use p-invoke. you could

#pragma unmanaged
#include <dll header files>
#pragma managed

you would also need to make modifications in your project settings (eg. change /clr:pure or /clr:safe compiler switch to just /clr), and perhaps a few changes in your code.
for more details, see:
http://msdn2.microsoft.com/en-us/library/ms973872.aspx
http://msdn2.microsoft.com/en-us/library/x0w2664k(VS.80).aspx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.