Skip to contentSkip to conversation

linking C++ modules against lttng-ust libraries

DISCUSSION Jérémie Galarneau 2 participants 2 messages May 12, 2014 – May 13, 2014 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 41 lines · Gerlando Falauto

Hi,

I am trying to link a C++ application against lttng-ust, with a simple test case, and I get the following error message upon linking:

main.cpp:109: undefined reference to `_lttng_ust_tracef(char const*, ...)'

where main.cpp reads:
...
13: #include <lttng/tracef.h>
...
109: tracef("my message, this integer %d", 1234);
...

The following seems to fix my problem:

include/lttng/tracef.h +8 -0
index 16a984b..98338d8 100644
@@ -23,6 +23,10 @@
  * SOFTWARE.
  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <lttng/lttng-ust-tracef.h>
 
 extern
@@ -35,4 +39,8 @@ void _lttng_ust_tracef(const char *fmt, ...);
                        _lttng_ust_tracef(fmt, ## __VA_ARGS__);         \
        } while (0)
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LTTNG_UST_TRACEF_H */
Quoted 8 lines

But since I've noticed in the history that this whole C guard has been reworked several times lately, I have no idea whether this is a good idea or not.
Don't know if this has any relevance or anything, but both lttng-ust (along with its dependencies) and my test application are being cross-compiled.

Hints?

Indeed, that file seems to be missing guards. Your best bet would be to submit a patch or open a bug against lttng-ust on bugs.lttng.org.

Thanks,
Jérémie

Quoted 7 lines

Thank you,
Gerlando

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): CA+jJMxtKdvH_Eu7OdQLuR_ekX1uqCM-fDo6ZSk6ZLXCJUHW-Tw@mail.gmail.com

#3 lore raw

----- Original Message -----

Quoted 56 lines

From: "Jérémie Galarneau" <[email protected]>
To: "Gerlando Falauto" <[email protected]>
Cc: [email protected]
Sent: Monday, May 12, 2014 1:43:06 PM
Subject: Re: [lttng-dev] linking C++ modules against lttng-ust libraries

Quoted 48 lines · Gerlando Falauto

Hi,

I am trying to link a C++ application against lttng-ust, with a simple test case, and I get the following error message upon linking:

main.cpp:109: undefined reference to `_lttng_ust_tracef(char const*, ...)'

where main.cpp reads:
...
13: #include <lttng/tracef.h>
...
109: tracef("my message, this integer %d", 1234);
...

The following seems to fix my problem:

include/lttng/tracef.h +8 -0
index 16a984b..98338d8 100644
@@ -23,6 +23,10 @@
  * SOFTWARE.
  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <lttng/lttng-ust-tracef.h>
 
 extern
@@ -35,4 +39,8 @@ void _lttng_ust_tracef(const char *fmt, ...);
                        _lttng_ust_tracef(fmt, ## __VA_ARGS__);         \
        } while (0)
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LTTNG_UST_TRACEF_H */

But since I've noticed in the history that this whole C guard has been reworked several times lately, I have no idea whether this is a good idea or
not.
Don't know if this has any relevance or anything, but both lttng-ust (along with its dependencies) and my test application are being cross-compiled.

Quoted 5 lines
Quoted 2 lines

Hints?

Indeed, that file seems to be missing guards. Your best bet would be to submit a patch or open a bug against lttng-ust on bugs.lttng.org.

Fix pushed into master, please confirm that it fixes your issue:

commit 866f2767f671ffbbff2c0511964f5a9a66358184

Author: Mathieu Desnoyers <[email protected]>
Date:   Tue May 13 09:34:03 2014 -0400

Fix: tracef.h: add missing c++ guard

Thanks,

Mathieu

Quoted 24 lines

Thanks,
Jérémie

Quoted 7 lines

Thank you,
Gerlando

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Signature · 8 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev