PxConfig problem

Hi all. I’m trying to use the PxConfig… functions. What I have compiles but then I try to build the project I get a load of errors saying

*** [C:/QNX630/workspace/Emulator/x86/o/Emulator] Error 1	Emulator		
*** [C:/QNX630/workspace/Emulator/x86/o-g/Emulator_g] Error 1	Emulator		
scenario_cancel_clicked.o * In function `scenario_cancel_clicked':  undefined reference to `PxConfigSetCx'
scenario_cancel_clicked.o * undefined reference to `PxConfigGetCx'  undefined reference to `PxConfigSetCx'
scenario_cancel_clicked.o * undefined reference to `PxConfigOpenCx'  undefined reference to `PxConfigSetCx'
scenario_cancel_clicked.o * undefined reference to `PxConfigSetCx'  undefined reference to `PxConfigGetCx'
scenario_cancel_clicked.o * undefined reference to `PxConfigSetCx'  undefined reference to `PxConfigOpenCx'
undefined reference to `PxConfigGetCx'	scenario_cancel_clicked.c	Emulator/src	line 29
undefined reference to `PxConfigOpenCx'	scenario_cancel_clicked.c	Emulator/src	line 29
undefined reference to `PxConfigSetCx'	scenario_cancel_clicked.c	Emulator/src	line 29
undefined reference to `PxConfigSetCx'	scenario_cancel_clicked.c	Emulator/src	line 30

Heres my code

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

#include <photon/PxProto.h>

/* Local headers */
#include "ablibs.h"
#include "abimport.h"
#include "proto.h"

int
scenario_cancel_clicked( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
    if (PxConfigOpen("myconfig", PXCONFIG_WRITE))
    {
        // read parameters from the file
        PxConfigClose();
    }
    else
    {
        (void)printf("Failed to open configuration file\n");
    }

    return( Pt_CONTINUE );
}

Can anyone see what im doing wrong?

The PxConfig stuff is in an extra library: phexlib. (That’s why you get a ‘undefined reference’, the compiler knows the functions from the header but it does not find the actual code for the functions as the code is in the extra lib)
You need to tell your compiler to use this library while compiling.

If you are using command line simply append ‘-lphexlib’ to your ‘gcc foo bar.c’ line.

If you use PhAB go
Project → Project Properties → Build and Debug options
and write ‘phexlib’ into the ‘Link Libraries’ field
(this is for QNX6.3, but there should be some similar option in other PhABs)

Many thanks.

I knew it was something stupid i had not set correctly or something like that.

Cheers