Subject: C++ and dlls???
From: [email-masked] (Roland Geier)

16 Jun 1997 17:57:11 -0700
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked]
X-Face: 
	 %JjDwL,CM#gbv*uICrNLdM9yk_LRxMh3DV'.fQ>iw'N;7([Jq}2|J#5o".kzM&>7tW`8T^Z
	 buvRLp?jvQ+sbD3BND%=&D: lT%vT4p7cGcGRP5JO+F'^
X-Mailer: ELM [version 2.4ME+ PL31 (25)]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Original-Sender: [email-masked]

Hi!

I'm trying to port a c++-project from Unix to NT4.0 using b18. Thereby I use a
Date/Time-package consisting of several classes dealing with Dates and
Times (class Date, class Time, class Month and so on). Each of this
classes is packed into a separate Module (.cc/.h-File).  There's no
problem compiling those modules into '.o'-Files, but don't get them
packed into a single dll.

After compiling I'm using the following commands to build a dll:

--------------------- cut here ---------------------

if [ ! -f fixup.o ]; then
  echo 'asm (".section .idata$3\n" ".long 0,0,0,0, 0,0,0,0");' >fixup.cc
  g++ -c fixup.cc
fi;

# --- create a temporary archive
ar rs tmp.a *.o

# --- create .def-File
echo EXPORTS > DateTime.def
nm tmp.a | egrep " [CT] " | sed s/.........T._//g >xxx.tmp
sed s/.........C._//g q.scr >> DateTime.def
rm -f xxx.tmp

g++ -s -v  -nostartfiles -Wl,--dll -e _dll_entry@12 -o tmp.dll -Wl,--base-file=tmp.base *.o

--------------------- cut here ---------------------

I did not mention the call of 'dlltool' as the g++-command already fails.
The DateTime.def-File looks like the following:

--------------------- cut here ---------------------
EXPORTS
BreakDown__C4DateRiR7WeekDayR5MonthT1
First__4Date
GetDateStr__4Date
GetMDay__C4Date
GetMonth__C4Date
GetPureDateStr__4Date
GetRep__4DateiG5Monthi
GetWDay__C4Date
GetYear__C4Date
InitializeEpoch__4Date
Last__4Date
SetDateFromChar__4DatePc
SetDateFromInt__4Dateiii
Today__4Date
__4DateG4Time
__4DatePc
__4DateiG5Monthi
__4Dateiii
Datetime_Init
dll_entry@12
Offset__5Monthi
Size__5Monthi
:
:
--------------------- cut here ---------------------

The call of 'g++' outputs the following:

--------------------- cut here ---------------------

Reading specs from C:\Programme\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-970404\specs
gcc version cygnus-2.7.2-970404
 C:\Programme\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-970404\../../../../i386-cygwin32\bin\ld.exe
-o tmp.dll -e dll_entry@12 -s
-LC:\Programme\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-970404
-LC:\Programme\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib
-LC:\Programme\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-970404\../../../../i386-cygwin32\lib
-LC:\Programme\gnuwin32\b18\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2
..7.2-970404\../../.. --dll --base-file=tmp.base Date.o
DateTimePkgInit.o Month.o Time.o TinyTime.o WeekDay.o Year.o fixup.o
-lstdc++ -lm -lgcc -lcygwin -lkernel32 -lgcc
Date.o: In function `Date::GetRep(int, Month, int)':
/home/project/packages/cms++-2.0/src/types/Date.cc:18: undefined reference to `GLOBAL_OFFSET_TABLE_'
/home/project/packages/cms++-2.0/src/types/Date.cc:19: undefined reference to `Offset__4Yeari@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:19: undefined reference to `Offset__5Monthi@PLT'
Date.o: In function `_4DateiG5Monthi':
/home/project/packages/cms++-2.0/src/types/Date.cc:22: undefined reference to `GLOBAL_OFFSET_TABLE_'
/home/project/packages/cms++-2.0/src/types/Date.cc:23: undefined reference to `__5MonthRC5Month@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:23: undefined reference to `GetRep__4DateiG5Monthi@PLT'
Date.o: In function `_4Dateiii':
/home/project/packages/cms++-2.0/src/types/Date.cc:27: undefined reference to `GLOBAL_OFFSET_TABLE_'
/home/project/packages/cms++-2.0/src/types/Date.cc:28: undefined reference to `__5Monthi@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:29: undefined reference to `__5MonthRC5Month@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:29: undefined reference to `GetRep__4DateiG5Monthi@PLT'
Date.o: In function `_4DatePc':
/home/project/packages/cms++-2.0/src/types/Date.cc:31: undefined reference to `GLOBAL_OFFSET_TABLE_'
/home/project/packages/cms++-2.0/src/types/Date.cc:34: undefined reference to `strlen@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:34: undefined reference to `strlen@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:34: undefined reference to `__assert@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:36: undefined reference to `strcpy@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:37: undefined reference to `strtok@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:38: undefined reference to `strtok@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:39: undefined reference to `strtok@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:40: undefined reference to `atoi@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:41: undefined reference to `atoi@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:42: undefined reference to `atoi@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:43: undefined reference to `strlen@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:54: undefined reference to `__5Monthi@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:55: undefined reference to `__5MonthRC5Month@PLT'
/home/project/packages/cms++-2.0/src/types/Date.cc:55: undefined reference to `GetRep__4DateiG5Monthi@PLT'
Date.o: In function `_4DateG4Time':
/home/project/packages/cms++-2.0/src/types/Date.cc:58: undefined reference to `GLOBAL_OFFSET_TABLE_'

--------------------- cut here ---------------------

What about that 'GLOBAL_OFFSET_TABLE'? Could anybody help me to find
out what's going on there? Is there a general description how to build
relocatable dlls containing c++-classes?

Many thx in advance

--- Roland.

---
Roland Geier                    Phone: ++49 (8505) 92181          
Universitaet Passau, GER 
Lehrstuhl Prof. Dr. Donner      [email-masked]	
D-94032 Passau                  http://www.uni-passau.de/~geier/

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".