- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My small test program compiles, links and run fine in Linux. But when I try to do the same think in Windows 7 I get a compiler error. What am I doing wrong? I quite new to Windows programming. My final target is to use a generic module interface from a dll.
- Compiler command Linux:
> ifort -c jochen_mod.f90 -fpic -shared -o libjochen.so
> ifort peter.f90 -I. -L. -ljochen
> ./a.out
I am a Integer
I am a Real
I am a Real
- Under Windows 7 the module compiles fine but compiling the main program peter.f90 gives the following error message:
>ifort /c peter.f90 /I. Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.8.254 Build 20180409 Copyright (C) 1985-2018 Intel Corporation. All rights reserved. peter.f90(28): error #6401: The attributes of this name conflict with those made accessible by a USE statement. [GETVALUE] i = getValue(i) --------^ peter.f90(29): error #6401: The attributes of this name conflict with those made accessible by a USE statement. [GETVALUE] r = getValue(r) --------^ compilation aborted for peter.f90 (code 1)
- Main program 'peter':
program peter use jochen_mod, only : getValue implicit none ! Variables integer :: i = 1 real :: r = 1.0 ! Body of peter i = getValue(i) r = getValue(r) end program peter
- Module jochen_mod:
module jochen_mod implicit none private public getValue interface getValue module procedure getValueI module procedure getValueR end interface getValue contains function getValueI(i) result(r) integer, intent(in) :: i real :: r print*, "I am an Integer" r = float(i) r = getValue(r) end function getValueI function getValueR(ri) result(r) real, intent(in) :: ri real :: r print*, "I am a Real" r = ri end function getValueR end module jochen_mod
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Take out the line !DEC$ ATTRIBUTES DLLIMPORT :: getValue - you don't need it and it is what is interfering. The DLLEXPORT in the module turns into a DLLIMPORT automatically on USE.
Here is what I see when I remove the line:
D:\Projects>ifort p.f90 j.lib Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.1.144 Build 20181018 Copyright (C) 1985-2018 Intel Corporation. All rights reserved. Microsoft (R) Incremental Linker Version 14.16.27024.1 Copyright (C) Microsoft Corporation. All rights reserved. -out:p.exe -subsystem:console p.obj j.lib D:\Projects>p.exe I am an Integer I am a Real I am a Real
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I just tried this with the current version 19 and got no errors. You didn't show compiling the module on Windows, but I assume you did it the same way as on Linux.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
thanks for the quick response. Actually I noticed that the I pasted the wrong code producing the error. If I pick the code as posted it compiles and links fine under Win7 with compiler v2016. But when I launch the executable an error message pops up: 'The application was unable to start correctly (0xc....). Click OK to close the application').
The code creating the error message contained lines with !DEC? Attributes. So here is the code producing the error messages.
- The module jochen_mod.f90
I used the following compile options:
> <Path\to>\compilervars.bat intel64
> ifort /dll jochen_mod.f90
module jochen_mod implicit none private public getValue interface getValue module procedure getValueI module procedure getValueR end interface getValue contains function getValueI(i) result(r) !DEC$ ATTRIBUTES DLLEXPORT :: getValueI !dec$ attributes reference:: i integer, intent(in) :: i real :: r print*, "I am an Integer" r = float(i) r = getValue(r) end function getValueI function getValueR(ri) result(r) !DEC$ ATTRIBUTES DLLEXPORT :: getValueR !dec$ attributes reference:: ri real, intent(in) :: ri real :: r print*, "I am a Real" r = ri end function getValueR end module jochen_mod
- Main program peter.f90
command line to just compile the main program:
> ifort /c /I. peter.f90
program peter use jochen_mod, only : getValue !DEC$ ATTRIBUTES DLLIMPORT :: getValue implicit none ! Variables integer :: i = 1 real :: r = 1.0 !real :: getValue ! Body of peter i = getValue(i) r = getValue(r) end program peter
This results in the following error message (as in my 1st post):
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R ) 64, Version 16.0 Build 20180409 Copyright (C) 1985-2018 Intel Corporation. All rights reserved. peter.f90(28): error #6401: The attributes of this name conflict with those made accessible by a USE statement. [GETVALUE] i = getValue(i) --------^ peter.f90(29): error #6401: The attributes of this name conflict with those made accessible by a USE statement. [GETVALUE] r = getValue(r) --------^ compilation aborted for peter.f90 (code 1)
Sorry for the confusion. But as described, none of the approaches, w/ and w/o the !DEC? statements, produces a working result.
Thanks in advance,
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You shouldn't need the "dllimport getvalue" in your file peter.f90. The "dllexport"s in the module file should be "magically" turned into dllimport when the module is USEd.
Take out that line, and then please post the link command you used to build the application.
thanks -
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Take out the line !DEC$ ATTRIBUTES DLLIMPORT :: getValue - you don't need it and it is what is interfering. The DLLEXPORT in the module turns into a DLLIMPORT automatically on USE.
Here is what I see when I remove the line:
D:\Projects>ifort p.f90 j.lib Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.1.144 Build 20181018 Copyright (C) 1985-2018 Intel Corporation. All rights reserved. Microsoft (R) Incremental Linker Version 14.16.27024.1 Copyright (C) Microsoft Corporation. All rights reserved. -out:p.exe -subsystem:console p.obj j.lib D:\Projects>p.exe I am an Integer I am a Real I am a Real
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, and the reason for the OS difference is that the Linux compiler ignores DLLIMPORT/DLLEXPORT.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
this solved the issue. It is working now for me as well. Here are the commands I used to finally run the executable peter.exe including the terminal output:
>c:"\Program Files (x86)\IntelSWTools\compilers_and_libraries\windows\bin\compilervars.bat" ia32 Copyright (C) 1985-2016 Intel Corporation. All rights reserved. Intel(R) Compiler 16.0 Update 8 (package 254) >ifort /dll jochen_mod.f90 Intel(R) Visual Fortran Compiler for applications running on IA-32, Version 16.0 Build 20180409 Copyright (C) 1985-2018 Intel Corporation. All rights reserved. Microsoft (R) Incremental Linker Version 11.00.61030.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:jochen_mod.dll -dll -implib:jochen_mod.lib jochen_mod.obj Creating library jochen_mod.lib and object jochen_mod.exp >ifort peter.f90 jochen_mod.lib Intel(R) Visual Fortran Compiler for applications running on IA-32, Version 16.0 Build 20180409 Copyright (C) 1985-2018 Intel Corporation. All rights reserved. Microsoft (R) Incremental Linker Version 11.00.61030.0 Copyright (C) Microsoft Corporation. All rights reserved. -out:peter.exe -subsystem:console peter.obj jochen_mod.lib >peter.exe I am an Integer I am a Real I am a Real
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page