Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Libraries conflicts

Alessandro
Beginner
1,997 Views
I have a piece of Fortran code to link to a static library, but it seems there are some conflicts with default libraries. I'm working with Windows XP 64bit.



ifort test.f gass_cuda.lib C:\CUDA\lib\cuda.lib /us /Qlowercase -o test

Intel Visual Fortran Intel 64 Compiler Professional for applications runni

ng on Intel 64, Version 11.0 Build 20090318 Package ID: w_cprof_p_11.0.074



Copyright (C) 1985-2009 Intel Corporation. All rights reserved.



Microsoft Incremental Linker Version 8.00.50727.42

Copyright (C) Microsoft Corporation. All rights reserved.



-out:test.exe

-subsystem:console

test.obj

gass_cuda.lib

C:\CUDA\lib\cuda.lib

MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: free already defined in LIBCMT.lib(fr

ee.obj)

MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: strncpy already defined in LIBCMT.lib

(strncpy.obj)

MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: malloc already defined in LIBCMT.lib(

malloc.obj)

LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u

se /NODEFAULTLIB:library

test.exe : fatal error LNK1169: one or more multiply defined symbols found



If I try to use the option /NODEAULTLIB it tells me that it is an unknown option:


ifort test.f gass_cuda.lib C:\CUDA\lib\cuda.lib /NODEFAULTLIB /us /Qlowercase -o test
Intel Visual Fortran Intel 64 Compiler Professional for applications runni
ng on Intel 64, Version 11.0 Build 20090318 Package ID: w_cprof_p_11.0.074

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB'

Microsoft Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

