• Manavendra Nath Manav

    I am trying to resolve the following undefined reference error, but not able to progress even after several hours. I am working on a C++ project for ARM target board and using ARM-g++ cross compiler.

    Objects/main.o: In function `main':
    source/ui/src/main.cpp:76: undefined reference to `PCD_api_register_exception_handlers(char*, void (*)(int))'
    /home/E518816/pcd/pcd-1.1.3/bin/target/lib/libpcd.so: undefined reference to `PCD_errlog_log'
    collect2: ld returned 1 exit status
    make: *** [tuxedo] Error 1

    I even tried putting

    #include <pcdapi.h>

    in an

    #ifdef __cplusplus extern "C" { #endif

    block but still same error is coming. When I try to list symbol




    it is saying that the symbol is undefined. Why?

    [E518816@IE1AUW029 LL_GUI_OCT_21]$ nm /home/E518816/pcd/pcd-1.1.3/bin/target/lib/libpcd.so | grep PCD_errlog_log
             U PCD_errlog_log

    I also tried building PCD with g++ instead of gcc by changing CC in Makefiles but it's failing with compilation errors. On a second thought, I guess this might be a typo error to add


    instead of


    to LDFLAGS as mentioned in pcd documentation.

    Manavendra Nath Manav

  • Hai Shalom

    Hai Shalom - 2011-11-14

    Thanks for pointing it out. There was a mistake using the log macro in the context of the pcd library. This function is available in the pcd context only. Please download the updated release which addresses this issue, and sorry for your inconvenience.
    I will also update the pcd documentation with the correct library name.

  • Manavendra Nath Manav

    Hi, Thanks for the prompt reply. I took the new release 1.1.4 but still the same error is coming. I still could not understand fully what you meant by

    This function is available in the pcd context only


    Objects/main.o: In function `main':
    source/ui/src/main.cpp:71: undefined reference to `PCD_api_register_exception_handlers(char*, void (*)(int))'
    collect2: ld returned 1 exit status
    make: *** [tuxedo] Error 1
  • Hai Shalom

    Hai Shalom - 2011-11-15

    The PCD log function is a wrapper to fprintf that also adds "pcd: " prefix and a ".\n" in the end. It is implemented in the pcd source code which runs in the pcd context. This function is not available in the library code, so the bug was that if you don't have an implementation of such a function in your executable, the link will fail. I fixed it by reverting to printf.
    I was able to successfully link with libpcd.so with v1.1.4. Did you add the cplusplus definition to the header file before trying to compile? Are you linking with -lpcd -lipc -lrt ?
    Once it works for you, I'll be happy if you could submit a patch to add the cplusplus definition permanently.

  • Manavendra Nath Manav

    Hi, I am able to compile and build my application after registering PCD exception handlers. I just added the cplusplus definition in pcdapi.h header file which solved the issue. Following is the patch:

    [root@IE1AUW029 pcd]# diff -uNr pcd-1.1.4.bk/pcd/src/pcdapi/include/pcdapi.h pcd-1.1.4.new/pcd/src/pcdapi/include/pcdapi.h
    --- pcd-1.1.4.bk/pcd/src/pcdapi/include/pcdapi.h        2011-11-16 13:34:28.000000000 +0530
    +++ pcd-1.1.4.new/pcd/src/pcdapi/include/pcdapi.h       2011-11-16 13:36:35.000000000 +0530
    @@ -40,6 +40,9 @@
     #ifndef _PCDAPI_H_
     #define _PCDAPI_H_
    +#ifdef __cplusplus
    +extern "C" {
     /*      INCLUDES                                                          */
    @@ -199,4 +202,7 @@
     #define PCD_API_FIND_PROCESS_ID() ( PCD_api_find_process_id( argv[ 0 ] ) )
    +#ifdef __cplusplus
     #endif /* _PCDAPI_H_ */

    Thanks for the much needed help,
    Manavendra Nath Manav


Log in to post a comment.