DLL Build issues

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

DLL Build issues

Robert Cavanaugh
Hi Keith and everybody,

I am running into a linker issue. I am trying to convert a Microsoft makefile into its equivalent MinGW using gcc. I am trying to build an example DLL for the ARM debugging toolset, which runs on Windows. I can compile and link an example DLL with no problems using nmake and Visual Studio version 6. My target is a 32-bit Windows 7 machine. I am getting repeated "undefined reference" errors from ld, so I either have an ordering problem, a missing configuration problem, or a library incompatibility problem, or.... Basics first:

 gcc --version
gcc.exe (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ld --version
GNU ld (GNU Binutils) 2.25.1
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

$ bash --version
bash --version
GNU bash, version 3.1.23(1)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.

$ mintty --version
mintty --version
mintty 1.0.3
(C) 2011 Andy Koppe
License GPLv3+: GNU GPL version 3 or later
There is no warranty, to the extent permitted by law.




Computer is running Windows 7 Enterprise Service Pack 1 64-bit

Here is the output from the successful build using Microsoft tools (from Mintty shell)


$ nmake

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

        cl /c /Za /I..\.. /I..\..\..\armulif /I..\..\..\rdi /I..\..\..\clx /D_CONSOLE /D_MBCS /DNLS /nologo /W3 /GX /GR /WX -DRDI_VERSION=151 -DARM10MODEL  /O2 /G6 /MD /DNDEBUG   /DARM_RELEASE="\"RVARMulatorISS1.4\""  /DBUILD_NUMBER=312 /Iderived  /Fomillisec.obj ..\..\millisec.c
millisec.c
        C:\Progra~2\Mib055~1\VC98\bin\link /INCREMENTAL:no /DLL   /OUT:Millisec.dll /DEF:..\..\sordi.def /IMPLIB:Millisec.lib millisec.obj   version.res ..\..\..\armulif\armulif.b\intelrel\armulif.lib  ..\..\..\clx\clx.b\intelrel\clx.lib  user32.lib
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

   Creating library Millisec.lib and object Millisec.exp
        echo "Made Millisec.dll"
"Made Millisec.dll"

Here is the output from my converted makefile:

$ make -f Makefile.min all
gcc -g -c -O2 -Wall -Z -MD -MF millisec.dep -D_CONSOLE -D_MBCS -DNLS -DARM10MODEL -DARM_RELEASE="/RVARMulatorISS1.4/" -DBUILD_NUMBER=312 -DRDI_VERSION=151 -I../.. -I../../../armulif -I../../../rdi -I../../../clx -I. -Iderived ../../millisec.c -o millisec.o
gcc -shared -g  -L /c/MinGW/lib -L. -L../../../armulif/armulif.b/intelrel -L../../../rdi/rditools.b/intelrel -L../../../clx/clx.b/intelrel  -l user32 --enable-runtime-pseudo-reloc -t  -o millisec.dll --library ../../../armulif/armulif.b/intelrel/armulif.lib --library ../../../clx/clx.b/intelrel/clx.lib --library ../../../rdi/rditools.b/intelrel/rditools.lib millisec.o
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: mode i386pe
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../dllcrt2.o
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/crtbegin.o
millisec.o
(c:/MinGW/lib/libmingw32.a)dllmain.o
(c:/MinGW/lib/libmingw32.a)gccmain.o
(c:/MinGW/lib/libmingw32.a)tlssup.o
(c:/MinGW/lib/libmingw32.a)tlsthrd.o
(c:/MinGW/lib/libmingw32.a)pseudo-reloc.o
(c:/MinGW/lib/libmingw32.a)pseudo-reloc-list.o
(c:/MinGW/lib/libmingw32.a)crtst.o
(c:/mingw/bin/../lib/gcc/mingw32/4.8.1/libgcc.a)_ctors.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00748.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00709.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00682.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00676.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00633.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00625.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00610.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00595.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00583.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00266.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00182.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00137.o
(c:/MinGW/lib/libmsvcrt.a)dczfs00052.o
(c:/MinGW/lib/libmsvcrt.a)dczfh.o
(c:/MinGW/lib/libmsvcrt.a)dczft.o
(c:/MinGW/lib/libkernel32.a)dchds01215.o
(c:/MinGW/lib/libkernel32.a)dchds01213.o
(c:/MinGW/lib/libkernel32.a)dchds01173.o
(c:/MinGW/lib/libkernel32.a)dchds00814.o
(c:/MinGW/lib/libkernel32.a)dchds00734.o
(c:/MinGW/lib/libkernel32.a)dchds00577.o
(c:/MinGW/lib/libkernel32.a)dchds00529.o
(c:/MinGW/lib/libkernel32.a)dchds00510.o
(c:/MinGW/lib/libkernel32.a)dchds00236.o
(c:/MinGW/lib/libkernel32.a)dchds00207.o
(c:/MinGW/lib/libkernel32.a)dchdh.o
(c:/MinGW/lib/libkernel32.a)dchdt.o
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/crtend.omillisec.o: In function `peripsordi_Initialise':
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../../armulif/perip_sordi.h:169: undefined reference to `ToolConf_Lookup'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../../armulif/perip_sordi.h:184: undefined reference to `dir_getdirsep'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../../armulif/perip_sordi.h:185: undefined reference to `clx_findfile'
millisec.o: In function `peripsordi_Info':
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../../armulif/perip_sordi.h:211: undefined reference to `ToolConf_AddTyped'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../../armulif/perip_sordi.h:219: undefined reference to `ToolConf_AddTagged'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../../armulif/perip_sordi.h:214: undefined reference to `ToolConf_AddTagged'
millisec.o: In function `Millisec_Init':
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:185: undefined reference to `CVector_Init'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:192: undefined reference to `ToolConf_DLookupUInt'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:202: undefined reference to `ARMul_GetMCLK'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:206: undefined reference to `Hostif_PrettyPrint'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:220: undefined reference to `ToolConf_FlatChild'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:220: undefined reference to `ARMulif_ReadBusRange'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:185: undefined reference to `Hostif_RaiseError'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:185: undefined reference to `Hostif_PrettyPrint'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:196: undefined reference to `Hostif_ConsolePrint'
millisec.o: In function `Millisec_Exit':
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:238: undefined reference to `CVector_Iterate'
c:\Program Files\ARM\RVARMulator\ExtensionKit\1.4.1\312\win_32-pentium\armulext\millisec.b\intelrel/../../millisec.c:238: undefined reference to `CVector_Clear'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: link errors found, deleting executable `Millisec.dll'
collect2.exe: error: ld returned 1 exit status

make: *** [millisec.dll] Error 1

Any insights or pointers to pertinent documentation will be gratefully accepted and appreciated.

Thanks,
Bob Cavanaugh



------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: DLL Build issues

Keith Marshall-3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/06/16 23:21, Robert Cavanaugh wrote:
> gcc -shared -g  -L /c/MinGW/lib -L.
> -L../../../armulif/armulif.b/intelrel
> -L../../../rdi/rditools.b/intelrel -L../../../clx/clx.b/intelrel
> -l user32 --enable-runtime-pseudo-reloc -t  -o millisec.dll
> --library ../../../armulif/armulif.b/intelrel/armulif.lib
> --library ../../../clx/clx.b/intelrel/clx.lib --library
> ../../../rdi/rditools.b/intelrel/rditools.lib millisec.o

I've lost count of the number of times this question has been answered
before, both by myself and countless others.  Search the archives, or
the web in general, for why the order in which libraries and object
files matters, on the GCC command line.

Furthermore, what is "--library" doing in there?  It is an *ld* alias
for "-l", so should obey the same syntactic (and semantic)
conventions, but I'm not aware that GCC supports it as a transparent
ld argument, in the way that it does for "-l"; the GCC documentation
doesn't mention it, AFAICT, so if you must use it (why?), you probably
need to specify it as "-Wl,--library".  (In any case, "--library"
followed by the full path name for the library file would be incorrect
usage).

- --
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJXX9EMAAoJEMCtNsY0flo/c1AQAKLcYCHzJkBano/AhWMcvDm+
ejKEmXATI8k2IchV4BNYSwOkSygC80Bb8GRrjma4eBXS6fViVxUIwRhrjDo7Pt+a
9NYlxu1qsBCGSa1C1Mg/c6UvsFylH1AlKqBwPSiaQk2ObuXEU6x1J8dEPaaBpOkh
8jGC3OuSbyJ7QFyhAlCVuA9Tess/8bZBXOb0bHBSdTr2nUIv8BD8tqVqsddod/22
O7Yn8rqIYSByHXnvbPNUAqmkbG+L4M5YyIaTOgQAF5XbOZ5AEN7RiKUezAFt9JvC
G1gBU8EiSMwPZiseLehvbksOowTV2HTVCIalM6vywcRc9jfk7JcMPhNVKfDIfaEZ
+xNsgrzHGP6ZUTKO800JCLYcJFc3lMzQONqboLU4HJRPyHnm+aIssUUF0JsJm3mX
4uR1mWOD2yPz9ddIzhGt07qu9+8UZncSCWBumf0Yp06caItrx9fY9L+y6TtLcXAs
yhCUSpcsGFDgOAmVPPfEDXje/ppF14gPStCgBsfSAPreh8NvCDeR7QyA+7AQnFtE
Qwf8eTRhZkJXanifsPeaoqPbgxo3utxEfj72FnALzhA5gOd3lEYdeizrkpPmtV7X
MJfRp4uj4/uU1svqu6KM5Mm7nVSgV+utS7iArT4s8ks7OR7/En90Gidki15do3Jg
4lcZb+6mc1pR+rQ7w33W
=Z50F
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Loading...