Compile C++ and C file together

Pirmin Duss pirmin.duss at gapfruit.com
Mon Sep 17 13:22:42 CEST 2018


Hello lzSun


On 17.09.2018 11:30, lzSun wrote:
> 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

In a Genode component using the libc, the function Libc::Component::construct() is required. It is there to initialize
some things that are needed by libc programs (eg. the command line parameters).

There are two methods to to provide this function:
 - link the posix library to your component
 - write it yourself

The posix library is a wrapper that provides the Libc::Component::construct() function and calls the main() method of
the program, after setting up some variables that are normally needed by posix programs.


Best regards,
Pirmin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.genode.org/pipermail/users/attachments/20180917/be36e554/attachment.sig>


More information about the users mailing list