LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to compile rpm package in shell (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-compile-rpm-package-in-shell-618199/)

allan_bg 02-02-2008 01:26 PM

how to compile rpm package in shell
 
I tried to compile fortran g77 in shell but I couldnt. I folowed the procedure and typed

$ g77 source.for

and the answer was bash: $: command not found

I don't understand why shell didn't recognize this symbol, $

Perhaps I made a mistake in installation procedure... Firstly, I made a file named source in home directoy and copied compat-g77 and gcc-fortran rpm packages into. Secondly, i installed these rpm packages with yast, and finally checked them...
As I undersood the last step shoul be to compile g77 in shell...?!

But I have problem with that, and I need a step by step procedure

Nylex 02-02-2008 01:28 PM

What exactly are you trying to do? Are you trying to literally compile g77 from source, or are you trying to compile a Fortran 77 program using g77? If the latter, then you just need to enter "g77 source.for" if your source code is in source.for. When you see a "$", that's just indicating the prompt, so you don't need to type it.

{BBI}Nexus{BBI} 02-02-2008 01:29 PM

I don't think you need to use $. Where did you find the procedure?

allan_bg 02-02-2008 02:36 PM

I tried to type g77 source.for(without $), but the answer was the same
g77: source.for: no such file or directory

Perhaps my source code is not in source.for. Where I made a mistake? What can I do now?

btmiller 02-02-2008 02:38 PM

Do you have a Fortran program in a file called source.for? If so, make sure that you are in the same directory as the source.for file when you try to compile the program. You can use cd to change directories, pwd to tell you what directory you arein, and ls to list the contents of the directory.

Nylex 02-02-2008 03:15 PM

Surely you should know which file your code is in :confused:.

colucix 02-02-2008 04:39 PM

Quote:

$ g77 source.for
and the answer was bash: $: command not found
Quote:

I tried to type g77 source.for(without $), but the answer was the same
g77: source.for: no such file or directory
The answer is definitively not the same. As already pointed out, in the first case the "$" sign is not part of a linux command but a symbol which means "command prompt". On your OpenSuSE box you should have something like
Code:

allan@linux-c4ug:~>
as command prompt. In the second case, the error message tells that g77 could not find the file source.for in the current working directory. Anyway, what is source.for supposed to be? A Fortran code you wrote by yourself or some Fortran example you downloaded from somewhere?

jschiwal 02-02-2008 06:08 PM

Stop typing in the "$" before the command. That doesn't make sense. Sometimes it is posted just to show the prompt.
Make sure that you are in the directory with the fortran program, or include the path with the file.

I still can't get what you are trying to do. You mentioned downloading fortran rpms. Are you trying to install fortran, and what where the (full) names of the rpm packages. If the package ends in .src.rpm, then this is a source rpm, which you would use the rpmbuild command to install, or create a binary rpm file.

If you want to install fortran from a binary rpm package, you would use the "rpm -Uhv <package-file>" command, or better yet use YaST to install it from cd/dvd or the net.

What is with the "source.for" file? That has nothing to do with rpm.

---

Check if the fortran packages are installed:
rpm -qi gcc-fortran
for example.

My SuSE version doesn't have a a g77-compat package. Does "which g77" return anything. How about "which gfortran" or "which gfortran-4.2"

allan_bg 02-03-2008 05:36 AM

Check if the fortran packages are installed:
rpm -qi gcc-fortran
for example.

I checked, it's installed, and Source RMP is gcc-4.0.2_20050901-3.src.rpm


When I typed g77 source.for the answer was

/usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../libfrtbegin.a(frtbegin.o): In function `main':http://linuxquestions.cachefly.net/i...s_lq/icon5.gif
: undefined reference to `MAIN__'

colucix 02-03-2008 06:03 AM

Quote:

Originally Posted by allan_bg (Post 3044408)
I checked, it's installed, and Source RMP is gcc-4.0.2_20050901-3.src.rpm

As I already mentioned in your previous thread, this package is not from the official OpenSuSE repository. It would be a good idea use C compilers built from the official packager/developer.

Anyway, as jschiwal already pointed out, it is not clear what you're trying to accomplish. In order to get some good advice to solve your issue, you should try to elaborate your question a little more.

allan_bg 02-03-2008 12:39 PM

I will try to be clear.
I have to install fortran 77...!

As I understood I should download two rpm packages compat-g77 and gcc-fortran and installed them with yast. Final step would be compile fortran in shell. Perhaps this isn't correct procedure...?

I don't know how to run fortran 77...!

(Source.for is file I created by myself in home directory. I copied rpm packages into source.for.)

AceofSpades19 02-03-2008 12:58 PM

You don't need to compile fortran if you already have it installed. if you have fortran77 installed

colucix 02-03-2008 01:17 PM

Ok, thanks. The Yast software manager let you to select packages you want to install, then:
1. it takes care of all the dependencies (that is it automatically selects extra required packages),
2. downloads all the selected packages,
3. installs them
4. update the system configuration and caches.
So if you have a working internet connection and you properly configured the software repositories, you don't have to worry about manually downloading packages or compiling from source. Just select the software you want to install and after a bunch of minutes you have a working fortran 77 compiler at hand.

At this point it looks like you have already installed the downloaded packages. To be sure, simply issue the command
Code:

rpm -q gcc-fortran compat-g77
this look at the internal database of installed packages and tells you if those RPMs are installed. Indeed, you don't need both the above packages: the gcc-fortran is enough, while the g77 is an older version of the GNU fortran compiler which OpenSuSE kept for compatibility issues.
Quote:

I don't know how to run fortran 77...!

(Source.for is file I created by myself in home directory. I copied rpm packages into source.for.)
The last step is not correct. Once you have the package gfortran and/or the package compat-g77 installed you don't need anything else. Just start to write your own fortran code and compile. For example, if you write a simple program and call it my_program.f you can simply do (assuming gcc-fortran)
Code:

gfortran my_program.f
this will create an executable called a.out by default. To execute it you will launch as any other command. Hope this is clear.

If you want I can give you a hand to correctly set-up the packages repositories in Yast, since it seems the starting point of the whole issue.

allan_bg 02-03-2008 04:22 PM

I typed rpm -q gcc-fortran compat-g77 and I got this

gcc-fortran-4.0.2_20050901-3
compat-g77-3.3.5-2

When I typed gcc-fortran my_program.f I got

bash: gcc-fortran: command not found

Yes, I need a hand to correctly set-up the packages repositories in yast

AceofSpades19 02-03-2008 04:28 PM

the correct command is gfortran not gcc-fortran


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