- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am having a problem with link.exe searching the environment variable LIB for library files. I am using cygwin as a bash shell script. Here is the test script:
$ cat test.sh
#!/usr/bin/bash
#
echo "Hello test program"
cat hello.f
echo ""
echo "Tools used"
echo "Fortran compiler:`which ifx`"
echo "Linker..........:`which link`"
echo ""
echo "Compiling test program"
command="ifx hello.f"
echo $command
$command
ls -al hello*
echo ""
echo "But it is defined in LIB"
echo "LIB=$LIB"
ls -al $LIB/libcmt.lib
and the output
$ ./test.sh
Hello test program
print *,'Hello World'
end
Tools used
Fortran compiler:/cygdrive/c/Program Files (x86)/Intel/oneAPI/compiler/2024.2/bin/ifx
Linker..........:/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/link
Compiling test program
ifx hello.f
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.2.1 Build 20240711
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.41.34120.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:hello.exe
-subsystem:console
hello.obj
LINK : fatal error LNK1104: cannot open file 'libcmt.lib'
-rw-r--r-- 1 rcy rcy 28 Sep 2 19:49 hello.f
-rw-r--r-- 1 rcy rcy 1253 Sep 3 11:03 hello.obj
But it is defined in LIB
LIB=/cygdrive/c/Windows/Libs
-rw-r--r-- 1 rcy rcy 3228516 Sep 2 11:55 /cygdrive/c/Windows/Libs/libcmt.lib
According to the link documentation at
https://learn.microsoft.com/en-us/cpp/build/reference/linking?view=msvc-170
the environment variable LIB can contain the path to .lib files.
I first tried using the path to libcmt.lib in the distribution
/cygdrive/c/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.41.34120/lib/x64
but the spaces were a problem (tried several options to quote the spaces but nothing worked).
I have tried several options, including putting /VERBOSE and /DODEFAULTLIB in the link line but still cannot get it to work.
Any suggestionsw?
Thanks, Ron
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Windows system linker is not a cygwin program - it does not use the cygwin DLL. It will not understand what the /cygdrive/c prefix means on a path in LIB. For the Windows system linker to be able to search the paths listed in LIB, then when link.exe is invoked, LIB needs to contain paths that use the typical Windows conventions. cygwin provides the cygpath utility to map lists of paths between unix and Windows conventions.
(link.exe is invoked by the ifort executable, so LIB needs to be set up using windows conventions before ifort is invoked.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. That explains a lot.
One last problem I am having is with path names in LIB that contain spaces. For example
$ echo $LIB
/c/{Program Files (x86)/Intel}/oneAPI/compiler/2024.2/lib:/c/{Program Files/Microsoft Visual Studio}/2022/Community/VC/Tools/MSVC/14.41.34120/lib/x64:/c/{Program Files (x86)/Windows Kits}/10/Lib/10.0.22621.0/um/x64:/c/{Program Files (x86)/Windows Kits}/10/Lib/10.0.22621.0/ucrt/x64
I have tried enclosing the directories with spaces in {} and in "" "" but nothing works.
How does link expect to see file names with spaces?
Thanks, Ron

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page