• 締切済み

Linuxでプログラミング

jjk65536の回答

  • jjk65536
  • ベストアンサー率59% (66/111)
回答No.2

Centos,fedora,ubuntuあたりでCのコンパイルはよくやるんですが、 そういったエラーには遭遇したことがないですね。 興味深いです。 /usr/include/stdio.h は存在していますよね? gcc -I/usr/include hoge.c -o hoge のようにインクルードパスオプションを付けるとエラーは変化しますか? #include "/usr/include/stdio.h" に置き換えたらエラーの内容は変化しますか?

関連するQ&A

  • mallocで引数に変数を入れると警告がでます

    #include<stdio.h> int main(void){ int n,i; int* array; puts("n=?"); scanf("%d",&n); array = (int*)malloc(sizeof(int) * n); for(i=0;i<n;i++) *(array+i) = i; for(i=0;i<n;i++) printf("%d ",*(array+i)); puts(""); return 0; } C言語で、上述のプログラムをコンパイルしたところ、 9: warning: incompatible implicit declaration of built-in function ‘malloc’ と警告がでます。 ./a.outで普通に実行できるのですが、 警告がでるということは、もっと正しいやり方があるということでしょうか?

  • ubuntuにxspimをインストールできません

    Linux始めたばかりの初心者です。ディストリビューションはubuntuを使っています。 授業に使っているXSPIMというソフトを自宅のLinuxにも入れようとしています。XSPIMというのはUNIX環境で動くアセンブリ言語のシミュレータです。インストール手順がここ(http://www.cs.wisc.edu/~larus/spim.html) の下の方に載っているのでそれに従っているのですが・・・ 現在手順6.で躓いています、、 6. Then, if you are using Imakefile file, change to the spim-7.2/xspim directory and type: % xmkmf % make If you do not have a copy of xmkmf, you can use the Makefile in the xspim directory, but beware that it may not work on your system because the paths to the X windows libraries could be different. 上記の通りに、spim-7.3/xspimのディレクトリに移動して、xmkmfを実行しようとすると、次のエラーが出てしまいます。 mv -f Makefile Makefile.bak imake -DUseInstalled -I/usr/lib/X11/config <stdin>:1:19: error: stdio.h: No such file or directory <stdin>:2:19: error: ctype.h: No such file or directory <stdin>: In function ‘main’: <stdin>:18: error: ‘NULL’ undeclared (first use in this function) <stdin>:18: error: (Each undeclared identifier is reported only once <stdin>:18: error: for each function it appears in.) <stdin>:45: warning: incompatible implicit declaration of built-in function ‘sscanf’ <stdin>:49: warning: incompatible implicit declaration of built-in function ‘printf’ Aborted (core dumped) 何か余分にインストールしなければならないものがあるんでしょうか? エラーメッセージを見ても何がいけないのか僕ではわからなかったのでここに投稿させていただきました。 よろしくお願いします。

  • エラーの意味が…

    自分でプログラムを打ち、コンパイルしてみたんですけど 「c:10:警告:incompatible implicit declaration of built-in function 'printf'」とエラーが出てきました。 自分なりに10行目[ printf("%d :",b[i]); ]をいじってみたりは したのですが、上手くいきません。 いったいドコがおかしいのでしょうか? ご指導よろしくお願いします<(_ _)> ↓コレがそのプログラムです。 *************** int main(void){ int score[3][4]; int i,j,sum[3]={0}; score[0][0]=70; score[0][1]=80; score[0][2]=75; score[0][3]=60; score[1][0]=75; score[1][1]=83; score[1][2]=70; score[1][3]=70; score[2][0]=60; score[2][1]=76; score[2][2]=70; score[2][3]=55; char b[]="ABC"; for(i=0; i<3; i++){ printf("%d :",b[i]); for(j=0; j<4; j++){ printf("%3d",score[i][j]); sum[i]+=score[i][j];} printf(" : sum=%d, ave=%5.2f\n",sum[i],(float)sum[i]/4); } return 0; }

  • どうしてもできない!!

    このC言語でのプログラミングがsqrtのところで常にエラーしてしまいます。どこがおかしいのか、おしえてください。 問・三角形の三辺の長さを入力し、ヘロンの公式を利用して面積を求めなさい。 #include <stdio.h> main() { double a,b,c,s,S; printf("Enter 3 numbers"); scanf("%lf %lf %lf",&a,&b,&c); s=(a+b+c)/2; S=sqrt(s*(s-a)*(s-b)*(s-c)); printf("area = %f\n",S); } [EOF] 常に表示されるエラー (1)In fuction `main': (2)type mismatch in implicit declaration for built-in function `sqrt' (3)undefined reference to `sqrt' お願いします。

  • プログラミングの質問です。学校でLinuxを使ってプログラミングを授業

    プログラミングの質問です。学校でLinuxを使ってプログラミングを授業中にかじったのですが、 Windowsでのコンパイルの仕方がわからなくて困っています。 ちなみに下は、私がつくったものです #include <stdio.h> int main(void) { printf("あほじゃないの?"); return(0); }

  • プログラミングについて

    初めまして、初めて質問させていただきます。 いきなりですが最近プログラミングにはまり、独学でCプロをやり始めた物なのですが、以下のようなプログラムをCプロで打ち込んでコンパイルしたところ int main(void) { int i,j,height,length; scanf("%d",&height); if(height % 2 ==0) { putchar("invalid"); { return 0; } } scanf("%d",&length); if(height>=1 && height<=100) for(i=1;i<=height;i++){ for(j=1;j<=length;j++) if(i ==1 || i==height) { putchar('e'); } else if( i !=height/2+1){ putchar('e'); for(j=1;j<length;j++) putchar('.'); } else{ for(j=1;j<=length/2+1;j++) putchar('e'); for(j=length/2+1;j<length;j++) putchar('.'); } putchar('\n'); } return(0); } ――――――――――― Main.c:5:1: warning: implicitly declaring library function 'scanf' with type 'int (const char *restrict, ...)' [-Wimplicit-function-declaration] scanf("%d",&height); ^ Main.c:5:1: note: include the header <stdio.h> or explicitly provide a declaration for 'scanf' Main.c:8:5: warning: implicit declaration of function 'putchar' is invalid in C99 [-Wimplicit-function-declaration] putchar("invalid"); ^ 2 warnings generated. ――――――――― と上のようなエラー内容が出てしまい、丸一日自分で模索しても何故こんなエラーが出て来てしまうのか分からない為、教えて頂けるとありがたいです。

  • C言語プログラミングについて

    #include <stdio.h> int main(void) { printf("hello,world\n"); } □■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■ #include <stdio.h> int main(void) { printf("hello"); printf(",world"); printf("\n"); } 上の2つのプログラムをコンパイルするとどのような違いが生じるんですか??printfってどんな働きをするんですか?

  • Linuxにgccをインストールしたのですが・・・

    Linux(Debian Sarge)にgccをインストールしたのですが、 #include <stdio.h> int main(void) { printf("Hello World"); return 0; } のような1.cといったファイル名のプログラムを作成し、 cc -o 1 1.c と実行したのですが、 1.c:1:19: stdio.h : そのようなファイルやディレクトリ はありません と表示されコンパイルできません。恐らくライブラリが読み込まれていないまたはライブラリがインストールされていないために起こったと考えられるのですが、 どういった設定をすればいいのでしょうか?これまでは標準でインストールしただけで、全ての設定が完了していたのですが、今回は何故か設定ができていませんでしたので、手のつけられない状況です。 ご回答よろしくお願いします。

  • Linuxプログラミングについて

     今回初めてLinuxでプログラム作成をしているのですが、どうもわからない 現象がでてしまい困っています。なにが悪いのかわかりません。  めちゃ困っています。助けて下さい。宜しくお願い致します。 (サンプルプログラム) #include <stdio.h> main(){ float float_data ; float float_data1 ; float float_data2 ; float RuisekiSum ; printf("\n") ; float_data = 0.1 ; float_data1 = 1.1 ; float_data2 = 0.01 ; RuisekiSum = float_data1 * float_data2 ; printf(" data → float1( %f. %e )\n" , float_data1,float_data1 ) ; printf(" float2( %f, %e )\n" , float_data2,float_data2 ) ; printf(" RuisekiSum = float_data1 * float_data2\n" ) ; printf(" = 0x%x( %f , %e )\n" , RuisekiSum, RuisekiSum, RuisekiSum ) ; printf("\n") ; exit(0) ; } (実行結果) data → float1( 1.100000. 1.100000e+00 ) float2( 0.010000, 1.000000e-02 ) RuisekiSum = float_data1 * float_data2 = 0x0( 0.000000 , 5.265658e-315 ) 何が悪いのでしょうか? 恥ずかしいながら宜しくお願い致します。

  • C言語のpow関数の不具合

    linux(ubuntu)の上でgccを使っています。 powの関数がおかしいです。 pow(10,-1)を計算させると正しく1e-1が出力されます。 #include <math.h> #include <stdio.h> int main(void){ double x = -1; printf("%f",pow(10,x)); return 0; } 上記のプログラムを走らせると、 In function "main"; *****.c:(.text+0x2d):undefined reference to 'pow' collect2: ldはステータス1で終了しました。 というエラーメッセージがでます。 なぜかpow関数の中に変数を入れるとプログラムが動きません。