Menu

C++ and PCD_api_register_exception_handlers

Help
Anonymous
2011-08-04
2013-05-28
  • Anonymous

    Anonymous - 2011-08-04

    I have spent several hours trying to resolve an undefined reference to PCD_api_register_exception_handlers. If I compile in c, everything seems fine, but many of my daemons are written in C++. Is it not possible to use the exception handlers in C++? Thanks in Advance. I really am impressed by this product and would like to use it in my embedded system.

     
  • Hai Shalom

    Hai Shalom - 2011-08-04

    It shouldn't be a problem. I assume that you have a C++ program that you want to be instrumented with the exception handlers. Did you make sure that you linked your program with libpcd.so and libipc.so ?

     
  • Anonymous

    Anonymous - 2011-08-05

    Thanks for the quick response. I am pretty sure I am linking the correct libraries. I was struggling with it so much that I stole the compile line from the example script (changing the compiler, of course). This is what I see.
    g++ SystemDataManagement.cpp -lipc -lpcd -lrt -lsqlite3
    /tmp/ccPfqBS3.o: In function `main':
    SystemDataManagement.cpp:(.text+0xf77): undefined reference to `PCD_api_register_exception_handlers(char*, void (*)(int))'
    collect2: ld returned 1 exit status

    It seems to be a problem associated with the g++ compiler. If I change the build.sh script thus:
       ${CROSS}g++ ${i}.c -I ${PCD_DIR}/include -L ${PCD_LIBS_DIR} -lipc -lpcd -lrt -o ../bin/${i}
    I get the same error
    Compiling a.c
    /tmp/ccC0v8aj.o: In function `main':
    a.c:(.text+0x22): undefined reference to `PCD_api_register_exception_handlers(char*, void (*)(int))'
    collect2: ld returned 1 exit status

    I'm going to do a little more homework on moving from gcc to g++ to see if I can find out what I am doing wrong. I am very interested in using PCD for my current project. PCD fills many of the needs I have for daemon management that I thought I would have to write myself (poorly, at least the first time out of the gate!) I will post back with what I learn and thanks again.

     
  • Anonymous

    Anonymous - 2011-08-05

    FIXED I found my problem. I neglected to #ifdef __cplusplus extern "C" {  #endif around my C header files. Thanks again!

     
  • Hai Shalom

    Hai Shalom - 2011-08-05

    Great! Could you please attach an example of your fix so I could have it available for any future C++ user?

     

Log in to post a comment.