Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12435 Discussions

reuse header and c file as library

Altera_Forum
Honored Contributor II
792 Views

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
Altera_Forum
Honored Contributor II
100 Views

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?
Reply