Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compiling a C++ file as a MDL DLL

161 views
Skip to first unread message

hotp...@my-deja.com

unread,
Feb 1, 2001, 4:24:10 PM2/1/01
to
I'm trying to compile a C++ file as a DLL in MDL & I'm having problems
in linking. I took a look at the mdlvc sample in Bentley developerware
site but I see that it uses only a C file.
extpnt.obj : error LNK2001: unresolved external symbol "int __cdecl
dlmSystem_ca
llMdlFunction(struct mdlDesc *,void *,...)" (?
dlmSystem_callMdlFunction@@YAHPAUm
dlDesc@@PAXZZ)
extpnt.exp : error LNK2001: unresolved external symbol _initialize

I'm using the MSVC C++ compiler.
Any help is greatly appreciated.

Thanks
-SR


Sent via Deja.com
http://www.deja.com/

Michal Baranski

unread,
Feb 1, 2001, 3:21:56 AM2/1/01
to
File *.def not found. Create file *.def and problem not exist.

hotp...@my-deja.com wrote:

--
Michal Baranski
BSiPE "Energoprojekt-Katowice" SA
mailto:baransk...@energoprojekt.com.pl


Enrico S. Penetti

unread,
Feb 2, 2001, 5:40:10 AM2/2/01
to
This is not correct. In the *.def-file, you are declares your functions to
export. The function dlmSystem_callMdlFunction is a function exported from
ustation.dll which you must linking to your apps.

cu
Enrico Penetti


Michal Baranski schrieb in Nachricht
<3A791CA4...@energoprojekt.com.pl>...

hotp...@my-deja.com

unread,
Feb 2, 2001, 9:46:10 AM2/2/01
to
Enrico,
In another mail you'd written:
>You must set the additionally library path to the mdl-libs-directory,
>for example: "D:\USTNT95\MDL\LIBRARY" an then you must set the
>MDLBLTIN.LIB in the link options.

I am including the mdlbltin.lib and the paths are ok. I think it has to
do with the strict type checking which happens in C++.
For e.g:
In the include file dlmsys.fdf there is the function definition
int dlmSystem_callMdlFunction
(
MdlDesc *pMdlFileDesc,
MdlFunctionP pFunc,
...
);

& in mdl.h depending on the preprocessor directive
# if defined (mdl)
MdlFunctionP is either
typedef int (*MdlFunctionP)();
# else
typedef void *MdlFunctionP;
#endif

And this is what makes it break while trying to link because the
Microsoft Visual C++ linker tries to do a strict(exact) type matching
with the definition in the mdl libraries (mdlbltin.lib) & crashes.

So, my question is have any of youbeen able to resolve this -say by
using extern "c" or something like that.

Thanks

-SR

In article <95e2t1$go9ks$1...@ID-25655.news.dfncis.de>,

hopeth...@my-deja.com

unread,
Feb 2, 2001, 9:52:54 AM2/2/01
to
Put this line at the top of your c++ file below your #include's:
#define DLLEXPORT extern "C" __declspec( dllexport )

It sort of casts the c++ file as a c file.


In article <95ck5c$d4q$1...@nnrp1.deja.com>,

hotp...@my-deja.com

unread,
Feb 2, 2001, 10:07:02 AM2/2/01
to
Nope. The problem remains.

In article <95ehk1$49$1...@nnrp1.deja.com>,


hopeth...@my-deja.com wrote:
> Put this line at the top of your c++ file below your #include's:
> #define DLLEXPORT extern "C" __declspec( dllexport )
>
> It sort of casts the c++ file as a c file.
>
> In article <95ck5c$d4q$1...@nnrp1.deja.com>,
> hotp...@my-deja.com wrote:
> > I'm trying to compile a C++ file as a DLL in MDL & I'm having
problems
> > in linking. I took a look at the mdlvc sample in Bentley
developerware
> > site but I see that it uses only a C file.
> > extpnt.obj : error LNK2001: unresolved external symbol "int __cdecl

> > dlmSystem_callMdlFunction(struct mdlDesc *,void *,...)" (?

hopeth...@my-deja.com

unread,
Feb 2, 2001, 10:33:31 AM2/2/01
to
This is from the WINSTART example on DeveloperWare which uses a c++
file:
#include <afxwin.h> // MFC core and standard components
#include <afxdlgs.h> // MFC components
#include <stdio.h>
#include <stdlib.h>

#define DLLEXPORT extern "C" __declspec( dllexport )

