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++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

Linking error. Problem on "undefined reference to...." in NIOS II IDE 11sp1

Altera_Forum
Honored Contributor II
2,670 Views

hello! 

I am new in quartus 11 and NIOS II IDE 11sp1 for development. The project concludes four source files. the main() function is in  

 

 

my_file_for_blank_project_0.cpp 

 

 

the other three source files all have their corsponding H files included in my_file_for_blank_project_0.cpp. 

 

 

But when I build project, the console shows : 

 

 

 

 

 

 

**** Build of configuration Debug for project my_blank_project_0 **** 

 

 

make -s all includes  

Compiling file_sys.c... 

Compiling hal.c... 

Compiling host.c... 

Compiling my_file_for_blank_project_0.cpp... 

Linking my_blank_project_0.elf... 

obj/my_file_for_blank_project_0.o(.text+0x1c4): In function `main': 

../my_file_for_blank_project_0.cpp:46: undefined reference to `host()' 

collect2: ld returned 1 exit status 

make: *** [my_blank_project_0.elf] Error 1 

 

 

the host() function is in host.c and also declared in host.h. the corresponding four *.o files can also be produced. 

 

 

I do not know how to solve it. 

Can anyone with kindness help me?
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
1,554 Views

I think this happens because your are mixing C and C++ source files. 

For example, If you want to call C++ code from a C source file you need the following definition in .cpp file: 

 

extern "C" int test_cpp_call (int n); 

 

int test_cpp_call (int n) 

.... 

}
0 Kudos
Reply