Compile C++ and C file together

lzSun 1137480042 at qq.com
Mon Sep 17 11:30:17 CEST 2018


Hello,
I want to build a component which needs both C++ and  C files, however, I encountered some problem when I compiling them together. Here's the error:
libc.lib.so: undefined reference to `Libc::Component::construct(Libc::Env&)'
collect2: error: ld returned 1 exit status

For brief, in the C++ file (main.cc ), I would use  a function in the C file , so I want to compile them together. 
In the main.cc file ,I  add "  extern "C"  { # include cfile.h } " . In the cfile.h there exist  the C function declaration ,let's say " fun() " , and I would use fun() in the main.cc.
And in the target.mk, I set SRC_C = xx.c xxx.c (all the C files to be used ) and  add LIBS+= libc  to use C library which the fun() function would use. And I get the error message above, so my question is how can I compile the C++ and the C files together?
Any help will be greatful, thanks in advance! 
 
------------------
Best wishes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genode.org/pipermail/users/attachments/20180917/c20cec1f/attachment.html>


More information about the users mailing list