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

Help please - Common Windows Library Searches...

anthonyrichards
New Contributor III
495 Views
I recently posted some code for a console program that compiled and linked using Compaq Visual Fortran and I have been trying to get it to do the same using IVF but failing. Here is the code:

program changeconsoleicon

use dfwin
implicit none

INTERFACE
FUNCTION SetConsoleIcon(hIcon)
USE DFWINTY
INTEGER(DWORD) hIcon
!DEC$ ATTRIBUTES DEFAULT, STDCALL, ALIAS:'SetConsoleIcon' :: SetConsoleIcon
END FUNCTION
END INTERFACE

include 'resource.fd'
integer hmodule, hmainicon
integer lret

hModule=GetModuleHandle(0)
hMainIcon = LoadIcon( hModule, MAKEINTRESOURCE( IDI_ICON1 ))
lret=SetConsoleIcon(hMainIcon)

print *, 'Hello World'
pause

end program changeconsoleicon

It fails with "unresolved external symbol SetConsoleIcon referenced in _MAIN__.

Now, I know that SetConsoleIcon exists as an exported symbol in Kernel32.dll (using DUMPBIN /exports on it), so how can I ensure that a standard WINDOWS library such as Kernel32.dll is searched during the link process and any symbol exported from it is found? Under Properties, Fortran..libraries I have tried 'debug multithreaded' and debug multithreaded Dll' with no success. I have also specified 'use common windows libraries - Yes' but the symbol is still not found during linking. What can I do? I thought that IVF would seemlesly find and search through all the Windows libraries as a matter of course and find any symbol that is properly specified and matches with a valid Windows function/subroutine. Help!

P.S. How do I ensure that DEFTOFD.EXE is run automatically after I make changes to a resource script so that RESOURCE.FD is re-created each time?
0 Kudos
1 Reply
Steven_L_Intel1
Employee
495 Views
You forgot the DECORATE attribute. I find it difficult to believe that this exact code worked in CVF.

For DEFTOFD, you need to create a custom build step for resource.h as described in the Fortran Building Applications volume - search for "deftofd".
0 Kudos
Reply