* [PATCH 1/2] trace-cmd: libtracecmd: Fixing linking to C++ code
@ 2022-08-15 3:13 Joel Fernandes (Google)
2022-08-15 3:13 ` [PATCH 2/2] trace-cmd: README: Add note on installing libtracecmd Joel Fernandes (Google)
0 siblings, 1 reply; 4+ messages in thread
From: Joel Fernandes (Google) @ 2022-08-15 3:13 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt, Joel Fernandes (Google)
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 libtracecmd with a main.o built from a C++ main.cc source file.
main.cc:(.text+0x90):
undefined reference to `tracecmd_get_tep(tracecmd_input*)'
undefined reference to `tracecmd_free_record(tep_record*)'
undefined reference to `tracecmd_read_data(tracecmd_input*, int)'
The standard fix for this is to wrap the C project's header in
extern "C".
With this patch, I am able to link libtracecmd into a C++
code base.
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
include/trace-cmd/trace-cmd.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
index 4963f45..b050233 100644
--- a/include/trace-cmd/trace-cmd.h
+++ b/include/trace-cmd/trace-cmd.h
@@ -9,6 +9,10 @@
#include "event-parse.h"
#include "tracefs.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct tracecmd_input;
enum tracecmd_open_flags {
@@ -78,5 +82,8 @@ struct tracecmd_filter *tracecmd_filter_add(struct tracecmd_input *handle,
const char *filter_str, bool neg);
enum tracecmd_filters tracecmd_filter_match(struct tracecmd_filter *filter,
struct tep_record *record);
+#ifdef __cplusplus
+}
+#endif
#endif /* _TRACE_CMD_H */
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] trace-cmd: README: Add note on installing libtracecmd
2022-08-15 3:13 [PATCH 1/2] trace-cmd: libtracecmd: Fixing linking to C++ code Joel Fernandes (Google)
@ 2022-08-15 3:13 ` Joel Fernandes (Google)
2022-09-22 1:43 ` Steven Rostedt
0 siblings, 1 reply; 4+ messages in thread
From: Joel Fernandes (Google) @ 2022-08-15 3:13 UTC (permalink / raw)
To: linux-trace-devel; +Cc: rostedt, Joel Fernandes (Google)
This might be obvious but it still took me some Makefile reading. Add it
to README to make it easier for others.
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
README | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README b/README
index 9d8c127..e823843 100644
--- a/README
+++ b/README
@@ -57,6 +57,9 @@ To install trace-cmd
To install the gui
make install_gui
+To install libtracecmd libraries
+ make install_libs
+
Note: The default install is relative to /usr/local
The default install directory is /usr/local/bin
The default plugin directory is /usr/local/lib/trace-cmd/plugins
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] trace-cmd: README: Add note on installing libtracecmd
2022-08-15 3:13 ` [PATCH 2/2] trace-cmd: README: Add note on installing libtracecmd Joel Fernandes (Google)
@ 2022-09-22 1:43 ` Steven Rostedt
2022-09-22 2:56 ` Joel Fernandes
0 siblings, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2022-09-22 1:43 UTC (permalink / raw)
To: Joel Fernandes (Google); +Cc: linux-trace-devel
On Sun, 14 Aug 2022 23:13:42 -0400
"Joel Fernandes (Google)" <joel@joelfernandes.org> wrote:
> This might be obvious but it still took me some Makefile reading. Add it
> to README to make it easier for others.
>
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Both patches applied. Thanks Joel!
-- Steve
> ---
> README | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/README b/README
> index 9d8c127..e823843 100644
> --- a/README
> +++ b/README
> @@ -57,6 +57,9 @@ To install trace-cmd
> To install the gui
> make install_gui
>
> +To install libtracecmd libraries
> + make install_libs
> +
> Note: The default install is relative to /usr/local
> The default install directory is /usr/local/bin
> The default plugin directory is /usr/local/lib/trace-cmd/plugins
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] trace-cmd: README: Add note on installing libtracecmd
2022-09-22 1:43 ` Steven Rostedt
@ 2022-09-22 2:56 ` Joel Fernandes
0 siblings, 0 replies; 4+ messages in thread
From: Joel Fernandes @ 2022-09-22 2:56 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-trace-devel
On 9/21/2022 9:43 PM, Steven Rostedt wrote:
> On Sun, 14 Aug 2022 23:13:42 -0400
> "Joel Fernandes (Google)" <joel@joelfernandes.org> wrote:
>
>> This might be obvious but it still took me some Makefile reading. Add it
>> to README to make it easier for others.
>>
>> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
>
> Both patches applied. Thanks Joel!
Thanks!
- Joel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-22 2:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 3:13 [PATCH 1/2] trace-cmd: libtracecmd: Fixing linking to C++ code Joel Fernandes (Google)
2022-08-15 3:13 ` [PATCH 2/2] trace-cmd: README: Add note on installing libtracecmd Joel Fernandes (Google)
2022-09-22 1:43 ` Steven Rostedt
2022-09-22 2:56 ` Joel Fernandes
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.