Re: C++ Version 6 app using c++ version 8 dll

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



David wrote:

Hello all,

My company is in the process of migrating to Visual Studio 2005. For now only new development is happening in 2005, leaving existing programs in version 6.

I have developed a MFC version 8 dll. A version 6 application needs to link to this new dll. The problem I am having is related to STRINGS. The dll exports a few functions that have strings as parameters. These function generated linker errors.

TestDlg.obj : error LNK2001: unresolved external symbol "int __cdecl Test(char const *,char const *)" (?Test @@YAHPBD0@Z)
Test.obj : error LNK2001: unresolved external symbol "int __cdecl Test2(int,int,char *,int *)" (?Test2@@YAHHHPADPAH@Z)

There are two other functions being exported that only have ints as parameters, and they do not give this linker error.

The prototypes for these two functions are:
__declspec(dllexport) BOOL Test (int nParam1, int nParam2, LPTSTR strError, int *p_nLen);
__declspec(dllexport) BOOL Test2 (LPCTSTR strPath, LPCTSTR strFile);

In the Test(…) function if an error occurs strError will have the error string.

How can I get this to work?


David:

Mixing compiler versions is usually not a good idea, but if you have a C-interface with simple types it should work.

It looks to me that the problem is your Unicode settings. It might seem that your VC6 app is an ANSI build, but your VC8 DLL is a Unicode build.

--
David Wilkinson
Visual C++ MVP
.



Relevant Pages

  • Re: resource unavailable problem
    ... David - thanks for the response. ... first value returns a valid resource handle, with the second handle it does ... Open the build DLL ... > in Visual Studio and check that it ...
    (microsoft.public.vc.mfc)
  • Re: problem with /DELAYLOAD
    ... Using Dumpbin /imports (Dumpin comes with Visual Studio) to see if the DLL ...
    (microsoft.public.vc.mfc)
  • Deployment Status
    ... I have multiple customer webspaces on a remote server. ... If Visual Studio ... Version 1.1 would set the name of the DLL to the name of the NameSpace. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Webpart unable to register as safecontrol
    ... Here are the steps to registering a webpart as safe for all of you who ... \SDK\v1.1\Bin directory of your Visual Studio Installation. ... Make the AssemblyKeyFile look like [assembly: ... This is the location of your dll. ...
    (microsoft.public.sharepoint.portalserver.development)
  • CoCreateObject of C# ComVisible object from C++ Crashes
    ... I have three DLL projects, all compiled from Visual Studio 2003 ... setup to get to the point where I try to call CoCreateInstance takes ... the CoCreateInstance call causes Visual Studio to crash ...
    (microsoft.public.dotnet.framework.interop)