Use of C++ Library

I need to link to c++ libraries in my application (I am using phAB 2.3) but it is compiled with qcc (as opposed to QCC), is there a way to tell phAB to compile with the c++ compiler ( I look in to the makefiles and couldn’t find gcc qcc or QCC)

I am using QNX 6.3 with gcc 2.95.3.

I know my alternative would be creating all widgets from code (PtCreateWidget etc) but that would be more difficult, besides I cannot compile the example by just including <Pt.h>, it fails when linking, maybe I have to link some .lib files?

Thanks for any help

Ok, now my problem is down to a flag in the makefile.

Here is my common.mk file :
The flag I need to include for it to link properly is

-Y_gpp

how do I added it ? I tryied in CCFLAGS_D and CCFLAGS but that only is included when compiling the *.cc files, when it links it excludes the file and fails.

TIA (Hopefully)

This is an automatically generated record.

The area between QNX Internal Start and QNX Internal End is controlled by

the QNX IDE properties.

ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)

#===== USEFILE - the file containing the usage message for the application.
USEFILE=

include $(MKFILES_ROOT)/qphabtarg.mk
EXTRAF=-Y_gpp

#QNX internal start
ifeq ($(filter g, $(VARIANT_LIST)),g)
DEBUG_SUFFIX=_g
LIB_SUFFIX=_g
else
DEBUG_SUFFIX=_r
endif

#CC=QCC

LIBS_D = $(LIBS_$(CPUDIR)$(DEBUG_SUFFIX)) $(LIBS$(DEBUG_SUFFIX))

EXTRA_LIBVPATH := $(EXTRA_LIBVPATH_$(CPUDIR)$(DEBUG_SUFFIX)) $(EXTRA_LIBVPATH$(DEBUG_SUFFIX))
$(EXTRA_LIBVPATH_$(CPUDIR)) $(EXTRA_LIBVPATH)

EXTRA_INCVPATH := $(EXTRA_INCVPATH_$(CPUDIR)$(DEBUG_SUFFIX)) $(EXTRA_INCVPATH$(DEBUG_SUFFIX))
$(EXTRA_INCVPATH_$(CPUDIR)) $(EXTRA_INCVPATH)

EXTRA_SRCVPATH := $(EXTRA_SRCVPATH_$(CPUDIR)$(DEBUG_SUFFIX)) $(EXTRA_SRCVPATH$(DEBUG_SUFFIX))
$(EXTRA_SRCVPATH_$(CPUDIR)) $(EXTRA_SRCVPATH)

CCFLAGS_D = $(CCFLAGS$(DEBUG_SUFFIX)) $(CCFLAGS_$(CPUDIR)$(DEBUG_SUFFIX))
$(CCFLAGS_$(basename $@)$(DEBUG_SUFFIX))
$(CCFLAGS_$(CPUDIR)$(basename $@)$(DEBUG_SUFFIX))
LDFLAGS_D = $(LDFLAGS$(DEBUG_SUFFIX)) $(LDFLAGS
$(CPUDIR)$(DEBUG_SUFFIX)

CCFLAGS += $(CCFLAGS_$(CPUDIR)) $(CCFLAGS_$(basename $@))
$(CCFLAGS_$(CPUDIR)_$(basename $@)) $(CCFLAGS_D) #-Y_gpp

LDFLAGS += $(LDFLAGS_$(CPUDIR)) $(LDFLAGS_D)

LIBS := $(foreach token, $(LIBS_D) $(LIBS_$(CPUDIR)) $(LIBS), $(if $(findstring ^, $(token)), $(subst ^,$(token))$(LIB_SUFFIX), $(token)))

libnames:= $(subst lib-Bdynamic.a, ,$(subst lib-Bstatic.a, , $(libnames)))
libopts := $(subst -l-B,-B, $(libopts))
#QNX internal end

OPTIMIZE_TYPE_g=none
OPTIMIZE_TYPE=$(OPTIMIZE_TYPE_$(filter g, $(VARIANTS))) $(EXTRAF)

Add the -Y_gpp to LDFLAGS.

HTH.

I am using QNX 6.3.0 with gcc 2.95.3.
my common.mk is:
//////////////////
ifndef QCONFIG
QCONFIG=qconfig.mk
endif
include $(QCONFIG)
#===== USEFILE - the file containing the usage message for the application.
USEFILE=
#===== LDFLAGS - add the flags to the linker command line.
LDFLAGS+=-lang-c++
LDFLAGS+=-Y_gpp
#===== EXTRA_INCVPATH - a space-separated list of directories to search for include files.
EXTRA_INCVPATH_x86+=/usr/local/include
include $(MKFILES_ROOT)/qmacros.mk
//////////////////
I add some extra c++ files into src. But when compile, It still can’t pass. In proto.h ,like void A::b() can’t be resolved.
Any advice will be appreciated.

Dxwang,

Is A::b() your function or is this a library function?

Are you sure those new src files you added are being compiled AND being linked in properly?

I have the ‘-lang-c++’ option on both my CFLAGS and LDFLAGS macro’s.

Tim

it’s my c++ files. it contains class. A:b() is my the function of class.

Dxwang,

Just to be clear, the error your getting is at link time and not compile time. Is this correct?

You posted the common.mk file but what about the Makefile itself. I am curious as to what the CFLAGS macro looks like and if your new source files are actually getting compiled correctly.

If you just make a test.cpp file and place your A class in it will it compile and link (you can just make a main that does nothing but call A::b() then exit) via ‘qcc test.cpp A.cpp’ from the command line?

Your A.cpp could look like (assumes you have an A.h file):

#include A.h

class A
{
   // Class A code here. You can strip out most of it if it's a large class
   // with lots of external references to other classes/functions.
   // You only really need the b() function.

public:
   void b(void)
   {
        cout << " I am here in b()" << endl;
    }
}

Your test.cpp could look like

#include "A.h"

int main(void)
{
    A a;

    a.b();

    exit(1);
}

Tim