[genivi-dlt] undefined reference to dlt_* when compiling Logging example from dlt_user_manual.txt

Prigent, Christophe christophe.prigent at intel.com
Tue May 30 10:25:53 EDT 2017


My bad, the problem is solved using command:
$ gcc dltdemo.c -o dltdemo -ldlt 

-----Original Message-----
From: genivi-diagnostic-log-and-trace [mailto:genivi-diagnostic-log-and-trace-bounces at lists.genivi.org] On Behalf Of Prigent, Christophe
Sent: Tuesday, May 30, 2017 2:12 PM
To: genivi-diagnostic-log-and-trace at lists.genivi.org
Subject: [genivi-dlt] undefined reference to dlt_* when compiling Logging example from dlt_user_manual.txt

Good morning,

I have some compilation errors when I'm trying the logging example from https://github.com/GENIVI/dlt-daemon/blob/master/doc/dlt_user_manual.txt (section "=== Logging example").
How can I solve it?

Thank you,
Christophe.

dltdemo.c:
----------
#include <stdio.h>
#include <dlt/dlt.h>

DLT_DECLARE_CONTEXT(mycontext);

int main()
{
   int num;

   DLT_REGISTER_APP("MYAP","My Application");
   DLT_REGISTER_CONTEXT(mycontext,"MYCT", "My Context");

   printf("Hello world");

   for(num=0;num<10;num++) {
      DLT_LOG(mycontext,DLT_LOG_INFO,DLT_STRING("Hello world"),DLT_INT(num));
      sleep(1);
   }

   DLT_UNREGISTER_CONTEXT(mycontext);
   DLT_UNREGISTER_APP();

   return 0;
}

Steps:
------
christophe at XPS12-9Q33 ~/dev/logging-example $ gcc -o dltdemo -ldlt dltdemo.c
dltdemo.c:2:17: fatal error: dlt.h: No such file or directory compilation terminated.
christophe at XPS12-9Q33 ~/dev/logging-example $ locate dlt.h /usr/include/qdlt/qdlt.h /usr/local/include/dlt/dlt.h

With #include <dlt/dlt.h> instead of #include <dlt.h>:

christophe at XPS12-9Q33 ~/dev/logging-example $ gcc -o dltdemo -ldlt dltdemo.c
/tmp/ccqfNZ9M.o: In function `main':
dltdemo.c:(.text+0x72): undefined reference to `dlt_check_library_version'
dltdemo.c:(.text+0x81): undefined reference to `dlt_register_app'
dltdemo.c:(.text+0x95): undefined reference to `dlt_register_context'
dltdemo.c:(.text+0xe0): undefined reference to `dlt_user_log_write_start'
dltdemo.c:(.text+0x103): undefined reference to `dlt_user_log_write_string'
dltdemo.c:(.text+0x11a): undefined reference to `dlt_user_log_write_int'
dltdemo.c:(.text+0x129): undefined reference to `dlt_user_log_write_finish'
dltdemo.c:(.text+0x151): undefined reference to `dlt_unregister_context'
dltdemo.c:(.text+0x156): undefined reference to `dlt_unregister_app'
collect2: error: ld returned 1 exit status
christophe at XPS12-9Q33 ~/dev/logging-example $

Info:
-----
Distro: Linux Mint 18.1 Serena
Kernel: 4.4.0-53-generic x86_64 (64 bit gcc: 5.4.0) gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)


---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
genivi-diagnostic-log-and-trace mailing list genivi-diagnostic-log-and-trace at lists.genivi.org
http://lists.genivi.org/mailman/listinfo/genivi-diagnostic-log-and-trace
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


More information about the genivi-diagnostic-log-and-trace mailing list