LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-10-2005, 04:32 AM   #1
johnnyICON
Member
 
Registered: Aug 2004
Posts: 32

Rep: Reputation: 15
Help with Compiling and what's a good application to program with?


Hi I was wondering whats a good program to program with? I am mainling dealing with C++ files, but I am about to learn C.

I currently have nedit, but I am not too sure how to compile files with Linux either. I have only developed applications in Windows, so I am pretty much lost.

I am trying to compile the following code.

FileName: test.cpp
Code:
#include <iostream>

int main()
{
    cout << "test";
    
    return 0;
}
I typed in the console:
Code:
g++ test.cpp
and I get no output. Help
 
Old 01-10-2005, 05:33 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
hint:
use make in built rules for simple stuff
'make test'
see what you get
 
Old 01-10-2005, 06:38 AM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
another hint:
Code:
using namespace std;
 
Old 01-10-2005, 06:43 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
and - you probably have got output.
look for a file a.out which is the default
output file name for the compiler.
(don't ask me why!)

using make like I mentioned earlier
will fix this behaviour.

say you have

Code:
file_name.c

make file_name
will produce an executable file called file_name
 
Old 01-10-2005, 06:45 AM   #5
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
Quote:
and - you probably have got output.
look for a file a.out which is the default
output file name for the compiler.
(don't ask me why!)
a.out = Assembler OUTput ...
 
Old 01-10-2005, 06:47 AM   #6
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
cheers for the info!

How long does it take before one's brain becomes
full up?
 
Old 01-10-2005, 07:17 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
Quote:
How long does it take before one's brain becomes full up?
It can't, the brain is leaking faster that it fills after a while ...
 
Old 01-10-2005, 08:24 PM   #8
johnnyICON
Member
 
Registered: Aug 2004
Posts: 32

Original Poster
Rep: Reputation: 15
So the way I was doing it (g++ <filename>) isn't the way to compile C++ files?

Also, what applications do you guys use when writing code?
 
Old 01-11-2005, 02:38 AM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
Quote:
So the way I was doing it (g++ <filename> ) isn't the way to compile C++ files?
It is *one* way, but as you do not tell the compiler the name of the output file, it defaults to a.out which is probably not be what you want.
When your code is growing (multiple source files, dependancies, hierarchies, libraries, ...), you'll find that calling the compiler on the command line start to be a burden, and using a Makefile or an IDE greatly simplify the process.
Quote:
Also, what applications do you guys use when writing code?
I use elvis (a vi clone) and from time to time netbeans, but this is a domain where you have a very large choice (and religious wars too).
 
Old 01-11-2005, 04:35 AM   #10
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,314

Rep: Reputation: 175Reputation: 175
Jilliagre is correct.
I think 99% of the time people use make.
(it easier to type 'make test' than 'gcc test.o -o test' :-)

I just use a few standard Makefile templates
which I copy where I need them.
make is worth getting to know though it can be
very (VERY) frustrating to get familiar with it!

editor, I use vi!
 
Old 01-12-2005, 01:08 AM   #11
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
If you got the 'vi' type route, try vim (vi Improved). Free to download :-)
Has syntax highlighting amongst other goodies..
 
Old 01-12-2005, 03:02 AM   #12
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,523

Rep: Reputation: 365Reputation: 365Reputation: 365Reputation: 365
elvis is also open source, free to download, has syntax coloring, plus: has man-page and html modes (ā la linx) and is more compatible with the standard vi.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Good Burning Application DmD Linux - Newbie 8 09-06-2006 05:30 AM
compiling simple c/c++ program but no good freeindy Programming 3 02-12-2005 12:38 PM
Anyone know a good safe free application phonecian Linux - Networking 3 10-03-2004 12:42 AM
good enough compiling program Derek-kun Linux - Newbie 1 09-22-2003 02:30 AM
Application Compiling Daxziz Linux - General 3 02-20-2002 04:21 AM


All times are GMT -5. The time now is 01:11 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration