Author Topic: C Programing in Linux  (Read 1362 times)

tazor

  • Newbie
  • *
  • Posts: 5
  • Kudos: 0
C Programing in Linux
« on: 25 March 2003, 05:43 »
I learnt C using a Borland compiler. I now use Red Hat but I've found that the compiler built in with Linux uses different header files and I need to re-write a lot of my stuff just to get it to compile.

I have heard there is a compiler for Linux that uses the same header files as Borland, and is basically Borland for Linux.

Does anyone know where I can find this and what it is called? Does anyone have any better suggestions?

I would just learn the Linux header files, but I'm still learning the Borland ones, and learning them is not optional (Student demands).
Just because you're not paranoid, don't mean they're not after you...

slave

  • Member
  • **
  • Posts: 1,136
  • Kudos: 0
    • http://www.fuckmicrosoft.com
C Programing in Linux
« Reply #1 on: 25 March 2003, 06:16 »
Do you use conio.h or something?  Linux uses ncurses which is kind of similar.  I'd suggest just getting used to programming with gcc, everyone uses it.  Borland costs money I think anyway.  And what C class makes you use Borland?  Even  mine (which is dumb as dirt so far) uses gcc on solaris machines.

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Programing in Linux
« Reply #2 on: 25 March 2003, 08:59 »
Gee TaZoR where abouts in aussie do you live? I live in 9 Coram Close Narre Warren, Victoria.

You?

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Programing in Linux
« Reply #3 on: 25 March 2003, 21:03 »
(TaZoR is my brother)

We found out if we just ditch the conio it works, and that getch is getchar. A few other things, he runs Red-Hat 8.0, and uses GNOME.

slave

  • Member
  • **
  • Posts: 1,136
  • Kudos: 0
    • http://www.fuckmicrosoft.com
C Programing in Linux
« Reply #4 on: 25 March 2003, 21:09 »
What's the program you're writing?  Can I have a look?

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
C Programing in Linux
« Reply #5 on: 25 March 2003, 10:25 »
Uhm, ask him.

SAJChurchey

  • Member
  • **
  • Posts: 246
  • Kudos: 0
    • http://sajchurchey.htmlplanet.com
C Programing in Linux
« Reply #6 on: 25 March 2003, 11:00 »
Kylix 3 Open Edition is from Borland, and it's a free download w/ a built in C/C++ environment.  It should be backwards compatible w/ their headers hopefully.
SAJChurchey                    

tazor

  • Newbie
  • *
  • Posts: 5
  • Kudos: 0
C Programing in Linux
« Reply #7 on: 26 March 2003, 04:49 »
Sounds good.

The programming book I have and all the things at TAFE are for learning Microsoft/Borland style C. I figured that it would be a bit too much to learn both sets of headers at once.

I do plan on learning gcc, but I'll wait until after the exams.

Just for the record, I was using the conio.h header and I also couldn't find an equivalent of clrscr().

Call me an idiot, but then I am related to Food.  ;)
Just because you're not paranoid, don't mean they're not after you...

slave

  • Member
  • **
  • Posts: 1,136
  • Kudos: 0
    • http://www.fuckmicrosoft.com
C Programing in Linux
« Reply #8 on: 26 March 2003, 07:14 »
quote:
Just for the record, I was using the conio.h header and I also couldn't find an equivalent of clrscr()


Use the command

clear();

Make sure you #include <ncurses.h> and compile your program with the -lncurses option, like this:

gcc hello.c -lncurses


Oh, and make sure to issue a refresh() to redraw the screen afterwards.

Hope that helps.

tazor

  • Newbie
  • *
  • Posts: 5
  • Kudos: 0
C Programing in Linux
« Reply #9 on: 28 March 2003, 04:20 »
Yeah, thanks.

Perhaps I should just send out my source code and then I'll see what changes have to be made.

I did have a problem that one of the programs I made. I converted what I new from borland style to linux style. But when I went to compile it (it didn't show any errors) the compiled program was nowhere to be seen, although it seemed to compile alright.
Just because you're not paranoid, don't mean they're not after you...

tazor

  • Newbie
  • *
  • Posts: 5
  • Kudos: 0
C Programing in Linux
« Reply #10 on: 29 March 2003, 18:06 »
Well, I'm not out of trouble yet.

I've converted a program to gcc, but I'm having touble with the math.h library, I think. This is what is happening when I try to compile:  
quote:
[tazor@tazor dev]$ gcc EngOCalc.c -o EngOCalc -lncurses
EngOCalc.c: In function `main':
EngOCalc.c:14: warning: return type of `main' is not `int'
/tmp/ccWMnoWD.o: In function `main':
/tmp/ccWMnoWD.o(.text+0x2cf): undefined reference to `sqrt'
/tmp/ccWMnoWD.o(.text+0x2de): undefined reference to `sqrt'
/tmp/ccWMnoWD.o(.text+0x2ed): undefined reference to `sqrt'
/tmp/ccWMnoWD.o(.text+0x341): undefined reference to `sqrt'
/tmp/ccWMnoWD.o(.text+0x350): undefined reference to `sqrt'
collect2: ld returned 1 exit status

Just because you're not paranoid, don't mean they're not after you...

flap

  • Member
  • **
  • Posts: 1,268
  • Kudos: 137
C Programing in Linux
« Reply #11 on: 29 March 2003, 18:28 »
You need to link with the math library as well.

gcc EngOCalc.c -o EngOCalc -lncurses -lm
"While envisaging the destruction of imperialism, it is necessary to identify its head, which is none other than the United States of America." - Ernesto Che Guevara

http://counterpunch.org
http://globalresearch.ca