LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gcc-g77 package (https://www.linuxquestions.org/questions/programming-9/gcc-g77-package-4108/)

neko 07-10-2001 03:43 AM

gcc-g77 package
 
Hy, I recently installed the Mandrake 8.0 distribution and I have some problems with the fortran compiler (package gcc-g77). I can compile the programs but not execute them. For example, an executable toto is created but when I try toto, the error message "command toto not found" appears. Does someone have an idea about my problem ?

Thanks a lot.

cinnix 07-10-2001 03:59 AM

make sure you have execute permissions set and if the program is not in your path you have to execute the program like this

./toto

To check your path do a

echo $PATH

neko 07-11-2001 02:00 AM

About PATH...
 
It did work when I tried ./toto but what does it mean ?
I am a Linux beginner and I am not familiar with these questions of PATH. Should I change something in my directories ?

jharris 07-11-2001 03:50 AM

You've used DOS yeah? If you type 'format' in DOS, and format.com is in your current (working) directory then that program will be executed, if its not they command.com looks in all the dirs in your path. On linux if you had the program 'fdformat' in the current directory and you type 'fdformat' then unless your path contains ./ (the current dir) then the 'fdformat' in the current directory won't be executed, your shell will instead look in all the directories in your path. Hence if you have a program in the current directory called 'toto' then just typing 'toto' will fail, you need to type './toto' to reference the toto program in the current directory.

That make sense??

Jamie...

isajera 07-11-2001 03:56 AM

PATH is an enviromental variable... when you call a prog to be executed, the computer will check in each directory listed in the PATH variable for the program. that way, you can call certain programs from any directory.

on linux, like in DOS, "cd .." will take you one directory lower. this is because the ".." represents the directory below the current one. whereas just "." represents the current one. if you call a program in linux, it will only execute if
1: you give the full name, path included, such as /usr/bin/clock
2: the program is in one of the directories listed in PATH

the trick to the ./ is that "." represents the current directory, and linux will fill in the "." with the current directory. let's say you make a program in the /usr/src/packages directory. the full name of the program will be /usr/src/packages/prog1
so, you type ./prog1, and linux translates it to /usr/src/packages/prog1 automagically.

your directories are probably fine. it's the PATH variable that you need probably need to change. do you happen to know what shell you're running?

jharris 07-11-2001 04:00 AM

No matter how you address a file it isn't going to execute unless its executable flag is set! Wether you address it as ./someFile or /someDir/someFile or anyother how.

cheers

Jamie...

isajera 07-11-2001 04:08 AM

sorry about that jamie... i edited the massively erroneous parts of that last post... :rolleyes: <- you know, you really need a smiley for extreme embarrasment.

neko 07-16-2001 03:00 AM

Thanks
 
Thanks a lot to you... I begin to understand better the role of the PATH.

trusouthrnplaya 07-20-2001 06:39 PM

I to am a newbie in programming
 
I am doin' the imfamous hello.cxx, After writing the code in my text editor...I did the compile, gcc hello.xx -o hello.......I got this return:
/tmp/ccTCzq9c.o: In function 'main':
/tmp/ccTCzq9c.o(.text+0xf): undefined reference to 'cout'
/tmp/ccTCzq9c.o(.text+0xf14): undefined reference to 'ostream::operator<<(char const *)'
collect2: ld returned 1 exit status

Does anybody know what the hell this means???

isajera 07-21-2001 01:14 AM

the compiler isn't recognizing the file as c++... it's treating it as a c file. i remember i once solved that prob by just renaming the file to hello.C instead of hello.c.

it still boggles my mind that it worked, and i wouldn't dispense it as advice if it hadn't really happened.

trusouthrnplaya 07-21-2001 04:35 AM

I tried that....and still got the same results, Can u think of any other reason?

Colonel Panic 07-21-2001 10:40 PM

You know, in Japanese, the word 'neko' means cat. Just to let you know...

*****Colonel Panic*****

doodah 07-22-2001 02:10 PM

Quote:

I did the compile, gcc hello.xx -o hello...
this is c++ source right? try to use...

% g++ hello.cpp -Wall -o runMe

i dont know if you have to have the source file as a *.cpp; but i always do and it always works, but definately use the ' g++' cuz that turns on all the opts for c++, and also sends you to the right libs...

oh yeh always use -Wall, somtimes its a bitch.. but youll keep your code clean :)


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