LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to download and install gfortran on linux? (https://www.linuxquestions.org/questions/linux-software-2/how-to-download-and-install-gfortran-on-linux-4175431412/)

carolasu 10-09-2012 08:59 PM

How to download and install gfortran on linux?
 
I want to download and install gfortran on my linux, so I typed command:

sudo apt-get install libgfortran3

But it doesn't seem that I downloaded it successfully. What else do I need to do? Thank you!

nugat 10-09-2012 09:11 PM

Quote:

Originally Posted by carolasu (Post 4801731)
I want to download and install gfortran on my linux, so I typed command:

sudo apt-get install libgfortran3

But it doesn't seem that I downloaded it successfully. What else do I need to do? Thank you!

Why do you say that? Is there any error output in the terminal?

You can confirm that the package is installed with:

Code:

dpkg -l libgfortran3

carolasu 10-09-2012 09:23 PM

Because when I was trying to use gfortran to compile my program, it said couldn't find it. And I couldn't find gfortran folder in my laptop.

(1)after I typed 'sudo apt-get install libgfortran3', it says following in terminal:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libgfortran3
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 357 kB of archives.
After this operation, 1,222 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main libgfortran3 amd64 4.6.3-1ubuntu5 [357 kB]
Fetched 357 kB in 1s (207 kB/s)
Selecting previously unselected package libgfortran3.
(Reading database ... 168458 files and directories currently installed.)
Unpacking libgfortran3 (from .../libgfortran3_4.6.3-1ubuntu5_amd64.deb) ...
Setting up libgfortran3 (4.6.3-1ubuntu5) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

(2)I just typed 'dpkg -l libgfortran3', it says:

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii libgfortran3 4.6.3-1ubuntu5 Runtime library for GNU Fortran applications


What does that mean? Thank you!

btw, how to use code frame like what you did?

nugat 10-09-2012 09:52 PM

Your apt-get output looks all right - you successfully installed the GNU Fortran libraries (not the binary, but more on that later).

Your dpkg output also confirms that your apt-get install of libgfortran3 was successful.

I think what you need is the GNU Fortran compiler package itself, try this:

Code:

sudo apt-get install gfortran
and you can create code syntax in your post either by literally typing the following around your code:

Code:

[ code ] your code here [/ code ]
just remove the spaces around "code" in the square brackets.

or just highlight the text w/your mouse and then press the # icon in the tool bar above the text box, which will enclose it in the same code brackets.

carolasu 10-09-2012 10:04 PM

Thank you very much! It works! And thanks for telling me how to create code syntax.

What's the difference between GNU Fortran libraries and GNU Fortran compiler package?

Can I use GNU Fortran compiler package without GNU Fortran libraries?

nugat 10-10-2012 06:55 PM

Quote:

Originally Posted by carolasu (Post 4801764)
What's the difference between GNU Fortran libraries and GNU Fortran compiler package?

Linux libraries are files that contain functions, routines and definitions in them. Binaries are compiled against these library modules, and can thus reference the functions and routines in the libraries. So when you run binary "binA" on a system that has been compiled with "libA", then the binary will expect to find "libA" on the system in the lib area.

But it is the binary program itself that you usually want, you just don't know you need the libraries sometimes. Usually, your package manager (yum, apt-get, etc.) will install and required library packages when installing a given binary. If you had done "apt-get install gfortran" first, it probably would have installed libgfortran3 along with it.

Quote:

Can I use GNU Fortran compiler package without GNU Fortran libraries?
I doubt it, but not sure. I don't really know what those libs do. If the gfortran binary was compiled with static Fortran libs, then you probably would not need them, but chances are, you'll be compiling something w/your fortran compiler and *that* program will be looking for Fortran libs...so go ahead and keep it. For that matter, you'll probably also want any "include" (or "header" or "devel") packages for GNU Fortran, too.

carolasu 10-10-2012 07:37 PM

Thank you! that's very clear.

So the "include" packages are included in the fortran libraries? I don't need to download "include" packages, do I?
I am using fortran 90. but sometimes i need to compile fortran 77.

Today I was trying to download and install lapack from terminal, so i typed
Code:

sudo apt-get install lapack
It didn't work. Is that because lapack is not in Linux libraries? I downloaded lapack from website directly and installed it. But if I want to do that from terminal, what should I do?

knudfl 10-11-2012 03:17 AM

# 7
Quote:

sudo apt-get install lapack
apt-file search lapack

sudo apt-get install liblapack-dev

I.e. the correct package name must be used for apt to install it.
About "includes" : Those files are in "lib<name>-dev" packages.

.

carolasu 10-11-2012 11:45 AM

I see, Thank you very much!

sundialsvcs 10-11-2012 02:03 PM

"For the record," here are a few reactions to what I've seen in this thread:

(1) "Can't find 'command'" is caused by a command not being found on the $PATH that is in effect at the time. Linux boxes often set-aside a /usr/local/... directory for the installation of "peculiar to this machine" software, and /usr/local/bin is sometimes not in that path. But, when you're installing from a package, that shouldn't be an issue.

(2) Every program that's written in a high-level language (like FORTRAN) expects to be able to call upon a fairly large set of "predefined" subroutines. These are stored in the language-specific library, and there might be more than one, e.g. to support high-precision calculations. Any program written in that language must have access to these libraries in order to run. Sometimes they also require various text files. But the language compiler is only needed if you are writing software in that language.

(3) After any library is installed or updated, the (privileged) ldconfig command must be run. Usually this takes place automatically as part of package-installation. If your program "can't find the library," but you know it's there, this is probably why.

carolasu 10-11-2012 04:25 PM

I see, Thank you! so,

(1)if I reset the path, I should be able to find it.

(2)that make sense.

(3)ldconfig: list of directions of configurations? It should help me to find the libraries, how come my program can't find the library after this command run?

nugat 10-11-2012 06:21 PM

Quote:

Originally Posted by carolasu (Post 4802566)
Thank you! that's very clear.

So the "include" packages are included in the fortran libraries?

Well, occasionally they are, but more often, they are in "-dev" packages (on Debian-based distros), as somebody pointed out. In this case, libgfortran3 only contains:

Code:

/usr/lib/libgfortran.so.3
/usr/lib/libgfortran.so.3.0.0
/usr/share/doc/libgfortran3

(the .so files are the libraries, and one is probably a link to the other) and gfortran only contains:

Code:

/usr/bin/gfortran
/usr/bin/i486-linux-gnu-gfortran
/usr/share/doc/gfortran

(again, one of those binaries is likely a link to the other). So, between those two packages, you should be able to run the compiler (/usr/bin/gfortran).

Quote:

I don't need to download "include" packages, do I?
I don't see any GNU Fortran specific dev packages (you can look here) so you are probably good. If you do find that you need compiler header/include files, you can grab libc6-dev to see if that satisfies things.

carolasu 10-12-2012 12:18 PM

I see, thanks a lot!


All times are GMT -5. The time now is 07:08 PM.