Thread: DevC++ accepts neither "conio.h" nor "conio.c"

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    DevC++ accepts neither "conio.h" nor "conio.c"

    Hi,

    I can't seem to compile the following program:

    Code:
    #include <stdio.h>
    #include <conio.h>
    
    int main()
    {
       textbackground(4);
       clrscr();
       cprintf( "THE BACKGROUND IS RED BUT TEXT IS NORMAL WHITE" );
       getch();
       return 0;
    }
    under DevC++ 5 even if i change conio.h to conio.c.

    When compiling using conio.h error is:
    [Linker error] undefined reference to `textbackground'
    [Linker error] undefined reference to `clrscr'
    [Linker error] undefined reference to `cprintf'

    When using conio.c:

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638

    works fine for me

    Your prog works fine for me. I am use borland. The unresolved externals might be because your .cfg file is not there?

    Do other progs compile for you?

  3. #3
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    >>Your prog works fine for me. I am use borland.
    Borland supports everything in conio.h without problems. Dev-C++ is not made by Borland.

    >>under DevC++ 5 even if i change conio.h to conio.c.
    I had to make changes to conio.c before it would even let me compile, something about a C++ comment was causing a parse error when compiling as a C program. After that conio.c worked fine, but I use Dev-C++ 4, not 5. Can you give the full list of errors you're getting with conio.c? I got like a page or two full of them before I fixed the source, the parse error was the last on the list.
    *Cela*

  4. #4
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    ...

    Because conio.h is not part of the C standard. It is a Borland extension, and works only with Borland compilers (and perhaps some other commercial compilers). Dev-C++ uses GCC, the GNU Compiler Collection, as it's compiler. GCC is originally a UNIX compiler, and aims for portability and standards-compliance.

    If really can't live without them, you can use Borland functions this way:
    Include conio.h to your source, and add C:\Dev-C++\Lib\conio.o to "Linker Options" in Project Options (where C:\Dev-C++ is where you installed Dev-C++).
    Please note that conio support is far from perfect. I only wrote it very quickly

    From the Dev-C++ FAQ:
    http://www.bloodshed.net/dev/faq.html

  5. #5
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    I can't seem to find conio.h in the "lib' folder?
    Last edited by Nutshell; 01-16-2003 at 06:35 PM.

  6. #6
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    Because he said conio.o

  7. #7
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Oops, i actually mean the conio.o file. I couldn't find it.

    I even tried to copy conio.o from my other computer with DevC++ 4. I compiled it successfully, but couldn't execute the exe.

    Any more ideas? Anyone with DevC++ 5 who also has this problem?
    Last edited by Nutshell; 01-16-2003 at 09:28 PM.

  8. #8
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    I tried to insert conio.o like this, but didn't work, is this right?
    Last edited by Nutshell; 01-17-2003 at 06:50 PM.

  9. #9
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    Is there any possible reason for posting a 1176 x 882 pixel graphic for such a small thing? Resize the damn thing...

  10. #10
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Meow sorryz.

    Now i'm forced to switch back to DevC++ 4. But i still want to figure out the problem. I really want to find out if any other DevC++ 5 users have the same problem. Or someone else got any ideas?

    thnx

Popular pages Recent additions subscribe to a feed