ページ 11

CGIコンパイルができない

Posted: 2012年2月02日(木) 13:08
by KI
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <time.h>

void showimg(char []);

int main(void)
{
int no;
char *imgfile[] = {"img1.jpg","img2.jpg","img3.jpg"};

srand((unsigned int)time(NULL));
no = rand() % 3;

printf("Content-type: image/jpeg\n\n");
showimg(imgfile[no]);

return 0;
}

void showimg(char imgfile[])
{
FILE *fp;
char buf[1024];
int i, size;

fp = fopen(imgfile, "rb");
if(fp != NULL) {
_setmode(_fileno(stdout), _O_BINARY);
while((size = fread( buf, sizeof(unsigned char), 1024, fp )) != 0) {
for(i = 0 ; i < size ; i++) {
printf("%c", buf);
}
}
fclose(fp);
fflush(stdout);
_setmode(_fileno(stdout), _O_TEXT);
}
}

画像をランダムに表示させるCGIでコンパイルをしたのですがio.hが見当たらないとエラーが出てします。コンパイルはsentOSで画像などもカレントディレクトリにちゃんと入ってあります。
おそらくio.hが通ってない、存在しないからだと思います、io.hを使わないで実行ファイルを作りたいのですがいろいろやってみてダメでした。
半分あきらめモードですがどなたかお教えください

Re: CGIコンパイルができない

Posted: 2012年2月02日(木) 13:22
by beatle
locateコマンドかfindコマンドでio.hの所在を確認したらいいのではないでしょうか.OSによってio.hがある場所は異なるらしいです.

locateは検索用データベースが構築されている環境で使えます.
$ locate io.h

locateコマンドが無いとか,locate用データベースが無く,検索できない場合はfindで検索します.
$ find /usr/include -name "io.h"

Re: CGIコンパイルができない

Posted: 2012年2月02日(木) 13:25
by さかまき
http://detail.chiebukuro.yahoo.co.jp/qa ... 1380635438
にも似たような質問があります。参考になりますか?
(向こうはCentOS だけど)

Re: CGIコンパイルができない

Posted: 2012年2月02日(木) 13:29
by さかまき
http://okwave.jp/qa/q7280690.html
こっちのほうがいいですか

Re: CGIコンパイルができない

Posted: 2012年2月02日(木) 13:32
by softya(ソフト屋)
マルチポストの可能性が高いですね。
「リリカルなのはさんの質問一覧 - Yahoo!知恵袋」
http://my.chiebukuro.yahoo.co.jp/my/mys ... mpcc694ccc
マルチポストの場合、相互リンクをお願いしていております。 http://dixq.net/board/board.html
すべての掲示板で、同時質問している掲示板を掲載して頂くようにお願いします。