WindowsVistaでDev-C++を使用しています。同じディレクトリに3つのファイルがあります。彼らです:
- math_functions.h
- math_functions.c
- test3.c
math_functions.hコード:
int sum (int x, int y);
float average (float x, float y, float z);
math_functions.cコード:
int sum (int x, int y)
{
return (x + y);
}
float average (float x, float y, float z)
{
return (x + y + z) / 3;
}
test3.cコード:
#include <stdio.h>
#include "math_functions.h"
main ()
{
int theSum = sum (8, 12);
float theAverage = average (16.9, 7.86, 3.4);
printf ("the sum is: %i ", theSum);
printf ("and the average is: %f \n", theAverage);
printf ("average casted to an int is: %i \n", (int)theAverage);
}
コンパイルに失敗します。私が受け取るエラーメッセージは次のとおりです。
C:\Users\eSum\AppData\Local\Temp\ccKmdaaa.o(.text+0x3a) In function `main':
[Linker error] undefined reference to `sum'
[Linker error] undefined reference to `average'
C:\Users\eSum\AppData\Local\Temp\ccKmdaaa.o(.text+0x3a) ld returned 1 exit status
私はubuntuで同じ正確なコードコンパイルを使用します(私は仮想マシン、つまりvmplayerを使用してubuntuを実行します)、それはエラーなしでコンパイルされました。
ファイルをコンパイルするには、Dev-C ++で何かを設定する必要がありますか?