[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::axp-developer

Title:Alpha Developer Support
Notice:[email protected], 800-332-4786
Moderator:HYDRA::SYSTEM
Created:Mon Jun 06 1994
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3722
Total number of notes:11359

3225.0. "CRC Infomation Systems, Inc" by HYDRA::AXPDEVELOPER (Alpha Developer support) Thu Feb 20 1997 16:54


    Company Name :  CRC Infomation Systems, Inc
    Contact Name :  Jim Case
    Phone        :  (602) 451-7474
    Fax          :  
    Email        :  [email protected]
    Date/Time in :  20-FEB-1997 16:53:02
    Entered by   :  Jim Mikelis
    SPE center   :  MRO

    Category     :  nt
    OS Version   :  4.0
    System H/W   :  alpha


    Brief Description of Problem:
    -----------------------------
From:	SMTP%"[email protected]" 20-FEB-1997 16:34:08.69
To:	<[email protected]>
Subj:	Problems linking fortran and C into a DLL


Here is the makefile which contains routines that call other routines in a
standard LIB.  This makefile is supplosed to create OVERLAY.DLL but fails 
with Fatal Error:  multiply defined symbols. 

Thanks,
Jim Case
CRC Infomation Systems, Inc
(602) 451-7474

Output from make:

link /noentry /out:overlay.dll /dll  @overlay.ooo overlay.exp dfordll.lib  
     \crc\overlay\insert\insert.lib  
     \crc\numeric\source\numeric.lib  
     \crc\kam\source\kam.lib 
     \crc\toolbox\source\toolbox.lib

Microsoft (R) 32-Bit Executable Linker Version 3.00.5270
Copyright (C) Microsoft Corp 1992-1995. All rights reserved.

addanypath.obj
addpath.obj
addprintpath.obj
addprintsycompath.obj
agebalbox.obj
attrf.obj
attrp.obj
attrs.obj
atype.obj
big.obj
blank.obj
box.obj
center.obj
chain.obj
chainm.obj
chkdate.obj
chkdaterng.obj
ckdgt.obj
clrarea.obj
clrln.obj
clrscr.obj
clrscr2.obj
cplace.obj
cpos.obj
crcbarcode.obj
crcedit.obj
crenam.obj
crtdisply.obj
crtinhp.obj
crtinput.obj
crtout.obj
cursoron.obj
date.obj
datei.obj
datrel.obj
day.obj
delay.obj
delnam.obj
dfilew.obj
dfl.obj
dirsrch.obj
displyhp.obj
doc.obj
dtimedrd.obj
dumbopen.obj
exinq.obj
expdate.obj
getkey.obj
getlog.obj
getscreen.obj
getsys.obj
getsys1.obj
getuser.obj
getvfub.obj
get_default_dir.obj
header.obj
hlinei.obj
ichr$.obj
idatrel.obj
ifauthorized.obj
inkey.obj
input.obj
ival.obj
jr30dasort.obj
lockit.obj
lpos.obj
lposd.obj
lpout.obj
lpplot.obj
lprint.obj
lprintd.obj
lptitl.obj
lvprnt.obj
mask.obj
mdata.obj
menudrvr.obj
nametomod.obj
okibar184.obj
okibarcode.obj
openbox.obj
ovreclock.obj
pfiler.obj
pfilew.obj
pfilewf.obj
phline.obj
pinit.obj
plotit.obj
pout.obj
pplot.obj
ppos.obj
ptitl.obj
pvline.obj
pvlinec.obj
pvlinel.obj
pvliner.obj
rchr$.obj
recfmt.obj
recint.obj
reclock.obj
reldat.obj
relidat.obj
rval.obj
sbmtcom.obj
scplot.obj
scplus.obj
scprntn.obj
screenon.obj
scriptcheck.obj
sctitl.obj
sendmail.obj
sendmailmessage.obj
serror.obj
spawn.obj
start.obj
subtitle.obj
sycalc.obj
termtype.obj
title.obj
today.obj
userno.obj
vali.obj
validate.obj
valr.obj
version.obj
vflongopen.obj
vfub.obj
vfup.obj
vfus.obj
vlinei.obj
wait.obj
wmbarmenu.obj
wmbarselect.obj
wmclearmenu.obj
wmgetfile.obj
wmgethotkey.obj
wmsetattr.obj
wmsethelp.obj
wmsethotkey.obj
yearrel$.obj
zerosup.obj
LIBC.lib(otsdiv.obj) : error LNK2005: _OtsDivide64 already defined in 
 dfordll.lib(DFOR.dll)
LIBC.lib(otsdiv.obj) : error LNK2005: _OtsDivide32 already defined in
 dfordll.lib(DFOR.dll)
LIBC.lib(otsdiv.obj) : error LNK2005: _OtsRemainder32 already defined in
 dfordll.lib(DFOR.dll)
overlay.dll : fatal error LNK1169: one or more multiply defined symbols found

%%%%%%%%%%%%%%%%%%%%%%%
Content-Disposition: attachment; filename="makefile"

!INCLUDE "\utils\F77.MAK"


all: overlay.obj overlay.dll

# ------------------------------
# BUILD OBJECT FILES
# ------------------------------

overlay.obj:: *.F77
          $(f77) $(fflags) /c \
!INCLUDE  "overlay.ff1"             
          $(f77) $(fflags) /c \
!INCLUDE  "overlay.ff2"

overlay.obj:: *.c
          CL /c /Gy *.c

# ------------------------------
# BUILD EXPORT LIBRARY
# ------------------------------

overlay.lib overlay.exp: overlay.def
        $(libr) /out:overlay.lib /machine:$(CPU) /def:overlay.def

# ------------------------------
# BUILD DLL
# ------------------------------

overlay.dll: overlay.exp overlay.lib 
        $(link) /noentry /out:overlay.dll /dll \
        @overlay.ooo overlay.exp dfordll.lib \
        \crc\overlay\insert\insert.lib \
        \crc\numeric\source\numeric.lib \
        \crc\kam\source\kam.lib \
        \crc\toolbox\source\toolbox.lib
clean:
      -del overlay.dll
      -del overlay.lib
      -del overlay.exp
      -del *.obj
                     

------=_NextPart_000_01BC1F3A.329C4E80
Content-Type: application/octet-stream; name="F77.mak"
Content-Transfer-Encoding: quoted-printable
Content-Description: F77.mak (MAK File)
Content-Disposition: attachment; filename="F77.mak"

#+
# F77.MAK - DEC Fortran application master NMAKE definitions file
#
# This software F77.MAK is part of the DEC Fortran.
# Copyright (C) 1993, 1994, 1995 Digital Equipment Corporation.
# All rights reserved.
#
# This software is furnished to you under a license by  Digital Equipment
# Corporation and must be used only in accordance with the terms and conditions
# of that license, and only with the inclusion of the above copyright notice.
# This software is protected by both United States copyright law and
# international treaty provisions. 
#
# This file should be included at the top of all MAKEFILEs as follows:
#  !include <f77.mak>
#
# NMAKE Options:
#
# Use the table below to determine the additional options for NMAKE
# Application Information Type         Invoke NMAKE
# ----------------------------         ------------
# For Debugging Info                   nmake debug=3D1
# For linker map                       nmake linkmap=3D1
# For linking with the DLLs            nmake linkdll=3D1
#-

!IF "$(CPU)" !=3D "ALPHA"
!ERROR This NMAKE definitions file is for Alpha AXP system only.
!ENDIF

!IF "$(DECFORT_TOOLS)" =3D=3D ""
!ERROR DECFORT_TOOLS must be defined to be one of MSVC20, MSDN35 or MSDN31
!ENDIF

!IF ( ("$(DECFORT_TOOLS)"  "MSVC20") || ("$(DECFORT_TOOLS)" "msvc20") )

crtimplibmsvcrt.lib

!IFNDEF link
link  link
!ENDIF
!IFNDEF libr
libr  lib
!ENDIF

!ENDIF

!IF ( ("$(DECFORT_TOOLS)"  "MSDN35") || ("$(DECFORT_TOOLS)"  "msdn35") )

crtimplibcrtdll.lib

!IFNDEF link
link  link
!ENDIF

!IFNDEF libr
libr  lib
!ENDIF

!ENDIF

!IF ( ("$(DECFORT_TOOLS)"  "MSDN31") || ("$(DECFORT_TOOLS)" "msdn31") )

crtimplibcrtdll.lib

!IFNDEF link
link  link32
!ENDIF

!IFNDEF libr
libr  lib32
!ENDIF

!ENDIF

#   Default

!IFNDEF link
link  link
!ENDIF
!IFNDEF libr
libr  lib
!ENDIF

#+
# Define the compiler verbs.
#-

FOR  f77
f77  f77

#+
# Macros for the compiler
#-

#f77_standard   /fort /novms /align:norecords /align:dcommons 
 /extend_source /optimize:0 /real_size:64 /warn:declarations /nolink
f77_standard  /fort /novms /align:norecords /align:dcommons
 /extend_source \
 /optimize:0 /real_size:64 /warn:declarations /align:commons /call_dll

!IFDEF DEBUG
f77_debug  /debug:full
lnk_debug  /debug:full /debugtype:both
!ELSE
f77_debug  /debug:none
lnk_debug  /debug:none
!ENDIF

!IFDEF LINKDLL

f77_dll    /call_dll
!IF ( ("$(DECFORT_TOOLS)"  "MSDN31") || ("$(DECFORT_TOOLS)"  "msdn31") )
f77libs    dfordll.lib dmathdll.lib dotsdll.lib dutildll.lib \
                $(crtimplib) kernel32.lib
!ELSE
f77libs    dfordll.lib $(crtimplib) kernel32.lib
!ENDIF

!ELSE

f77_dll   
!IF ( ("$(DECFORT_TOOLS)"  "MSDN31") || ("$(DECFORT_TOOLS)"  "msdn31") )
#f77libs    dfor.lib dmath.lib dots.lib dutil.lib libc.lib kernel32.lib
f77libs    dfor.lib dmath.lib dots.lib dutil.lib kernel32.lib
!ELSE
#f77libs    dfor.lib libc.lib kernel32.lib
f77libs    dfor.lib  kernel32.lib
!ENDIF

!ENDIF

fflags     $(f77_debug) $(f77_dll) $(f77_standard)

#+
# Macros for the FPP Preprocesor
#-

fpp  $(f77) $(fflags) /fpp
fppflags 

#+
# Macros for the linker.
#-

!IFDEF LINKMAP
lflags  /map:$(*B).map $(lflags)
!ELSE
lflags  $(lflags)
!ENDIF


#+
# Add .fpp to the .SUFFIXES list
#-

.SUFFIXES: .exe .obj .asm .c .bas .cbl .fpp .for .pas .res .rc

#+
# Define the inference rules
#-

.obj.exe:
   $(f77) $(f77_dll) $(f77_debug) /link $(lflags) $(lnk_debug) $*.obj

.for.exe:
   $(f77) $(fflags) $*.for /link $(lflags)

.fpp.exe:
   $(fpp) $(fppflags) $*.fpp /link $(lflags)

.for.obj:
   $(f77) $(f77_debug) $*.for /nolink /object:$@

.fpp.obj:
   $(f77) $(f77_debug) /nolink /object:$@ /fpp $(fppflags) $*.fpp

T.RTitleUserPersonal
Name
DateLines
3225.1HYDRA::AXPDEVELOPERAlpha Developer supportFri Feb 21 1997 14:3740
From:	HYDRA::AXPDEVELOPER "[email protected]" 21-FEB-1997 14:36:34.77
To:	US4RMC::"[email protected]"
CC:	LOG 1997-3225 LINKING DLL PROBLEM,AXPDEVELOPER
Subj:	Log 1997-3225 Linking DLL problem

Jim,
	In general the rule for builing images is:

 "If you link against ANY DLL's (not counting system ones) then you should
  link against ALL DLL's".

In other words, if you are building a "statically linked app" then don't
link against any import libs. If you are building an app (or DLL) that
is linked against other DLL's then link against the DLL version (not the
static version) of ALL the other libraries. If you don't do this you
will find that you have multiple copies of "shared" data (for instance,
you will have multiple errno's, multiple ctype tables, etc. etc.)

In your case you are linking against a DLL import library (dfordll.lib)
and a <<STATIC>> C library (libc.lib). This creates just the type of
problem you are seeing. The solution is to link all static or all DLL.
Since it looks like you are in fact building a DLL, this implies that
you should link all DLL so the "dfordll.lib" is correct but you need to
link against the DLL version of the C library.

Libc.lib may be being pulled in because you didn't compile using /MD
when you compiled the C code. Using /LINK /NODEFAULTLIB may "fix the
problem" but may leave you with multiple copies of errno, etc. Recompile
the C code with /MD to REALLY fix the problem and not just hide the
symptom.

I hope that helps.

Best Regards,

  James Mikelis, Alpha Developer Support
  Digital Equipment Corporation, 200 Forest St. [MR01-2/K5], Marlboro, MA 01752
  Phone: +1.800.332.4786 FAX: +1.508.467.1468 [paper] (or) +1.508.467.3440 [online]
  EMAIL: [email protected] 
  URL:   http://www.partner.digital.com/www-swdev/