Silverfrost Forums

Welcome to our forums

Multiply defined symbols for INTEL build using clearwin64.dl

12 May 2020 10:00 #25381

Hello,

I am building a GUI application using INTEL's 64 bit fortran compiler ifort, INTEL's linker xilink and SALFORD's Dll clearwin64.dll.

If I am using clearwin64.dll and clearwin64.lib of SALFORD ftn95 version 7.10 the building process works fine and creates the executable successfully.

However, if using clearwin64.dll and clearwin64.lib of SALFORD ftn95 version 8.61 (version info of clearwin64.dll in resource monitor: 22.2.3.15, date: 03.02.2020), then INTEL's linker xilink reports the following errors (and does not create the executable expected):

LIBCMT.lib(memcpy.obj) : error LNK2005: memmove already defined in clearwin64.lib(clearwin64.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: exit already defined in clearwin64.lib(clearwin64.dll)
LIBCMT.lib(unlink.obj) : error LNK2005: remove already defined in clearwin64.lib(clearwin64.dll)
LIBCMT.lib(getenv.obj) : error LNK2005: getenv already defined in clearwin64.lib(clearwin64.dll)
LIBCMT.lib(atox.obj) : error LNK2005: atoi already defined in clearwin64.lib(clearwin64.dll)
..\p64_intel\p0918w.exe : fatal error LNK1169: one or more multiply defined symbols found

. I could force xilink to ignore this (via option '/FORCE:MULTIPLE') and thus I could create the executable in question (named p0918w.exe). But I am unsure about possible side effects and hence would like to know more about the errors/warnings. I used commmand

dumpbin /EXPORTS clearwin64.dll

to observe that e.g. symbol exit is exported by clearwin64.dll version 8.61, but **not **by clearwin64.dll version 7.10. I wonder why this is the case.

Please note: clearwin64.lib is the import library supplied by SALFORD and needed for the build process using INTEL's ifort. Moreover, all the module files (and corresponding objects) needed for building have **not **been suppied by SALFORD and have been built by me using ifort and the module sources supplied by SALFORD in directory

FTN95\source64

of the ftn95 installation in question ( i.e. version 7.10 or version 8.61).

LIBCMT.lib is a C Link Library used (mt stands for multithreaded) and I suspect that it is used because the GUI application is built from Fortran and C/C++ sources.

Any comment is welcome.

Regards, Dietmar

12 May 2020 11:44 #25383

These C functions (including exit) are exported by the latest version of clearwin64.dll and have been included in recent versions but presumably not in the early version that you mention.

They were added for those who need these functions when combining 64 bit Silverfrost Fortran with 64 bit Silverfrost C/C++.

I don't know if there is any risk in using '/FORCE:MULTIPLE' and, at the moment I can't think of a work-around other than supplying a variant of clearwin64.dll that does not export these functions.

12 May 2020 1:25 #25385

Paul,

using '/FORCE:MULTIPLE' results in warnings

LIBCMT.lib(memcpy.obj) : warning LNK4006: memmove already defined in clearwin64.lib(clearwin64.dll); second definition ignored
LIBCMT.lib(crt0dat.obj) : warning LNK4006: exit already defined in clearwin64.lib(clearwin64.dll); second definition ignored
LIBCMT.lib(unlink.obj) : warning LNK4006: remove already defined in clearwin64.lib(clearwin64.dll); second definition ignored
LIBCMT.lib(getenv.obj) : warning LNK4006: getenv already defined in clearwin64.lib(clearwin64.dll); second definition ignored
LIBCMT.lib(atox.obj) : warning LNK4006: atoi already defined in clearwin64.lib(clearwin64.dll); second definition ignored
..\p64_intel\p0918w.exe : warning LNK4088: image being generated due to /FORCE option; image may not run

hence the symbols of clearwin64.dll are used and the symbols of ifort's libcmt.dll ignored.

For the moment I can live with option '/FORCE:MULTIPLE' but in the long term I would appreciate, if you could supply a variant of clearwin64.dll/clearwin64.lib that do not export these functions.

By the way: does this phenomenon occur for GNU Fortran, as well?

Thanks, Dietmar

17 Jul 2020 1:33 #26027

Paul,

one of my intel64 applications linked with clearwin64.dll of ftn95 version 8.63 crashes when calling

EXIT$

. Via dumpbin I see that it is still part of clearwin64.dll. The same is true if I replace EXIT$ by EXIT.

Would it be possible to remove both symbols from clearwin64.dll? Regards, Dietmar

17 Jul 2020 3:23 #26031

Dietmar

EXIT$ and EXIT are native FTN95 intrinsics so I don't see how we can remove support for them.

These routines are subroutines that require a CALL and they both take a single integer argument.

Maybe you could replace the call to EXIT$ by STOP.

18 Jul 2020 1:47 #26039

Dietmar,

You could always ask Intel to change their compiler ....

Eddie

19 Jul 2020 3:57 #26044

Dietmar,

Rather than mess with CLEARWIN64.DLL, you could produce your custom version of an import library for the DLL by (1) use DUMPBIN /exports on the DLL to produce a DEF file, (2) edit the DEF file and remove the symbols such as EXIT and EXIT$ that you do not want exported, and (3) use LIB.exe on the DEF file to generate your custom version of CLEARWIN64.a.

You then use your custom version of CLEARWIN64.a when linking your application with the INTEL RTL.

19 Jul 2020 6:42 #26045

That is an interesting idea from mecej4. clearwin64.dll is built using Microsoft C/C++ and I could supply the .def file from which a custom .lib stub library could be produced.

20 Jul 2020 9:42 #26048

Paul, mecej4,

this sounds good. I would appreciate if Paul could send me a def file (based on version 8.63 of ftn95 environent). I still do not understand if this def file will contain both the symols exit and exit$ or not and how I would create the corresponing lib file from this def file using utility lib.

Thanks and regards, Dietmar

20 Jul 2020 10:41 #26049

The procedure is quite simple.

  1. Obtain the DEF file from PaulLaidler and make a working copy, say DSCLRWIN.def. This a plain text file, with the first one or two lines naming the new library that will be built. Subsequent lines contain the names of entry points in CLEARWIN64.DLL, one entry per line. You are going to prune this list to suit your needs.

  2. Edit the DEF file working copy and remove the lines containing entries that you do not want to be visible to the MS linker when you link your Intel Fortran programs, such as EXIT$.

  3. Create the new import library (stub library) using the LIB utility (part of MS Visual C package, also used by Intel Fortran)

    lib /def:dsclrwin.def /machine:amd64

Use the resulting dsclrwin.lib file instead of the one that you used in the past when linking with Intel Fortran (clearwin64.lib?).

20 Jul 2020 11:34 #26050

Here is a link to the current .def file for ClearWin64.dll...

https://www.dropbox.com/s/whc3flqeakpihe4/omni.def?dl=0

20 Jul 2020 1:28 #26051

mecej4, Paul,

thanks for your instructions and the def file. This helped to remove the 'exit doubly defined' warning. Unfortunately it does not prevent the runtime error. Hence I first will try to get rid of all other symbols which are doubly defined before attacking the runtime error occurring when calling exit.

Regards Dietmar

20 Jul 2020 1:43 #26052

Dietmar,

Please keep in mind that non-standard functions such as EXIT$ may have different interfaces depending on whether they are provided by Silverfrost or Intel.

When you use such routines, you have to make sure that you are passing the correct types, order and values of arguments, and take appropriate actions depending on returned error codes.

Please login to reply.