ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ?
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 ?
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.
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?
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.
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:perator<<(char const *)'
collect2: ld returned 1 exit status
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.