-   Linux - General (
-   -   gcc and gfortran (

fereshteh 07-11-2013 04:12 AM

gcc and gfortran
hi dear
how and where can i determine cc and fc compilers in my system (fedora 16)?
i know that my system has those compilers but i think that their paths have not been defined for system because i check env file in etc/bin/ and dont see
in env file.
please tell me how i can set them?

knudfl 07-11-2013 04:42 PM

CC = gcc : CC is always /usr/bin/gcc(-4.6.x), unless you specify different.
FC : The various fortran's are checked. If you have gfortran only,
/usr/bin/gfortran(-4.6.x) will be used. Unless the program to compile
specifically requires pgf90, ifort, "old g77 / f77", etc.

There is no such thing as setting a PATH for the "4000" default executable'.
But : Your PATH / the system PATH is set to /bin:/usr/bin:/usr/local/bin: ? :?
→ → Please try out the command $ env | grep PATH
... to know the default system settings.

Installing the Fedora compilers :
# yum install gcc-c++ gfortran compat-gcc-34-c++ compat-gcc-g77

Setting a different compiler, examples :
gcc34 file.c ; g++34 file.cpp ; g77 file.f ;
export CC=gcc34 CXX=g++34 && ./configure


John VV 07-11-2013 08:47 PM

but be warned
Fedora 16 is past it's end of life
the mirrors will be disappearing

Fedora 16 and 17 are no longer supported
only fedora 18 and 19 are

also of note g77 and gfortran are not the same
the old g77 is deprecated , but around for all the old code that is still usable
and a lot of it is still being used

fereshteh 07-14-2013 09:02 AM

gcc and g fortran
i check my labtop defaul paths. i set up my labtop like pc system. in ps system i see cc=gcc and fc=gfortran but in labtop those mention paths dont exist.
see below:

[fereshteh@localhost ~]$ env
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;0 1:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01 ;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:* .Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31 :*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ac e=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01 ;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35 :*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:* .m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv =01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01; 35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.a nx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka= 01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36 :*.xspf=01;36:*.pdf=00;33:*.ps=00;33:*.ps.gz=00;33:*.txt=00;33:*.patch=00;33:*.diff=00;33:*.log=00;3 3:*.tex=00;33:*.xls=00;33:*.xlsx=00;33:*.ppt=00;33:*.pptx=00;33:*.rtf=00;33:*.doc=00;33:*.docx=00;33 :*.odt=00;33:*.ods=00;33:*.odp=00;33:*.xml=00;33:*.epub=00;33:*.abw=00;33:*.html=00;33:*.wpd=00;33:
LESSOPEN=||/usr/bin/ %s

there are not compilers as gcc and gfortran there are intel compiler that i install separatly.
when i type
[fereshteh@localhost ~]$ gcc --version
gcc (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1)
therefore my system has gcc as default compiler. in my pc system i have cc=gcc anf fc=gfortran by default in env.

John VV 07-14-2013 11:53 AM

fedora like rhel uses "links" in /usr/bin

and uses GFortran , part of the gcc compiler

in my case i have a few versions of the gcc group installed
gcc 3.3 , gcc 4.3 and gcc 4.7
-- i have not yet installed the ancient g77 for some code i use , i recently upgraded my OS and have not gotten to it yet .

for one of the "current " newer versions gcc 4.7
"/usr/bin/gfortran-4.7" is a symbolic link to "/usr/bin/gfortran"

if you try calling g77 or g95 in your build line you will get an error

on fedora ( mind you Fedora 16 is WELL past it's end of life ! And is NOT supported and has not been supported since 2013-02-12 - "Feb. 12 20123")

use yum to install gfortran ( the current will be installed by default

su -
yum search fortran
---- then from that list install it ----
yum install gcc-fortran

then to see the version it is

gfortran -v

please post the build line you are using
and where this code is from ( if possible )
and the errors you are getting

fereshteh 07-15-2013 01:54 AM

$ gcc --version
gcc (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

$ gfortran -v
sing built-in specs.
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl= --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj- --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux
Thread model: posix
gcc version 4.6.2 20111027 (Red Hat 4.6.2-1) (GCC)
[fereshteh@localhost ~]$ gcc --version
gcc (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

when i try to set up zlib 1.2.7 by:
[fereshteh@localhost zlib-1.2.7]$ ./configure --prefix=/home/fereshteh/NETCDF_4.2.1.1
Checking for gcc...
Checking for shared library support...
No shared library support.
Building static library libz.a version 1.2.7 with cc.
Checking for off64_t... No.
Checking for fseeko... No.
Checking for strerror... No.
Checking for unistd.h... No.
Checking for stdarg.h... No.
Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf().
Checking for snprintf() in stdio.h... No.
WARNING: snprintf() not found, falling back to sprintf(). zlib
can build but will be open to possible buffer-overflow security
Checking for return value of sprintf()... No.
WARNING: apparently sprintf() does not return a value. zlib
can build but will be open to possible string-format security
Looking for a four-byte integer type... Not found.

this error arises in labtop system but when i use this in pc that has same fedora version i did not have error like this.
please help me to solve it

John VV 07-15-2013 03:04 AM

might ask "why ?" are you trying to build zlib ?

libz is installed by default
and the devel rpm is in the base fedora repo

yum install zlib-devel
in the very LAST update that fedora 16 got is
-- 32 bit --

building zlib 1.2.7 from source will REPLACE the default version that is installed and that the Fedora 16 NEEDS!!!

from the error warnings
you are missing some basic development source code
you might want to install the "development group"

su -
yum grouplist
---- then from that long list install the development tools and libraries
yum groupinstall "Development Tools"

fereshteh 07-16-2013 02:30 AM

gcc and gfortran
dear i did both of comment that you say
1-yum install zlib-devel
2-yum grouplist...
but again by using ./configure -- prefix=/home/user/netcdf4.2.1 for zlib installation same error has appeared.
i need to install zlib by source (not rpm) becuase i need to install netcdf with zlib in same location by ./configure --with-zlib=/home/user/netcdf4.2.1 -- prefix=/home/user/netcdf4.2.1
now what is your recommendation

John VV 07-16-2013 11:31 AM

seeing as "unistd.h" is in the kernel-devel.rpm
stdarg.h is in the libstdc++ rpm

Did you install the software development libraries and tools listed in the output of "grouplist "

again WHY do you need a different version of libz than the GCC compiler and autotools and the Operating System will use in the build folder of some program


becuase i need to install netcdf with zlib in same location by
then just copy/past the version that IS already installed

if it can not find add it to the linker line
things like that are VERY common with fedora ( even a version that is not supported any longer )
somethings -- like Gcc-- are going to be WAY WAY too new to build a lot of programs without hacking that source code TO build with very new versions of programs
netcdf-4.3.0.tar.gz is the current , not the old 4.2.1

4.2.1 is listed in the OLD section on the page

netcdf-4.2.1.tar.gz dated July of 2012
from the INSTALL text file

Then you build HDF5, specifying the location of the zlib library:

./configure --with-zlib=/home/ed/local --prefix=/home/ed/local
make check install
autotools should automatically pick up zlib
it is installed in /usr/lib or /usr/lib64 the default location
just use "--with-zlib"

there is NO NEED to have a different version( than the operating system is using ) in the build folder

i just ran

in the "/netcdf-4.2.1" folder without any options and "-lz" was auto found and auto used

fereshteh 07-17-2013 01:54 AM

1- i install software development libraries and tools by typing:
[code]yum grouplist
yum groupinstall "Development Tools
as you tooled. I have several questions that become so appreciate to receiving answer.
2- how can i find version of zlip which is already installed ?
3- you mean that i should make a folder as NETCDF for installing netcdf and then what i should copy/ past in that folder?
4-what is linker line and how i can add it ?
5-after coping what i need for zlib (quesion 3), for installing hdf5, i should dressed NETCDF folder (that i make it) in
./configure –with-zlib=/home/usr/NETCDF –prefix=/home/usr/NETCDF
make check install
6- and also for installing netcdf do
CPPFLAGS=-I/home/usr/NETCD/ include
LDFLAGS=L/home/usr/NETCD /lib
./configure –prefix=/home/usr/NETCD4
make check install

Thanks so much

John VV 07-17-2013 02:51 AM

this is a VERY big problem with "university code"
it is often made by students that are NOT software developers and software engineers
Geology writing code for geology programs
Math majors writing code for a function
Physics students writing astronomy software with help from the Geology students
and so on

some is good , some is GREAT, and some is a very messy bit of "spaghetti code"

the "directions" are often a bit wrong
or relate to 20+ year old instructions ( even if the software is new )
-- i build and use a lot of this stuff and " reading the code" is often better than trying to fallow the included instructions

to have the OLD version of netcdf build " netcdf-4.2.1" is a OLD VERSION !
netcdf-4.3 is the current

there is NO NEED to put in the netcdf-4.2.1 folder
no need at all , you do NOT need to do that !
"./configure" will auto find it on the fedora 16 system using "autotools"
that is WHY you run "configure"
to set up a build script FOR YOUR SYSTEM

setting "CPPFLAGS" and "LDFLAGS" in the terminal are not needed for almost ALL normal builds
"configure" should auto take care of this
yes way back in 1999 to 2003 they were NEEDED , but not today in 2013
-- sometimes for some "special" builds they are , but not 99.99999% of the time
-- "university code" documentation -- sometimes it is VERY VERY OLD ,some of it dating from 1996 for netcdf


how can i find version of zlip which is already installed ?
use yum
yum is the package manager

su -
yum info libz
-- or --
yum info zlib

-- there are some name changes in the zip compression library


you mean that i should make a folder as NETCDF for installing netcdf and then what i should copy/ past in that folder?
in "file-roller" the default GUI archive manager on fedora 16
it auto made a folder( called /netcdf-4.2.1 ) when you extracted the gziped tarball "netcdf-4.2.1.tar.gz"
also you DO NOT
100% DO NOT install the software to the build folder
almost all older code , and a lot of new also , will AUTO configure to install to "/usr/local"
fedora DOSE NOT , repeat dose NOT use that Debian default location
it uses " /usr " by default

you need to set that using "--prefix" in the configure line
have a look at the default settings for netcdf-4.2.1
in that folder run this

./configure --help
--- a quote from the output of this

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
also for netcdf-4.2.1 there is NO need to manually set the zlib option
it is AUTO tested for and auto set to "yes" if needed


what is linker line and how i can add it
if needed that would all depend on the error -- if any
and the version of gcc that this program was DESIGNED for
it is very likely that even on the now unsupported and old Fedora 16 that the version of gcc might be WAY too new
-- just tested it on a fairly current gcc 4.7 , and it builds without an error

PS. I just ONLY ran this and it build without any problems


make -j3

the "-j3" told the compiler to use 3 of the 4 CPU's on my computer
-- for faster build times on a i5 or i7 or better CPU

if you want to install it to "/home/usr/NETCDF
well REPLACE "usr" with your REAL name -- the name on your home folder

./configure --prefix=/home/fereshteh/NETCDF
make install

you should see this if there are no errors

| Congratulations! You have successfully installed netCDF!    |
|                                                            |
| You can use script "nc-config" to find out the relevant    |
| compiler options to build your application. Enter          |
|                                                            |
|    nc-config --help                                        |
|                                                            |
| for additional information.                                |
|                                                            |
| CAUTION:                                                    |
|                                                            |
| If you have not already run "make check", then we strongly  |
| recommend you do so. It does not take very long.            |
|                                                            |
| Before using netCDF to store important data, test your      |
| build with "make check".                                    |
|                                                            |
| NetCDF is tested nightly on many platforms at Unidata      |
| but your platform is probably different in some ways.      |
|                                                            |
| If any tests fail, please see the netCDF web site:          |
|                |
|                                                            |
| NetCDF is developed and maintained at the Unidata Program  |
| Center. Unidata provides a broad array of data and software |
| tools for use in geoscience education and research.        |
|                                |

mind you the folder /NETCDF is NOT in the system or user $PATH
you will likely need to add that in the .bash_profile text file ( it is a hidden system file in your home folder

run "make check" before you use it to check if there are problems or not

all the tests should pass

TobiSGD 07-17-2013 06:23 AM

Moved: This thread is more suitable in Linux - General and has been moved accordingly to help your thread/question get the exposure it deserves.

Please use code-tags for output of commands and scripts.

fereshteh 07-18-2013 06:37 AM

thanks for your attention. i decide to use yum install zlib-devel (base on your recommendation)
now how can i find its path to put in ./configure --with-zlib= ???? -prefix=/ / / netcdf for installing HDF5 and also netcdf.
thanke so mush ;)

knudfl 07-18-2013 07:32 AM

# 13 :

zlib will be found automatically by applications that require zlib files.
The same is valid for other libraries installed with yum.

Why are you trying to build hdf5 and netcdf ? ?

This will do for 99% of all applications :
# yum install hdf5-devel netcdf-devel

*** Which application is it that require hdf5 and netcdf ? ?


fereshteh 07-20-2013 01:00 AM

hdf5 and netcdf
actually ROMS model need hdf5 and netcdf libraries to determined in .bashrc file and roms bouild file too.
for this model it is need that i install netcdf with hdf5 and zlib too.
and becouse i am newbie with roms and linux i try to install cmpeletly coincide with usergiude. in netcdf4 INSTALL guide write that i should install it with zlib and hdf5 by
Cd /home/fkomijani/zlib 1.2.7
./configure --prefix=/home/fkomijani/NETCD4.2.1.1
make check install
cd /home/fkomijani/HDF5 1.8.9
./configure --with-zlib=/home/fkomijani/NETCD4.2.1.1 --prefix=//home/fkomijani/NETCD4.2.1.1
make check install
and then
cd /home/fkomijani/netcdf4.2.1.1
CPPFLAGS=-I/home/fkomijani/NETCD4.2.1.1/ include LDFLAGS=L/home/fkomijani/NETCD4.2.1.1 /lib ./configure --prefix=/home/fkomijani/NETCD4.2.1.1
make check install
i try to use it step by step (with out applying yum for installation) and now i install zlib by
[code] yum install zlib-devel
and i need guide for puting zlib path in --withzlib=.... part

All times are GMT -5. The time now is 01:38 PM.