New package linking fails

Masti Ramya Jayaram rmasti at inf.ethz.ch
Mon Sep 1 17:05:20 CEST 2014


Okay, I got around it by simply putting the entire header file inclusion in an extern "C"{} . Now it works!

Thanks again for your help,
Ramya

________________________________________
From: l4-hackers [l4-hackers-bounces at os.inf.tu-dresden.de] on behalf of Masti  Ramya Jayaram [rmasti at inf.ethz.ch]
Sent: 01 September 2014 16:53
To: Martin Küttler; l4-hackers at os.inf.tu-dresden.de
Subject: RE: New package linking fails

hey Martin,

I had not done that and I tried it. In main.cc I declared the function as

extern "C" int self_test(int);

I hope that is what you meant.

However,  I get the following error:

test1.h:115: error: previous declaration of ‘int self_test(int)’ with ‘C++’ linkage
/l4/pkg/test/server/src/main.cc:46: error: conflicts with new declaration with ‘C’ linkage

best,
Ramya



________________________________________
From: l4-hackers [l4-hackers-bounces at os.inf.tu-dresden.de] on behalf of Martin Küttler [martin.kuettler at gmail.com]
Sent: 01 September 2014 16:45
To: l4-hackers at os.inf.tu-dresden.de
Subject: Re: New package linking fails

On 09/01/2014 04:28 PM, Masti Ramya Jayaram wrote:
> Dear all,
>
> I am trying to create a new package under l4/pkg. The linking of the package fails and it has to do with the linker path but I am not sure how to fix it. Here are the details.
>
> Package structure: (relevant parts)
>
> l4/pkg/test/server/src/main.cc
> l4/pkg/test/server/src/folder1/test1.c
> l4/pkg/test/include/test1.h
>
> l4/pkg/test/server/src/Makefile
>
> PKGDIR          ?= ../..
> L4DIR           ?= $(PKGDIR)/../..
>
> TARGET          = $(PKGNAME)
>
> # list requirements of your program here
> REQUIRES_LIBS   = libsigma0 libirq l4util l4re_c-util
>
> # list your .c or .cc files here
> SRC_C           = folder1/test1.c
> SRC_CC          = main.cc
>
> include $(L4DIR)/mk/prog.mk
>
> The compilation of the package fails with an undefined reference in main.cc to a function in test1.c (defined through test1.h). All the object files are generated and I checked under build. What do you think is the issue?

Did you declare the function with extern "C" linkage in main.cc? Without
that the linker won't find C-functions called from C++-files.


Martin

_______________________________________________
l4-hackers mailing list
l4-hackers at os.inf.tu-dresden.de
http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers

_______________________________________________
l4-hackers mailing list
l4-hackers at os.inf.tu-dresden.de
http://os.inf.tu-dresden.de/mailman/listinfo/l4-hackers




More information about the l4-hackers mailing list