Author Topic: c++/gcc or whatever in linux  (Read 1284 times)

Siplus

  • Member
  • **
  • Posts: 522
  • Kudos: 43
    • http://www.siplus.org
c++/gcc or whatever in linux
« on: 29 March 2003, 21:17 »
reading "C Programing in Linux" reminded me of a few questions...

in my programming class, (we use Visual Studio 6...), my teachers tells us to use
system("CLS"); to clear the screen. will this command work in linux?

also, i haven't been able to program anything in linux. i don't really know how to use gcc, or what to write a program in

i tried to write a simple c++ program that would just print "Hi" to the screen, but i didn't know how to compile/build it. i wrote it in pico.
i tried ./program, gcc program... but these didn't work. how do you get a c++ program to compile/build/run?


http://www.siplus.org

"Your computer is already fucked up by having Windows
on it, you can only unfuck it up by installing Linux."
-- void main (old school MES member)


Desktop: Athlon 2600/ 768mb DDR266
--Running: Ubuntu 5.10, FC4, Win2k
 (Also, Unbuntu 6-06:5, 5.04; Fedora Core 5, WinXP, but none of these are used much)
12" Powerbook: 1.5 Ghz G4 PowerPC / 1.25 GB DDR333
--Running: Mac OS X 10.4 Tiger

slave

  • Member
  • **
  • Posts: 1,136
  • Kudos: 0
    • http://www.fuckmicrosoft.com
c++/gcc or whatever in linux
« Reply #1 on: 29 March 2003, 22:17 »
We're real cool in my programming class, we have sun workstations and are forced to use gcc.  Haha!


To compile a program in gcc (a simple one) type this:

gcc hello.c

that's it.  It wil generate a file called a.out, type

./a.out

to run it.

To clear the screen in Linux, use the command

clear();

This works for ncurses only, which is kinda like conio.h in dos.

Siplus

  • Member
  • **
  • Posts: 522
  • Kudos: 43
    • http://www.siplus.org
c++/gcc or whatever in linux
« Reply #2 on: 29 March 2003, 22:24 »
aww...i wish i was forced to use a unix os!!   :(

i guess i couldn't compile b/c i didn't put a '.c' after. why do you need to do this? i thought file extentions weren't needed in linux

never heard of ncurses or  conio.h...in fact, these are the only header files i know of:
iostream.h
stdlib.h
string.h
iomanip.h
math.h
fstream.h
so as you can see, i don't really know much c++... in my school we have 3 years of programming, 2 of which are QB. i managed to let them in the c++ year w/o wasting my time with QBasic, although it was a little rough expanding my mind to a programming langauge like c++ (my first and only langauge)

i think clear(); is a lot simpliar then system("CLS");, are there many shorter versions of commands/functions in the linux header files?


http://www.siplus.org

"Your computer is already fucked up by having Windows
on it, you can only unfuck it up by installing Linux."
-- void main (old school MES member)


Desktop: Athlon 2600/ 768mb DDR266
--Running: Ubuntu 5.10, FC4, Win2k
 (Also, Unbuntu 6-06:5, 5.04; Fedora Core 5, WinXP, but none of these are used much)
12" Powerbook: 1.5 Ghz G4 PowerPC / 1.25 GB DDR333
--Running: Mac OS X 10.4 Tiger

slave

  • Member
  • **
  • Posts: 1,136
  • Kudos: 0
    • http://www.fuckmicrosoft.com
c++/gcc or whatever in linux
« Reply #3 on: 29 March 2003, 22:27 »
Well you see, c and c++ files look very similar so you have to specify with an extension.  This is one of the only cases in Linux where the extension matters.

jtpenrod

  • VIP
  • Member
  • ***
  • Posts: 675
  • Kudos: 105
c++/gcc or whatever in linux
« Reply #4 on: 7 April 2003, 10:14 »
quote:
i guess i couldn't compile b/c i didn't put a '.c' after. why do you need to do this? i thought file extentions weren't needed in linux
File extensions are meaningless to Linux itself. However, gcc is an application that Linux runs. And for some applications, file extensions do matter. However, it is possible to override file extensions in gcc, so you can use other extensions if you'd like to do that. The way to compile something with gcc would be to enter:
Code: [Select]
That will compile a simple, one file, program, add debug symbols, turn on all warnings, and make an executable called "hello" (Linux executables seldom have extensions such as *.exe, although you can add them if desired.)
quote:
never heard of ncurses
NCurses is a basic graphical output. It preceeded X, and is used for applications such as Vi and EMACS without X support. NCurses doesn't allow for anything really fancy beyond drawing text on the screen.
_______________________________________
Live Free or Die: Linux

Their fundamental design flaws are completely concealed by their superficial design flaws.
Live Free or Die: Linux
If software can be free, why can't dolphins?