LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-13-2011, 10:32 AM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Rep: Reputation: 34
Compiling A 'C' Program


I issue the following command to put me into the proper directory where the C source code is located:
cd /home/myname/My?Documents

Then issue the following command and the compile works.
gcc –o cprog01 cprog01.c

The second time I try this I’m in root and I try to run the compile command as follows:
gcc –o /home/myname/My?Documents/cprog01 cprog01.c

The compile doesn’t work. States that it can’t find the source file.

Am I defining the path correctly?

Thanks (newbie)
 
Old 04-13-2011, 10:34 AM   #2
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,225

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Why the question mark?

Shouldn't it be My\ Documents?
 
Old 04-13-2011, 10:52 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
You specified tha path for the output file (-o option), but not for the source file.
If you want your compiled program in the source folder, your command should look like this:
Code:
gcc -o /path/to/source/output-file /path/to/source/source-file.c
If you want the output in your current directory then it should like this:
Code:
gcc -o output-file /path/to/source/source-file.c
 
Old 04-13-2011, 10:53 AM   #4
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
The question mark matches 0 or 1 of any character.

And to the OP: Why do you have a directory called My Documents (not to mention the fact that it's a bad idea to have spaces in filenames in Linux)? You should be storing things right in your home directory. Forget about the Windows way.
 
Old 04-13-2011, 10:58 AM   #5
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
I have a directory defined as ‘My Document’ and I couldn’t gain access to it.

So I placed a post about how to gain access to it as the following didn’t work;

cd /home/myname/My Documents

I was told to do the following,

cd /home/myname/My?Documents/ and this worked.
 
Old 04-13-2011, 11:06 AM   #6
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
Thanks all,

I’m going to change the ‘My Document’ directory to ‘MyDocuments’ using the Move command such as ‘mv My?Documents MyDocuments’ no quot marks.

I think this will work and clear up things.

BTW, how can I mark this question complete and closed?

Last edited by swamprat; 04-13-2011 at 11:10 AM.
 
Old 04-13-2011, 11:11 AM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Just for clarification: If you have a name of a file/folder that contains spaces the correct way would be to escape the spaces, in your way the command to change the name of your 'My Documents' folder should be
Code:
mv My\ Documents MyDocuments
The code you are using (My?Documents) would also match folders like MycDocuments, My1Documents and so on.
 
1 members found this post helpful.
Old 04-13-2011, 11:11 AM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I just wonder: Do you keep all your stuff in $HOME/MyDocuments instead of directly in $HOME?
 
Old 04-13-2011, 11:19 AM   #9
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
MTK358,

No not all, mostly used for word processor documents...
 
Old 04-13-2011, 11:30 AM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by swamprat View Post
MTK358,

No not all, mostly used for word processor documents...
Why are you storing source code, then? I hope you're not editing it with a word processor (especially with all the great text editors available, including gedit, kate, vim, etc.).
 
Old 04-13-2011, 11:49 AM   #11
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
I'm running Centos 5.3.

I generally use Kedit, Kwrite or VI to do the editing of the source file.

Being a newbie I would need time to try some of the others you suggest.

Thanks
 
Old 04-13-2011, 11:54 AM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by swamprat View Post
I'm running Centos 5.3.

I generally use Kedit, Kwrite or VI to do the editing of the source file.

Being a newbie I would need time to try some of the others you suggest.

Thanks
GEdit is just bretty basic, but has syntax highlighting.

Kate (my favorite for now) is basically KWrite but with support for multiple documents, split windows, and the abitily to have plugins. Plugins are available for compiling and finding errors, debugging your program, etc.. It can also be made to act like Vi.

Vim is a Vi clone with many added features.

Last edited by MTK358; 04-13-2011 at 11:57 AM.
 
1 members found this post helpful.
Old 04-13-2011, 04:54 PM   #13
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
Thanks, yes VI is a pain in the neck that's why I've been using something Kwrite or Kedit.

I'll look into Gedit.
 
Old 04-13-2011, 07:09 PM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by swamprat View Post
Thanks, yes VI is a pain in the neck that's why I've been using something Kwrite or Kedit.

I'll look into Gedit.
If you use KWrite, then I'd more strongly suggest that you look at Kate. I think it's better for seroius programmers because even though it's just a simple multi-document text editor at its core, it comes with lots of programming-oriented plugins that can pretty much turn it into a fully functional, minimalistic IDE.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling C program Udhayakrishnan Programming 8 02-10-2010 08:21 AM
help compiling a program minm Linux - Newbie 3 10-10-2005 01:14 AM
Compiling a Program? dbzw Linux - Software 4 10-09-2005 01:31 PM
Compiling a program lintho Linux - Software 2 08-24-2004 07:41 AM
Compiling Program Star3132 Linux - General 8 06-29-2004 05:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration