Re: [PATCH] libtraceevent: Fixing linking to C++ code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 14 Aug 2022 23:15:51 -0400
"Joel Fernandes (Google)" <joel@xxxxxxxxxxxxxxxxx> wrote:

> Linking in C++ compilers (including g++) causes references to be created
> with their arguments. Due to this, trace library headers included into
> C++ code base will cause their objects to built with symbols with
> arguments. Apparently this is to support operator overloading in C++.
> 
> This causes linker errors. For example, here's what I get when I try to
> link libtraceevent with a main.o built from a C++ main.cc source file.
> 
>  main.cc:(.text+0x90):
> 	undefined reference to `trace_seq_init(trace_seq*)'
> 	undefined reference to `trace_seq_do_printf(trace_seq*)'
> 	undefined reference to `tep_event_fields(tep_event*)'
> 
> The standard fix for this is to wrap the C project's header in
> extern "C".
> 
> With this patch, I am able to link libtraceevent into a C++
> code base.
> 
> Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
> ---

Applied. Thanks Joel!

-- Steve



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux