Forum Discussion
Altera_Forum
Honored Contributor
13 years agoreuse header and c file as library
I am using Nios II SBT Eclipse. I have couple of .c and .h files that i would like to use in a project. But when I trying to call the function in main program, it keep give me error of "undefined reference to: "function name"". I had include the header using# include. All the .c and .h file are placed in a folder in the same directory. Can someone help me with how to set up this folder as include library?
1 Reply
- Altera_Forum
Honored Contributor
Hi,
Can someone help? I still cant solve the problem. Let say I had a header and a source file, ======= myfunc.h ============ #ifndef _MYFUNC_H___ # define _MYFUNC_H___ # include <stdio.h> void funcCall(); # endif ====== myfunc.c ============= #include <stdio.h> # include "myfunc.h" void funcCall(){ printf("Called funcCall"); } They both are in a folder called "lib" Let say I created a new SBT project and add the source below: # include <stdio.h> # include "myfunc.h" int main(){ printf("Hello,Its working!"); funcCall(); return 0; } The build result always says that undefined reference to funcCall()... What I have to do to successfully build this simple system?