ページ 11

conio.hが見つからない。

Posted: 2011年12月13日(火) 15:10
by yuya
以下のプログラムをコンパイルしたのですが,エラーが出てしまいます。解決方法をご教授願います。
環境はlinux 2.6.39.4です。またプログラムは作成途中で無駄なヘッダがあります。

プログラム(zikken.c)↓↓

コード:

#include<stdio.h>
#include<conio.h>
#include<curses.h>
#include<dos.h>
#include<stdlib.h>

void main(){
	draw();
}

void draw(){
	clrscr();
	textcolor(WHITE);
	gotoxy(12,2);
	cputs("********************************************************");
	gotoxy(12,6);
	cputs("********************************************************");
	gotoxy(12,3);
	cputs("*\n\b*\n\b*\n\b");
	gotoxy(67,3);
	cputs("*\n\b*\n\b*\n\b");
	gotoxy(14,4);
	cputs("SYMANTEC SECURITY SCAN - 2009 (QUICK SYSTEM SCANNER)");
}
gcc -g -o zikken zikken.cでコンパイルしたところ以下のエラーが出ました。
zikken.c:2:18: error: conio.h: No such file or directory
zikken.c:4:16: error: dos.h: No such file or directory
zikken.c:11: warning: conflicting types for ‘draw’
zikken.c:8: note: previous implicit declaration of ‘draw’ was here
zikken.c: In function ‘draw’:
zikken.c:13: error: ‘WHITE’ undeclared (first use in this function)
zikken.c:13: error: (Each undeclared identifier is reported only once
zikken.c:13: error: for each function it appears in.)

conio.hがないと言われたのでググッて調べてみたのですが,解決法がよくわかりません。よろしくおねがいします。

Re: conio.hが見つからない。

Posted: 2011年12月13日(火) 15:19
by beatle
Linuxにはconio.hなんてありません。代わりにtermiosを使うんだったと思います。
僕は「Linuxプログラミング―例題で学ぶUNIXプログラミング環境のすべて」という本を参考にしました。

Re: conio.hが見つからない。

Posted: 2011年12月13日(火) 15:57
by yuya
conio.hの代わりにtermios.hをインクルードしてみたところヘッダエラーは発生しませんでした。しかしその他のエラーが残ったままです。

clrscrやtextcolorなどの関数は使えないと思うのですが、代わりとなる関数にはどのようなものがあるのでしょうか?

Re: conio.hが見つからない。

Posted: 2011年12月13日(火) 16:15
by ISLe
conio.hやdos.hはMS-DOSの機能を呼び出すためのものなのでLinuxには用意されていません。

代わりにcursesライブラリを使うと良いと思います。
LinuxならGNUのncurses。

ncursesを使ってconioをシミュレートするライブラリ(というかconio.h)というのもあります。
探してみてください。

(追記)質問のソースを見たらcursesインクルードしてた。