Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12628 Discussions

reuse header and c file as library

Honored Contributor II

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?

0 Kudos
1 Reply
Honored Contributor II



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!"); 


return 0; 


The build result always says that undefined reference to funcCall()... What I have to do to successfully build this simple system?
0 Kudos