Results 1 to 6 of 6
hello i am an experienced C programmer but totally new to Linux and Unix. i have a helloworld.c program that I want to compile and link. i managed to compile ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-04-2010 #1
- Join Date
- Sep 2010
Ubuntu GCC Helloworld.c - how to compile, link and set environment for libraries?
i am an experienced C programmer but totally new to Linux and Unix.
i have a helloworld.c program that I want to compile and link.
i managed to compile it and link it but when i run it using:
at commant prompt
it returns with error about package having a Hello and Hello_Debhelper and suggests I use sudo..... ?
any pointers would be appreciated.
thank you in advance
- 09-04-2010 #2
I assume, your compiled binary is called "Hello".
Furthermore I assume, the program is correct and the compilation succeeded.
Then there are two things to check:
1) executeable permission:
ls -la Hello chmod 755 Hello ls -la Hello
Your working directory is *not* automatically part of $PATH.
And it is advised not to add it.
For reasons, look at the recent (or rather ancient) problems and discussions with dll injections microsoft has because of that.
You can either call your programm with
or by copying it into a $PATH directory
or by extending your $PATH with a designated binary dir (for example in your home directory)
Also, binary names are usually all lowercase.
There is no technical reason.
Itīs more convenient.
One does not have to press shift (meh ), but a bit more seriously:
unix filenames are case sensitive.
"Hello" and "hello" can be different programs *and* in the same directory.
So, to avoid confusion, lowercase filenames are gererally used.
Last edited by Irithori; 09-04-2010 at 09:35 AM.You must always face the curtain with a bow.
- 09-04-2010 #3
I don't use Ubuntu but as Irithori already mentioned this unclear error message could result from Ubuntu's weird command suggestion. I'd recommend you to turn off this feature to get a clear "command not found" message which is much easier to understand and also much easier to google.
To turn off this feature (or call it "bug") run:Code:
sudo apt-get remove command-not-found sudo mv /usr/share/command-not-found /usr/share/command-not-found.bak
- 09-04-2010 #4
Manko10: Actually, I didnt mention the command suggestion.
But you are right.
In this case, this thing obfuscated the cause of failure.You must always face the curtain with a bow.
- 09-04-2010 #5
Yes, you didn't mention it explicitly, but implicitly since you assumed that the program's not executed because the working directory is not in $PATH.
But the error message is really weird. Sometimes I ask me what the Ubuntu developers had drunk before they implemented a new feature.
- 09-05-2010 #6
- Join Date
- Sep 2010
let me try another angle
thank you so far. Yes, i know about case sensitivity.
I managed to make it run using ./a.out.
can anyone recommend good on-line resource for learning how to develop GNU C programs (not C++, just plain C) using Linux, telling me how to compile, how to link, standard C libraries, etc, etc. I am not after a C progeamming help but how to use GNU C on Linux to do development etc.
I find the online GNU C manuals not very friendly.
many thanks again