c - "Undefined reference to function" error -
i having trouble compiling few files using headers. here breakdown of code:
file1.c
#include "header.h" int main() { func1(); return 0; } file2.c
#include "header.h" void func1() { ... function implementation ... } header.h
void func1();
error getting is:
in function
'main':
undefined reference'func1'
note: using simple breakdown of how 3 files set up. need work 3 files. setting/including properly? need use set up, unsure how file.c gets reference implementation of func1().
if error undefined reference func1(), and there no other error, think it's because have 2 files called header.h in project , other copy being included instead of copy declaration of func1().
i check include paths project , make sure header.h declaration of func1() being included first.
Comments
Post a Comment