[DGD]FW: Calling CPP Functions from an Extension

Michael J. Bacon mj.bacon at gte.net
Fri Jan 19 23:23:48 CET 2001


	Just wanted to let everyone know what the solution was, in case someone
else runs against this.  This little problem will only happen in the Windows
world, so if you don't build dgd in that environment you can ignore this...
:-)

	Anyway, the problem described below is the result of libraries being linked
in the wrong order.  The MFC libraries have to be linked before the STDC
libraries.  To fix the problem, I used "/nod:Nafxcwd.lib /nod:Libcmtd.lib"
switches to the linker to supress linkage of the default libraries, then,
added them as the first two libraries to be linked, in that order
"Nafxcwd.lib Libcmtd.lib".  Everything then linked normally and runs
happily.

	Probably something a microsoft C++ expert would know right off the bat, but
it took me a few days to find a knowledge base article about it:

	http://support.microsoft.com/support/kb/articles/q148/6/52.asp

	Anyway, enjoy, and everyone have a great friday!


Thanks;
Michael.
-----Original Message-----
From: Michael J. Bacon [mailto:mj.bacon at gte.net]
Sent: Wednesday, January 17, 2001 8:37 AM
To: dgd at list.imaginary.com
Subject: Calling CPP Functions from an Extension



	Hello all!  My apologies if this has been asked and answered in the past I
am relatively new to the list and still trying to figure out the best way to
go through the archive files in a logical manner.

	Anyway, I've been playing around with dgd1.2's extension capabilities.
Very neat I must say.  For convoluted reasons I find myself needing to call
C++ functions from an extension.  I realize I will be unable to directly
access class objects or advanced C++ constructs from an extension, but I
have devised a few functions which, in theory, should act as a layer between
the C++ objects and methods and the procedural C calls any extension would
make.  I wrote a simple extension to test this theory, and I'm glad I did,
because I can't get things to link.

	I am trying to do this on WinNT using Visual C++ 6.0.  I am trying to link
in a very simple CPP file which at the moment does nothing except declare a
string variable...  It looks like this:

------
#define TESTHR(x) if FAILED(x) _com_issue_error(hr)

// Function declarations
int OpenX(void);

///////////////////////////////////////////////////////////
//                                                       //
//               OpenX Function                          //
//                                                       //
///////////////////////////////////////////////////////////

int OpenX(void)
{

    _bstr_t strCnn("Provider=sqloledb;Data Source=MyServer;"
        "Initial Catalog=pubs;User Id=sa;Password=;");


	return 0;

}
------

Compiles fine, but when I link I get the following errors:

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

No configuration specified.  Defaulting to windgd - Win32 Debug.
        link.exe @C:\WINDOWS\TEMP\nma00163.
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator
new(unsigned i
nt)" (??2 at YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void
*)"
(??3 at YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
.\Debug/dgd.exe : fatal error LNK1169: one or more multiply defined symbols
foun
d
NMAKE : fatal error U1077: 'D:\PROGRA~1\MICROS~1\VC98\BIN\link.exe' : return
cod
e '0x491'
Stop.


	Any ideas what I am doing wrong?  I haven't modified windgd.mak at all
except to add the cpp file to the dependency and to link it in...

	Thanks in advance for any advice...


Michael.


List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list