compile error on Mac with gfortran

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
das7105

compile error on Mac with gfortran

#1 Unread post by das7105 »

Hello,

I run into a compile error with ROMS 2.2 on my Mac OSX with gfortran. It runs fine for awhile (I am new at this) but then I get an error about the 'ld' command as follows:
____________________
gfortran -ff2c -O1 master.o ocean_control.o -o /Applications/roms-2.2/Tests/oceanS libNLM.a libUTIL.a libMODS.a -L/usr/local/lib -lnetcdf
/usr/bin/ld: Undefined symbols:
___dso_handle
collect2: ld returned 1 exit status
make: *** [/Applications/roms-2.2/Tests/oceanS] Error 1
rm mod_kinds.f90

_____________________
I configured the makefile and .mk file correctly I think and I have the netcdf libs and .inc files. Any ideas? Thanks,

Dave Sutherland

RubenDiez-Lazaro

#2 Unread post by RubenDiez-Lazaro »

The symbol "__dso_handle" is in the standart C libary (you can type the command
"nm /usr/lib/libc.a |grep __dso_handle" and here is the simbol...)

So it seems that the linker ("ld") can't find this symbol...
An problem in the binutils package?
A problem in the standard library?

User avatar
hetland
Posts: 81
Joined: Thu Jul 03, 2003 3:39 pm
Location: TAMU,USA

#3 Unread post by hetland »

I've found that I need to copy libc or libc++ to a place the linker can find. This was a particular problem when the new macs updated to gcc4. See if you can find libc, and if it's not already in /usr/lib, put a copy there.

das7105

tried but failed again!

#4 Unread post by das7105 »

i couldn't find libc but put the libgcc.a and other libs i found in my gcc folder in /usr/local/lib and ran make again and got the following error:
________________________
g95 master.o ocean_control.o -o /Applications/roms-2.2/Tests/oceanS libNLM.a libUTIL.a libMODS.a -L/usr/local/lib -lnetcdf
ld: table of contents for archive: /usr/local/lib/libf95.a is out of date; rerun ranlib(1) (can't load from it)
ld: table of contents for archive: /usr/local/lib/libgcc.a is out of date; rerun ranlib(1) (can't load from it)
ld: table of contents for archive: /usr/local/lib/libgcc_eh.a is out of date; rerun ranlib(1) (can't load from it)
make: *** [/Applications/roms-2.2/Tests/oceanS] Error 1
_________________________

about the lib's being out of date. any more help would be awesome! do i need to reinstall gcc somehow or update those libs (or maybe i got them from the wrong place?)? thanks!

User avatar
hetland
Posts: 81
Joined: Thu Jul 03, 2003 3:39 pm
Location: TAMU,USA

#5 Unread post by hetland »

Did you install XTools? Did you get the latest version from the Developer Connection?

As you probably know, gcc does not come installed by default on a Mac. Also, there have been pretty significant changes recently between gcc4.0 and gcc4.1. Make sure you are running gcc 4.1:

$ gcc --version
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5341)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If not, go to http://www.apple.com/developer/ and get the latest XTools.

Then, come back with whatever other errors you are having, and we'll see if we can get ROMS going..
-r

thaned
Posts: 5
Joined: Thu May 25, 2006 2:36 am
Location: University of Colorado, boulder

compile error on Mac with gfortran

#6 Unread post by thaned »

I got similar error: e.g. f90 -w -O3 master.o ocean_control.o -o oceanS libNLM.a libUTIL.a libMODS.a -L/usr/local/netcdf/lib -lnetcdf -lU77 /usr/bin/ld: archive: libNLM.a has no table of contents, add one with ranlib(1) (can't load from it)

What I did to solve this problem is to execute "ranlib" manually or you can change the following in your scripts:
  1. Add "-s" after ranlib in Compilers/Darwin-xlf.mk (I used Darwin-xlf.mk in my case)
    for example, RANLIB := ranlib -s
  2. Add " $(RANLIB) $@" (start this line with "TAB") in the last line of the following files:
    • Adjoint/Module.mk
    • Nonlinear/Module.mk
    • Modules/Module.mk
    • Utility/Module.mk
    These files doing "ar" of libNLM.a, libUTIL.a, and libMODS.a

das7105

still having problems:)

#7 Unread post by das7105 »

hello,

well, i'm learning a lot by going through all this but i am still having problems. i tried updating my gcc as hetland suggested, and through fink got 4.0.2, but when i gcc --version it still says 4.0.1? i think the root of my problem lies in this- i have a few versions of gcc now on my system and just don't know enough to start messing around with links and copying libraries. any ideas? start from scratch?

when i did put libgcc.a in /usr/local/lib i got errors saying it was out of date but then when i reran ranlib it still didn't work- i get errors that say:

"ranlib: file: libMODS.a(mod_bbl.o) has no symbols"

and so on. any more suggestions would be awesome- thanks,

dave

Post Reply