Linking 3GL code to so that OpenROAD can invoke the resulting DLL

79 views
Skip to first unread message

coli...@fintechnix.com

unread,
Mar 18, 2011, 1:55:46 AM3/18/11
to OpenROAD Users Mailing List
Hi all,


We have a ESQLC program which we use to perform system calls and get a
return value

On Unix we build a .so file using the Ingres supplied makefile, set
II_LIBU3GL and it works fine
With a new Windows-only client we need to build the same code into a
DLL and call it using CALLPROC systm ( p1, p2, p3, p4 ....)

I've installed Windows Visual Studio C++ 2008 Express edition and
Microsoft Platform SDK for Windows Server 2003 R2 on Windows XP


I have one entry point (systm.sc) and a separate function that
systm.sc calls (printqry.sc)


I have added the following to PATH :


C:\Program Files\Microsoft Platform SDK for Windows Server 2003
R2\bin;
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;
C:\Program Files\Microsoft Visual Studio 9.0\VC\Bin;


I have added the following to INCLUDE :


C:\Program Files\Microsoft Platform SDK for Windows Server 2003
R2\Include;
C:\Program Files\Microsoft Visual Studio 9.0\VC\include


I have added the following to LIB :


C:\Program Files\Microsoft Platform SDK for Windows Server 2003
R2\Lib;
C:\Program Files\Microsoft Visual Studio 9.0\VC\Lib


I then run :


nmake /NOLOGO -f makefile_ingres_2006 nodebug=1
mt.exe -nologo -manifest systm.dll.manifest -outputresource:systm.dll;
2


Where makefile_ingres_2006 contains:


!include "C:\Program Files\Microsoft Platform SDK for Windows Server
2003 R2\Include\Win32.Mak"


##############################################


FILENAM=systm
SUBFILE=printqry


##############################################


# Link systm.c into .obj


# macro defines
OBJS=$(FILENAM).obj


# target list
all: $(FILENAM).dll


# Preprocess the source file
$(FILENAM).c: $(FILENAM).sc
esqlc $(FILENAM).sc


# Preprocess the source file
$(SUBFILE).c: $(SUBFILE).sc
esqlc $(SUBFILE).sc


# Update the object file if necessary
$(FILENAM).obj: $(FILENAM).c $(SUBFILE).c
$(cc) $(cdebug) $(cflags) -I. /W3 -DDBNTWIN32 $(cvarsdll) $
(FILENAM).c $(SUBFILE).c


# Update the import library
$(FILENAM).lib: $(FILENAM).obj $(FILENAM).def
$(implib)\
-machine:$(CPU)\
-def:$(FILENAM).def\
-out:$(FILENAM).lib


# Update the dynamic link library
$(FILENAM).dll: $(FILENAM).obj $(FILENAM).lib
$(link) $(ldebug) $(conlflags)\
-base:0x1C000000\
-dll\
-map:$(FILENAM).map\
-entry:_DllMainCRTStartup$(DLLENTRY)\
-out:$(FILENAM).dll\
$(FILENAM).obj $(FILENAM).exp\
C:\Progra~1\Ingres\IngresII\ingres\lib\esqlc.lib \
C:\Progra~1\Ingres\IngresII\ingres\lib\libingres.lib \
$(conlibsdll) \
$(_VC_MANIFEST_EMBED_DLL)


And systm.def contains


LIBRARY systm
EXPORTS systm


When the link command runs I get


systm.obj : error LNK2019: unresolved external symbol _printqry
referenced in function _systm


I'm obviously doing something wrong with the linking
If I remove all references to printqry.sc and SUBFILE it builds and
can be invoked just fine

Ingres 9.1 and OpenROAD 2006


Colin Hay
Database Administrator
Fintechnix
Level 5,
66 Clarence Street,
Sydney


Kim Ginnerup

unread,
Mar 18, 2011, 2:42:08 AM3/18/11
to openroa...@googlegroups.com, OpenROAD Users Mailing List
Have you defined a dllexports file containing you two functions?

Kim

Sendt fra min iPad 3G

> --
> You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
> To post to this group, send email to openroa...@googlegroups.com.
> To unsubscribe from this group, send email to openroad-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/openroad-users?hl=en.
>

Bodo Bergmann

unread,
Mar 18, 2011, 3:58:51 AM3/18/11
to openroa...@googlegroups.com
Colin,

Just from looking at your makefile I see:

# Update the object file if necessary
$(FILENAM).obj: $(FILENAM).c $(SUBFILE).c
$(cc) $(cdebug) $(cflags) -I. /W3 -DDBNTWIN32 $(cvarsdll) $
(FILENAM).c $(SUBFILE).c

IMHO (without testing) this will actually create two object files:
systm.o (from systm.c)and printqry.o (from printqry.c)

But you link command only uses $(FILENAM).obj, that is only systm.o is
used.
Therefore the printqry function defined in printqry.c is not linked.

Try with the following changes:

From:
OBJS=$(FILENAM).obj
Into:
OBJS=$(FILENAM).obj $(SUBFILE).obj
...
Then remove $(SUBFILE).c from the above $(FILENAM).obj target
definition,
add a new target definition for $(SUBFILE).obj using $(SUBFILE).c and
change the other target definitions to use both object files.

Bodo.

Hi all,


I then run :


Where makefile_ingres_2006 contains:


##############################################


FILENAM=systm
SUBFILE=printqry


##############################################


# macro defines
OBJS=$(FILENAM).obj


And systm.def contains


LIBRARY systm
EXPORTS systm

Reply all
Reply to author
Forward
0 new messages