×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

LD.EXE (GNU Linker) Syntax Problem

LD.EXE (GNU Linker) Syntax Problem

LD.EXE (GNU Linker) Syntax Problem

(OP)
Hello:

Listed below is the output from a very simple BATCH file to compile, library
and link 2 Fortran files (these files do nothing but exist). I have never used
GNU "programs" before (just IBM, DEC and Microsoft). I now have the
"opportunity" to use these programs (yes I need to use G77). Is it possible for
someone to explain why LD.EXE can not link. Thanks.

ie: I have tried multiple file extensions (.f, .for, .obj, .o, .a, .out, .exe) and
nothing seems to matter.

Screen Output:

TEST.BAT INFO: (Windows 7 Pro SP1)

Microsoft Windows [Version 6.1.7601]
CD...............:C:\ABC
PROGRAM_NAME.....:ABC
SUBROUTINE.......:DEF
COMP_IMAGE.......:C:\ABC\BIN\G77.EXE
LIB_IMAGE........:C:\ABC\BIN\AR.EXE
LINK_IMAGE.......:C:\ABC\BIN\LD.EXE
FORTRAN_EXT......:FOR
OBJECT_EXT.......:OBJ
LIBRARY_EXT......:LIB
LIBRARY_PATH.....:C:\ABC
LINK_EXT.........:EXE
*** GNU VERSION INFO ***
g77 version 2.95 19990728 (release) (from FSF-g77 version 0.5.25 19990728
(release))
Driving: C:\ABC\BIN\G77.EXE -v -c -xf77-version /dev/null -xnone
G77.EXE: /dev/null: No such file or directory
Using builtin specs.
gcc version 2.95 19990728 (release)
GNU ar 2.9.4
Copyright 1997, 1998 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
GNU ld version 2.9.4 (with BFD 2.9.4)
Supported emulations:
i386pe
. Press ENTER to Continue:
*** DIR OF FORTRAN FILES ***
ABC.FOR
DEF.FOR
. Press ENTER to COMPILE:
*** COMPILE ***

C:\ABC>C:\ABC\BIN\G77.EXE -c -o ABC.OBJ ABC.FOR

C:\ABC>C:\ABC\BIN\G77.EXE -c -o DEF.OBJ DEF.FOR
DIR OF OBJECT FILES
ABC.OBJ
DEF.OBJ
. Press ENTER to LIBRARY:
*** LIBRARY ***

C:\ABC>C:\ABC\BIN\AR.EXE r ABC.LIB DEF.OBJ
DIR OF LIBRARY FILES
ABC.LIB
LIBRARY LISTING

C:\ABC>C:\ABC\BIN\AR.EXE t ABC.LIB
DEF.OBJ
. Press ENTER to LINK:
*** LINK ***

C:\ABC>C:\ABC\BIN\LD.EXE -o ABC.EXE -l ABC.LIB ABC.OBJ
C:\ABC\BIN\LD.EXE: cannot open -lABC.LIB: No such file or directory

C:\ABC>C:\ABC\BIN\LD.EXE -o ABC.EXE -L C:\ABC -l ABC.LIB ABC.OBJ
C:\ABC\BIN\LD.EXE: cannot open -lABC.LIB: No such file or directory
. Press ENTER to EXIT:

C:\ABC>

RE: LD.EXE (GNU Linker) Syntax Problem

This is just a guess - I'm not sure of the behaviour of linux tools on windows. When a -l parameter is given to ld, it expects the item named to have a lib prefix and a .a or .so suffix, so

CODE

ld -o abc.exe -labc.lib 

will expect a libabc.lib.a to exist. ar, however does not add a lib prefix or the .a suffix so you need to do that.

CODE

ar r libabc.a def.obj
ld -o abc.exe -labc 

RE: LD.EXE (GNU Linker) Syntax Problem

I've just installed mingw gfortran. It looks like ld needs the fortran libraries so it might be better if you use g77 to do the linking. Also, ld, needs -L for the path of the library

CODE

g77.exe -c -g def.for -o def.obj
ar r libabc.a def.obj
g77.exe abc.for -L. -labc -o abc.exe 

RE: LD.EXE (GNU Linker) Syntax Problem

Personally I would have installed the development packages for cygwin from http://www.cygwin.org/
It is all the unix commands ported over to windows and for the FORTRAN I would use gfortran which works great. When you install the development packages it installs all the dependencies so it just works.

Bill
Lead Application Developer
New York State, USA

RE: LD.EXE (GNU Linker) Syntax Problem

You can compile fortran 77 using gfortran - you don't have to use g77. Just give the files either a .f or .for extension.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close