[lttng-dev] linking C++ modules against lttng-ust libraries
Jérémie Galarneau
jeremie.galarneau at efficios.com
Mon May 12 13:43:06 EDT 2014
On Mon, May 12, 2014 at 10:53 AM, Gerlando Falauto
<gerlando.falauto at keymile.com> wrote:
> 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:
>
> diff --git a/include/lttng/tracef.h b/include/lttng/tracef.h
> index 16a984b..98338d8 100644
> --- a/include/lttng/tracef.h
> +++ b/include/lttng/tracef.h
> @@ -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.
>
> 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
> Thank you,
> Gerlando
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list