Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > Your Distro > Knoppix Help Forum > How to compile and run C with Knoppix Live

Forgot Password?
 Knoppix Help Forum   For all discussions about Knoppix, the Linux "Live CD" that lets you run Linux without needing to install on your hard drive.

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 09-21-2006   #1 (permalink)
Just Joined!
 
Join Date: Sep 2006
Posts: 2
Question How to compile and run C with Knoppix Live

I'm using a knoppix live cd (recommended by uni) to compile and run c programs off a usb drive - practice makes perfect. I get compile error messages when not done properly, warning messages, etc which is good. But when I try to run the program nothing happens. So for example, to compile test.c (which displays a simple printf statement), I would type:

$ gcc -o test test.c

Then to run the program, I type:

$ test

And nothing happens. It just goes to the next line, ready to take in another command. Why?
ropati is offline  


Reply With Quote
Old 09-22-2006   #2 (permalink)
Linux Engineer
 
d38dm8nw81k1ng's Avatar
 
Join Date: Mar 2005
Location: Newcastle
Posts: 793
Send a message via AIM to d38dm8nw81k1ng Send a message via MSN to d38dm8nw81k1ng Send a message via Yahoo to d38dm8nw81k1ng
because you're running the linux command test and not your own test program. linux doesn't look in the directory by default. it first looks in /bin, then /usr/bin (and any other predefined directories) but never the current directory. to tell it to run the file from the current directory, use
Code:
./test
note the ./ and not just /
the . tells linux to look in the current directory. you can also give the pathname relative to the directory. say you are in /home/user and the file is in /home/user/prog/test you will run
Code:
prog/test
to execute the code.
__________________
Here's why Linux is easier than Windows:
Package Managers! Apt-Get and Portage (among others) allow users to install programs MUCH easier than Windows can.
Hardware Drivers. In SuSE, ALL the hardware is detected and installed automatically! How is this harder than Windows' constant disc changing and rebooting?
d38dm8nw81k1ng is offline   Reply With Quote
Old 09-23-2006   #3 (permalink)
Just Joined!
 
Join Date: Sep 2006
Posts: 2
That makes perfect sense. Thanks.
ropati is offline   Reply With Quote
Old 09-25-2006   #4 (permalink)
Just Joined!
 
Join Date: May 2005
Posts: 47
d38dm8nw81k1ng is correct that the path needs to be emphasized with ./.
However, the name test is not a unique name cause it conflicts with bash.
If you used say like test1 or test\ 1 or whatever then it would have worked.
BTW, permissions should be perused also.
waka is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 09:56 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2