[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #FVK-122895]: Problem with installing netCDF.
- Subject: [netCDF #FVK-122895]: Problem with installing netCDF.
- Date: Wed, 27 Mar 2013 14:57:52 -0600
> Hi Russ,
>
> I have successfully installed both C and Fortran libraries on my Mac, and on
> this website
> http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-fortran-install.html
> it says
>
> Now you will only need to use something like
>
> -L{DIR1}/lib -lnetcdff
>
>
> to link Fortran software with the installed netCDF Fortran and C libraries.
>
> But it returns
>
> bash-3.2$ -L/usr/local/lib -lnetcdff
> bash: -L/usr/local/lib: No such file or directory
>
> Is this linking step necessary? How do I do this right?
If you have a Fortran program that calls netCDF functions, for example the
sample program simple_xy_wr.f90 here:
http://www.unidata.ucar.edu/netcdf/examples/programs/simple_xy_wr.f90
You should be able to compile and link it like this:
gfortran -I/usr/local/include simple_xy_wr.f90 -o simple_xy_wr
-L/usr/local/lib -lnetcdff
where the -I option tells gfortran where to look for the netcdf.mod file and
the -L
option specifies where the library will be found.
You can also use the "nf-config" program installed in /usr/local/bin for this
purpose
with something that uses the nf-config program to provide the necessary -I and
-L
options, like this:
gfortran simple_xy_wr.f90 -o simple_xy_wr `nf-config --fflags --flibs`
(Note the use of back-quotes "`" rather than quotes "'".)
Either way, you should end up with an executable program "simple_xy_wr". If
you try
invoking it and it still can't find libraries, try putting the library
directory in
the environment variable DYLD_LIBRARY_PATH, as in
export DYLD_LIBRARY_PATH=/usr/local/lib
./simple_xy_wr
There are ways to avoid using the DYLD_LIBRARY_PATH environment variable which
were
displayed at the end of the output from "make install".
--Russ
> On Mar 25, 2013, at 9:50 PM, Unidata netCDF Support
> <address@hidden<mailto:address@hidden>>
> wrote:
>
> Please find the config.log attached.
>
> Thank you very much!
> Yanshi.
>
> OK, here are the relevant lines from config.log:
>
> configure:17833: gfortran -g -O2 -c conftestf.f
> configure:17836: $? = 0
> configure:17839: gfortran -o conftest -g -O2 conftestf.o conftest.o
> ld: warning: ignoring file conftest.o, file was built for unsupported file
> format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 1 0x
> 0 0x 0 0x 0 ) which is not the architecture being linked (i386): conftest.o
> Undefined symbols for architecture i386:
> "_sub_", referenced from:
> _MAIN__ in conftestf.o
> ld: symbol(s) not found for architecture i386
>
> Your gfortran is compiling for i386, a 32-bit architecture, but your gcc is
> apparently compiling for a different architecture, probably 64-bit x86_64.
> You have to use the same architecture if you want to link the software
> together.
> You could do this by either using the right flags for gcc, for example -m32 or
> maybe -arch i386, or use a flag for gfortran, maybe -m64 or -arch x86_64. If
> you installed netcdf-fortran from MacPorts, you may have a gfortran that
> produces
> 64-bit objects with a long name something like
> /opt/local/bin/x86_64-apple-darwin-gfortran-mp-4.7
> but it might be easier to just use the gfortran you have and make gcc produce
> 32-bit objects.
>
> --Russ
>
> On Mar 25, 2013, at 4:57 PM, Unidata netCDF Support
> <address@hidden<mailto:address@hidden>>
> wrote:
>
> Hi Russ,
>
> I don't have problem installing C library with --disable-netcdf-4. And I
> followed instructions at
> http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-fortran-install.html
>
> But still I get error for './configure --prefix=/usr/local' as below:
> checking what FC is set to... gfortran
> checking for special C compiler options needed for large files... no
> checking for _FILE_OFFSET_BITS value needed for large files... no
> configure: displaying some results
> checking for /Applications/Xcode.app/Contents/Developer/usr/bin/nm...
> /Applications/Xcode.app/Contents/Developer/usr/bin/nm
> checking nm flags...
> checking for C-equivalent to Fortran routine "SUB"... sub_
> checking for Fortran "byte"... yes
> checking for Fortran "integer*2"... yes
> checking if Fortran "byte" is C "signed char"... configure: error: Could not
> link conftestf.o and conftest.o
>
> Any idea how to fix this?
> Thank you!
> Yanshi.
>
> There's not enough information to tell just looking at the error
> message above. The error message means a simple Fortran program
> compiled to conftestf.o can't be linked to a simple C program
> compiled into conftest.o, so that the Fortran program can call a
> function defined in the C program.
>
> If you look at config.log towards the end of the file, the Fortran
> and C programs being compiled are shown, when the error occurs.
> The extra error information in config.log may be helpful in
> diagnosing the problem.
>
> What I see in config.log, using compatible versions of gcc and
> gfortran, is ouput like this, indicating successful linking:
>
> configure:19027: checking if Fortran "byte" is C "signed char"
> configure:19037: gcc -c -I/usr/local/include -g -O2 conftest.c
> conftest.c: In function 'sub_':
> conftest.c:4:3: warning: incompatible implicit declaration of built-in
> function 'exit'
> configure:19040: $? = 0
> configure:19043: gfortran -g -O0 -fno-inline -c conftestf.f
> configure:19046: $? = 0
> configure:19049: gfortran -o conftest -g -O0 -fno-inline conftestf.o
> conftest.o
> configure:19052: $? = 0
> configure:19055: ./conftest
> configure:19058: $? = 0
> configure:19060: result: yes
> ...
>
> If you can't figure it out from looking at config.log, send the whole
> config.log
> file to us and we'll see if we can help, but it may take several days ...
>
> --Russ
>
> On Mar 24, 2013, at 4:22 PM, Unidata netCDF Support
> <address@hidden<mailto:address@hidden><mailto:address@hidden>>
> wrote:
>
> Hi Yanshi,
>
> I am trying to install netCDF on my MACOS X 10.8.6.
> I have installed the netCDF-4.2.1.1 without error by
>
> ./configure --disable-netcdf-4
> make
> make check
> make install
>
> However, I could not find the the netcdf.mod and typesizes.mod under
> /usr/local/
>
> The netCDF-4.2.1.1 package only installs the C library. To install the
> Fortran netCDF libaries,
> which have been in a separate distribution since C version 4.1.3, you need to
> download the
> Fortran distribution (either the stable release or the beta test) from here:
>
> http://www.unidata.ucar.edu/downloads/netcdf/netcdf-fortran/
>
> and follow these instructions:
>
> http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-fortran-install.html
>
> Alternatively, you could use the MacPorts system (see
> www.macports.org<http://www.macports.org>) and have the full netCDF-4
> library installed, including netCDF-Fortran, using
>
> sudo port install netcdf-fortran
>
> Note, that may take a while, as it may also download and install compatible
> versions of gcc and
> gfortran ...
>
> --Russ
>
> So, I continued to install netCDF-fortran-4.2, and ./configure returns
> …...
> checking for Fortran "byte"... yes
> checking for Fortran "integer*2"... yes
> checking if Fortran "byte" is C "signed char"... configure: error: Could not
> link conftestf.o and conftest.o
>
> Any idea how to fix this?
> Thank you so much!
> Yanshi.
>
>
> Russ Rew UCAR Unidata Program
> address@hidden<mailto:address@hidden>
> http://www.unidata.ucar.edu
>
>
>
> Ticket Details
> ===================
> Ticket ID: FVK-122895
> Department: Support netCDF
> Priority: Normal
> Status: Closed
>
>
>
>
>
> Russ Rew UCAR Unidata Program
> address@hidden<mailto:address@hidden>
> http://www.unidata.ucar.edu
>
>
>
> Ticket Details
> ===================
> Ticket ID: FVK-122895
> Department: Support netCDF
> Priority: Normal
> Status: Closed
>
>
>
>
>
> Russ Rew UCAR Unidata Program
> address@hidden<mailto:address@hidden>
> http://www.unidata.ucar.edu
>
>
>
> Ticket Details
> ===================
> Ticket ID: FVK-122895
> Department: Support netCDF
> Priority: Normal
> Status: Closed
>
>
>
>
>
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: FVK-122895
Department: Support netCDF
Priority: Normal
Status: Closed