compilation - Problem compiling self-created header file using Dev-C++? -
i using dev-c++ on windows vista. have 3 files located in same directory. are:
- math_functions.h - math_functions.c - test3.c
math_functions.h code:
int sum (int x, int y); float average (float x, float y, float z);
math_functions.c code:
int sum (int x, int y) { return (x + y); } float average (float x, float y, float z) { return (x + y + z) / 3; }
test3.c code:
#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 average is: %f \n", theaverage); printf ("average casted int is: %i \n", (int)theaverage); }
it fails compile. error message is:
c:\users\esum\appdata\local\temp\cckmdaaa.o(.text+0x3a) in function `main': [linker error] undefined reference `sum' [linker error] undefined reference `average' c:\users\esum\appdata\local\temp\cckmdaaa.o(.text+0x3a) ld returned 1 exit status
i use same exact code compile in ubuntu(i run ubuntu using virtual machine i,e. vmplayer), compiled without errors.
do need set in dev-c++ compile files?
dev-c++ seems not linking math_function.c test3.c when making text3.exe configuration problem in dev-c++ need add math_function.c dev-c++ project
Comments
Post a Comment