-out:test.exe
-subsystem:console
test.obj
gass_cuda.lib
C:\CUDA\lib\cuda.lib
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: free already defined in LIBCMT.lib(fr
ee.obj)
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: strncpy already defined in LIBCMT.lib
(strncpy.obj)
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: malloc already defined in LIBCMT.lib(
malloc.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
se /NODEFAULTLIB:library
test.exe : fatal error LNK1169: one or more multiply defined symbols found
0 Kudos
8 Replies
eos_pengwern
Beginner
1,997 Views
Quoting - Alessandro
I have a piece of Fortran code to link to a static library, but it seems there are some conflicts with default libraries. I'm working with Windows XP 64bit.



ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /us /Qlowercase -o test

Intel Visual Fortran Intel 64 Compiler Professional for applications runni

ng on Intel 64, Version 11.0 Build 20090318 Package ID: w_cprof_p_11.0.074



Copyright (C) 1985-2009 Intel Corporation. All rights reserved.



Microsoft Incremental Linker Version 8.00.50727.42

Copyright (C) Microsoft Corporation. All rights reserved.



-out:test.exe

-subsystem:console

test.obj

gass_cuda.lib

C:CUDAlibcuda.lib

MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: free already defined in LIBCMT.lib(fr

ee.obj)

MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: strncpy already defined in LIBCMT.lib

(strncpy.obj)

MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: malloc already defined in LIBCMT.lib(

malloc.obj)

LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u

se /NODEFAULTLIB:library

test.exe : fatal error LNK1169: one or more multiply defined symbols found



If I try to use the option /NODEAULTLIB it tells me that it is an unknown option:


ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /NODEFAULTLIB /us /Qlowercase -o test
Intel Visual Fortran Intel 64 Compiler Professional for applications runni
ng on Intel 64, Version 11.0 Build 20090318 Package ID: w_cprof_p_11.0.074

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB'

Microsoft Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

-out:test.exe
-subsystem:console
test.obj
gass_cuda.lib
C:CUDAlibcuda.lib
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: free already defined in LIBCMT.lib(fr
ee.obj)
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: strncpy already defined in LIBCMT.lib
(strncpy.obj)
MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: malloc already defined in LIBCMT.lib(
malloc.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; u
se /NODEFAULTLIB:library
test.exe : fatal error LNK1169: one or more multiply defined symbols found

I believe that /NODEFAULTLIB must be followed by a colon and the name of the libray you want to exclude (i.e. here, "/NODEFAULTLIB:MSVCRTD").

Alternatively, if you are working in Visual Studio, you can specify which library(ies) to exclude under the Project/Properties/Linker/Input menu.

Stephen.
0 Kudos
Alessandro
Beginner
1,997 Views
Quoting - eos pengwern

I believe that /NODEFAULTLIB must be followed by a colon and the name of the libray you want to exclude (i.e. here, "/NODEFAULTLIB:MSVCRTD").

Alternatively, if you are working in Visual Studio, you can specify which library(ies) to exclude under the Project/Properties/Linker/Input menu.

Stephen.

I tried to use /NODEFAULTLIB:MSVCRTD or /NODEFAULTLIB:MSVCRTD.lib, but I keep on getting:

ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB
or
ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB:MSVCRTD.lib

I usually work in Visual Studio, but the people who gave me the library told me to compile with this command, and I do not know how to set Visual Studio to do the exact same thing. I first want to make the example work, and then I think I'll try to set Visual Studio to do it for me.

Thank you.
0 Kudos
Les_Neilson
Valued Contributor II
1,997 Views
Quoting - Alessandro

I tried to use /NODEFAULTLIB:MSVCRTD or /NODEFAULTLIB:MSVCRTD.lib, but I keep on getting:

ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB
or
ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB:MSVCRTD.lib

I usually work in Visual Studio, but the people who gave me the library told me to compile with this command, and I do not know how to set Visual Studio to do the exact same thing. I first want to make the example work, and then I think I'll try to set Visual Studio to do it for me.

Thank you.

It needs to be /NODEFAULTLIB:"msvcrtd.lib" - with quotes.
Les
0 Kudos
Alessandro
Beginner
1,997 Views
Quoting - Les Neilson

It needs to be /NODEFAULTLIB:"msvcrtd.lib" - with quotes.
Les

It still does not understand the command:


ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /NODEFAULTLIB:"msvcrtd.lib" /us /Qlowercase -o test
Intel Visual Fortran Intel 64 Compiler Professional for applications runni
ng on Intel 64, Version 11.0 Build 20090318 Package ID: w_cprof_p_11.0.074

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB:msvcr
td.lib'
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,997 Views
Quoting - Alessandro

It still does not understand the command:


ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /NODEFAULTLIB:"msvcrtd.lib" /us /Qlowercase -o test
Intel Visual Fortran Intel 64 Compiler Professional for applications runni
ng on Intel 64, Version 11.0 Build 20090318 Package ID: w_cprof_p_11.0.074

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
ifort: command line warning #10006: ignoring unknown option '/NODEFAULTLIB:msvcr
td.lib'

This is a linker-only option, so it must come after /link switch. This should work:

ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /us /Qlowercase -o test /link /NODEFAULTLIB:"msvcrtd.lib"
0 Kudos
TimP
Honored Contributor III
1,997 Views
Quoting - Jugoslav Dujic

This is a linker-only option, so it must come after /link switch. This should work:

ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /us /Qlowercase -o test /link /NODEFAULTLIB:"msvcrtd.lib"
I guess the newer /assume options are recommended over the /us /Qlowercase, but that's a nit pick. Either way, depending on those options, if, for example, it is done only as a means to avoid correct use of iso_c_interop, is not recommended.
0 Kudos
Alessandro
Beginner
1,997 Views
Quoting - Jugoslav Dujic

This is a linker-only option, so it must come after /link switch. This should work:

ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /us /Qlowercase -o test /link /NODEFAULTLIB:"msvcrtd.lib"

Thank you, now I'm able to build the application, with some warnings though. But I cannot execute the application, as it tells me:
"The system cannot execute the specified program".

Here it is what I get from ifort:

ifort test.f gass_cuda.lib C:CUDAlibcuda.lib /us /Qlowercase -o test /link /NODEFAULTLIB:"msvcrtd.lib"
Intel Visual Fortran Intel 64 Compiler Professional for applications runni
ng on Intel 64, Version 11.0 Build 20090318 Package ID: w_cprof_p_11.0.074

Copyright (C) 1985-2009 Intel Corporation. All rights reserved.

Microsoft Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

-out:test.exe
-subsystem:console
/NODEFAULTLIB:msvcrtd.lib
test.obj
gass_cuda.lib
C:CUDAlibcuda.lib
gass_cuda.lib(cuda.obj) : warning LNK4217: locally defined symbol free imported
in function cudevicegetname_
gass_cuda.lib(cuda.obj) : warning LNK4217: locally defined symbol strncpy import
ed in function cudevicegetname_
gass_cuda.lib(cuda.obj) : warning LNK4217: locally defined symbol malloc importe
d in function cudevicegetname_

0 Kudos
TimP
Honored Contributor III
1,997 Views
Quoting - Alessandro

Thank you, now I'm able to build the application, with some warnings though. But I cannot execute the application, as it tells me:
"The system cannot execute the specified program".

That message would be expected if you booted into 32-bit Windows and attempted to run the 64-bit build.
0 Kudos
Reply