PtCompound won`t run with subs

Hey, im developing a PtCompound-subclass for QNX4.25

Can anybody send me another example source code for
PtCompound? Im not getting the freeking widget to run…

thx in advance

oh yes, mailto: micro a planetschranz(dot)de

removed mail-link due to heavy spam …

Made it to compile, but linking fails, even i made the code minimum …


cc -Osax -g2 -3 -mf -w5 -b    -c PtLabelImage3.c 
cc -o li3 -g2 -3 -mf -b -l photon_s -l Aplib -l phexlib -l phcontrib -l phrtlib PtLabelImage3.o
Warning(1028): mmap_ is an undefined reference
Warning(1028): munmap_ is an undefined reference
Warning(1028): atexit_ is an undefined reference
Warning(1028): malloc_ is an undefined reference
Warning(1028): calloc_ is an undefined reference
Warning(1028): realloc_ is an undefined reference
Warning(1028): free_ is an undefined reference
Warning(1028): getenv_ is an undefined reference
Warning(1028): exit_ is an undefined reference
Warning(1028): setenv_ is an undefined reference
Warning(1028): qnx_spawn_ is an undefined reference
Warning(1028): spawnl_ is an undefined reference
Warning(1028): _environ is an undefined reference
Warning(1028): _qnx_spawn_options is an undefined reference
Warning(1028): spawnvp_ is an undefined reference
Warning(1028): _sho_open_ is an undefined reference
Warning(1028): __get_errno_ptr_ is an undefined reference
Warning(1028): strerror_ is an undefined reference
Warning(1028): write_ is an undefined reference
Warning(1028): strlen_ is an undefined reference
Warning(1028): _exit_ is an undefined reference
Warning(1023): no starting address found, using 001c9000
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol mmap_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol munmap_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol atexit_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol malloc_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol calloc_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol realloc_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol free_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol getenv_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol exit_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol setenv_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol qnx_spawn_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol spawnl_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol _environ
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol _qnx_spawn_options
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol spawnvp_
file /usr/lib/photon_s.lib(/tmp/mksh_host_226-11526-6.c): undefined symbol _sho_open_
file /usr/lib/photon_s.lib(/tmp/mksh_host__err226-11526-8.c): undefined symbol __get_errno_ptr_
file /usr/lib/photon_s.lib(/tmp/mksh_host__err226-11526-8.c): undefined symbol strerror_
file /usr/lib/photon_s.lib(/tmp/mksh_host__err226-11526-8.c): undefined symbol write_
file /usr/lib/photon_s.lib(/tmp/mksh_host__err226-11526-8.c): undefined symbol strlen_
file /usr/lib/photon_s.lib(/tmp/mksh_host__err226-11526-8.c): undefined symbol _exit_ 

with Makefile:

ifndef DEBUG
DEBUG = -g2
endif
ifndef OPTIM
OPTIM = -Osax
endif

CFLAGS  = $(OPTIM) $(DEBUG) -3 -mf -w5 -b 
LDFLAGS = $(DEBUG) -3 -mf -b -l photon_s -l Aplib -l phexlib -l phcontrib -l phrtlib

shadowtest:	shadowtest.o ShadowedBox.o
		$(CC) -o $(@) $(LDFLAGS) shadowtest.o ShadowedBox.o


li3:		PtLabelImage3.o
		$(CC) -o $(@) $(LDFLAGS) PtLabelImage3.o

sl2:		PtSampleList2.o
		$(CC) -o $(@) $(LDFLAGS) PtSampleList2.o

somehow i think i am missing something … like not doing pushing a button i should :stuck_out_tongue_winking_eye:

so the problem described above is solved …

Doing executable without mainfunction won´t work.
I put in a Main function now,
problem is, as soon as i include my subs, lets say creating an Label in dflts function, and including it in PtCreateWindows Args from my PtCompound-deriviate, makes SIGSEGVing the App …
I put my code now:

LabelCompound.h:


#ifndef __PT_LABEL_IMAGE_H_INCLUDED
#define __PT_LABEL_IMAGE_H_INCLUDED


#ifndef __PT_COMPOUND_H_INCLUDED
 #include <photon/PtCompound.h>
#endif

#ifndef __PT_LABEL_H_INCLUDED
 #include <photon/PtLabel.h>
#endif

#ifndef _PXIMAGE_H_INCLUDED 
 #include <photon/PxImage.h>
#endif


#ifdef __cplusplus
extern "C" {
#endif

#define PtLIWidget_t Pt_LabelImageWidget_t

extern PtWidgetClassRef_t *const PtLabelImage;


typedef struct Pt_LabelImage {
	 
	PtCompoundWidget_t	compound;		// Das Compound Widget immer als erstes!!!
	PtWidget_t *clabelw;

} Pt_LabelImageWidget_t;

typedef union Pt_LabelImageUnion {
	PtWidget_t           core;
	PtBasicWidget_t      basic;
	PtContainerWidget_t  cntnr;
	PtCompoundWidget_t   cmpnd;
	PtLabelWidget_t		label;
	Pt_LabelImageWidget_t	li3w;
} Pt_LabelImageUnion_t;

PtLabelCompound.c


#include <string.h>
#include <stdlib.h>
#include <Pt.h>
#include <Ph.h>
#include "PtLabelCompound.h"

#include <string.h>
#include <Pt.h>
#include <Ph.h>

PtWidgetClass_t *PtCreateLIClass( void );					// Prototype Widget - Create Funktion


PtWidgetClassRef_t __Pt_LabelImage = { NULL, PtCreateLIClass };
PtWidgetClassRef_t * const PtLabelImage = &__Pt_LabelImage;


static void
dflts_f( PtWidget_t *widget )
{
	PtLIWidget_t *li3 = (PtLIWidget_t *) widget;
	PtArg_t argt[10];
	int n = 0;
	PtSetArg(&argt[n], Pt_ARG_TEXT_STRING, "Bla", 0 ); n++;
	PtSetArg(&argt[n], Pt_ARG_FILL_COLOR, Pg_BLUE, 0 ); n++;
	li3->clabelw = PtCreateWidget( PtLabel, widget, n, argt );
	n=0;

}

static void
li_forwarding( PtWidget_t *widget, PtArg_t *argt )
{
	// forward resources
	PtLIWidget_t *li3 = (PtLIWidget_t * ) widget;
	PtSetResources( li3->clabelw, 1, argt );
}


PtWidgetClass_t *PtCreateLIClass( void )
{
    static PtResourceRec_t resources[] =
    {
		Pt_ARG_FILL_COLOR, li3_forwarding, 0, Pt_ARG_IS_NUMBER( PtBasicWidget_t, fill_color), 0,
		Pt_ARG_TEXT_STRING, li3_forwarding, 0, Pt_ARG_IS_STRING( PtLabelWidget_t, string), 0
    };

    static ushort_t subs[] =
    {
        offsetof( Pt_LabelImageWidget_t, 	clabelw )
    };

	static ulong_t blocked[] = {
		Pt_ARG_BALLOON_FILL_COLOR
	};

// Crashes here in runtime, as soon as i include subs in args !!

	static PtArg_t args[] = {
		{ Pt_SET_VERSION, 110 },
		{ Pt_SET_DFLTS_F, (long) dflts_f },
		{ Pt_SET_NUM_RESOURCES, sizeof( resources ) / sizeof( resources[0] ) },
		{ Pt_SET_RESOURCES,	(long) resources, sizeof( resources ) / sizeof( resources[0] ) },
		{ Pt_SET_NUM_SUBORDINATES, sizeof( subs ) / sizeof( subs[0] ) },
		{ Pt_SET_SUBORDINATES, (long) subs, sizeof( subs ) / sizeof( subs[0] ) },
		{ Pt_SET_NUM_BLOCKED_RESOURCES,	sizeof( blocked )/ sizeof( blocked[0] ) },
		{ Pt_SET_BLOCKED_RESOURCES,	(long) blocked, sizeof( blocked ) / sizeof( blocked[0] ) },
	};
	int size = sizeof( args ) / sizeof(args[0]);
	printf("Size: %d\n",size);
	return( PtLabelImage->wclass =
		PtCreateWidgetClass( PtCompound, 0, size, args )
	);
}

int main( int argc, char **argv ) {
	PtArg_t        args[ 10 ];
	PtWidget_t *   mainw;
	PtWidget_t *   list;
	PtAppContext_t app;

	PtSetArg( &args[0], Pt_ARG_WINDOW_TITLE, "PtLI", 0 );

	mainw = PtAppInit( &app, &argc, argv, 1, args );
	if ( mainw == NULL ) {
		return(EXIT_FAILURE);
	}
	
	PtSetArg( &args[0], Pt_ARG_TEXT_STRING, "Juhuu .. n Label", 0 );
	PtSetArg( &args[1], Pt_ARG_FILL_COLOR, Pg_BLUE, 0 );
	PtSetArg( &args[2], Pt_ARG_LABEL_TYPE, Pt_Z_STRING, 0 );
	list = PtCreateWidget( PtLabelImage, mainw, 3, args );
//	list = PtCreateWidget( PtLabel, mainw, 3, args );

	PtRealizeWidget( mainw );
	PtMainLoop();

	return(EXIT_SUCCESS);
}

There may be some wired namings, since i changed and deleted a lot for posting, but in general thats all what is run through.

Thx for help[/code]

Found the mistake, you have to set Pt_PROCREATED ind dflts_f, but nevertheless there won´t show up a Label in my App …
The label will show up as soon as i create just the label, but not within the compound …
Is there anybody having experience with PtCompound or has some other example?
I´m really getting tired of Custom Widgets :stuck_out_tongue_winking_eye:

moved on to a new topic, since the original problem was solved

http://www.openqnx.com/PNphpBB2-viewtopic-t8516-.html