/*----------------------------------------------------------------------
+
|
| name winstart
|
+----------------------------------------------------------------------*
/
DLLEXPORT int winstart
(
char *theProgram
)
{
/* See Win32 Programmer's reference on STARTUPINFO */
STARTUPINFO start;
PROCESS_INFORMATION proc;

start.cb = sizeof(STARTUPINFO);
start.lpReserved =NULL;
start.lpDesktop=NULL;
start.lpTitle=NULL;
start.cbReserved2 = 0;

/* Create a new process using Win32API */
if (false==CreateProcess ( NULL, theProgram,
NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &start,
&proc))
{
return false;
}
else
{
/* Wait for the application to start up */
WaitForInputIdle (proc.hProcess, 10000);
CloseHandle (proc.hProcess);
CloseHandle (proc.hThread);
return true;
}
}

DLLEXPORT int initialize
(
void
)
{
/* This function simplifies compiling with DLMLINK.MKI */
return 0;
}

In article <95eiee$r6$1...@nnrp1.deja.com>,

hotp...@my-deja.com

unread,
Feb 2, 2001, 11:49:18 AM2/2/01
to
Yes, I saw that. but it doesnt call "dlmSystem_callMdlFunction" & hence
it doesnt do a call-back to the MDL groundwork while mdlvc.c does a
callback & gets the dgn files name from a function in the .mc file.

I'm still at square 1.

Thanks for your input though.

-SR


In article <95ek0b$2em$1...@nnrp1.deja.com>,

Chris Zakrewsky

unread,
Feb 4, 2001, 7:24:25 AM2/4/01
to
Hi,

You may try to make a hybride:
put whatever causes headache in .c,
keep the rest in .cpp, compile both
and link together.

(.c will be your 'wrapper' code calling MDL)

HTH
--
Best Regards,
/Chris Zakrewsky

<hotp...@my-deja.com> wrote in message news:95eoe8$6s9$1...@nnrp1.deja.com...

Enrico S. Penetti

unread,
Feb 5, 2001, 3:31:35 AM2/5/01
to
I include the MDL-Headers like following code snipped:
-----
#ifdef MDL // MDL-Unterstützung (this is declared by me)
#ifdef __cplusplus
extern "C" {
#endif

#include <basedefs.h>
#include <dloadlib.h>
#include <dlmfuncs.h>
#include <mssystem.fdf>
#include <dlmsys.fdf>

#ifdef __cplusplus
}
#endif
#endif // MDL
------
and with the settings where in the other mail i have written.
Sometimes you must the order changes in which the libs are linking.


hotp...@my-deja.com schrieb in Nachricht <95eh7f$vl6$1...@nnrp1.deja.com>...

hotp...@my-deja.com

unread,
Feb 5, 2001, 9:49:29 AM2/5/01
to
Yes. It works. Though it still needed the following additional line:
Thanks for your help.

-SR

#ifdef MDL // MDL-Unterstützung (this is declared by me)
#ifdef __cplusplus
extern "C" {
#endif

#define DLLEXPORT extern "C" __declspec( dllexport )

#ifdef __cplusplus
}
#endif
#endif // MDL


In article <95lofv$hrles$1...@ID-25655.news.dfncis.de>,

Ambrosa

unread,
Feb 7, 2001, 4:41:33 AM2/7/01
to
Hi All
I am sending you my example you can use it
in your programs. There is no problem to compile C++ code by Visual C++ and
MFC of course
and use it to interact with MDL code. I also made a C++ class to interact
with MDL, but it would cost more space here.
Don forget to add def file and export
mdl_setCall @1

Best regards
Ambrosa


File called :MDLLib.cpp
********************

#include "stdafx.h"

extern "C"{
// mdl communication include
#define winNT
#include "mssystem.fdf"
#include "dlmsys.fdf"
#define MDLCALL __stdcall
}

mdlDesc *mdlDescP = NULL; // Pointer to Call back MDL module
MdlFunctionP func = 0L; // Pointer to MDL function

int MDLCALL mdl_setCall(MdlFunctionP mdlFunc){
if ((func = mdlFunc) && (mdlDescP = mdlSystem_getCurrMdlDesc()))
return true;
return false;
}

int MDLCALL mdl_call(short counter){
if ((func) && (mdlDescP))
return dlmSystem_callMdlFunction(mdlDescP,func,counter);
return FALSE;
}

"Chris Zakrewsky" <ch...@cadperf.se> wrote in message
news:aRbf6.1373$u7....@nntpserver.swip.net...

0 new messages