Hi,
Could someone please help me?

My program hangs in a simple COUT statement!! What seems to be the problem??
I've tried different combinations of compile/link/runtime options, nothing seems to work. This is frustrating!

There is really nothing complicated here.
I've simplified the scenario and created three simple programs (codes below).
These are my objects:
1. tstmainc.ec - Main Program in C
2. tstsubc.c - Sub Program in C (simple printf)
3. tstsubcp.ec - Sub Program in C++ (SQL commands and Cout).

We are using:
- Informix 731
- uname -a = > SunOS gfxdev 5.6 Generic_105181-23 sun4u sparc SUNW,Ultra-2
- cannot remove mqm libraries (real program uses them)

Any help will be greatly appreciated!

Thanks!

==============================
tstmk.mk - Make File
==============================
INFORMIXINCL= $(INFORMIXDIR)/incl/esql
INFORMIXLB=$(INFORMIXDIR)/lib/esql
LIBRARIES= -L/usr/mqm/lib -lmqm -lmqmcs -lmqmzse -lnsl -lsocket -ldl -lm
LIBDIRS=-L$(INFORMIXDIR)/lib/esql -L$(INFORMIXDIR)/lib

INCLUDES= \
-I./\
-I/app/mqm/inc\
-I/usr/include\
-I/usr/ucbinclude\
-I$(INFORMIXINCL)\
-I$(INFORMIXDIR)/incl/tools

LDFLAGS= -Dsparc -DPRINT -g -DSET_UID -mt \
$(INFORMIXDIR)/lib/esql/checkapi.o \
$(INFORMIXDIR)/lib/esql/libixsql.a \
$(INFORMIXDIR)/lib/libixasf.a \
$(INFORMIXDIR)/lib/esql/libixos.a \
$(INFORMIXDIR)/lib/esql/libixgen.a \
$(INFORMIXDIR)/lib/esql/libixgls.a \
$(INFORMIXDIR)/lib/esql/libixglx.a \
-lnsl -lsocket -lm -laio -ldl -lelf
CCFLAGS= -c -Dsparc -DPRINT -g -DSET_UID -I. -I/usr/include -I$(INFORMIXDIR)/incl/esq
l -I$(INFORMIXDIR)/incl/tools -mt

CPFLAGS=-g -mt

CC=/export/vol/SUNWspro5.0/bin/cc
CP=/export/vol/SUNWspro5.0/bin/CC

OBJS=tstmainc.o tstsubcp.o tstsubc.o

.SUFFIXES: .ec

all: tstappc
@echo done

tstappc: $(OBJS)
$(CP) -o $@ $(OBJS) $(LDFLAGS) $(LIBDIRS) $(LIBRARIES)

tstmainc.o: tstmainc.c
$(CC) $(CCFLAGS) tstmainc.c $(INCLUDES)

tstsubcp.o: tstsubcp.c
$(CP) $(CPFLAGS) -c tstsubcp.c $(INCLUDES)

tstsubc.o: tstsubc.c
$(CC) $(CCFLAGS) -c tstsubc.c $(INCLUDES)

clean:
rm $(OBJS) core

install:
$(CP) -o tstmainc -O -L$(INFORMIXLB) $(OBJS) $(LIBRARIES) $(LIBDIRS)
## strip tstmainc

.ec.c:
esql -g -e `pwd`/$*.ec

.c.o:
$(CP) -c $(CPFLAGS) $(INCLUDES) `pwd`/$*.c


==============================
tstmainc.ec - Main Program in C
==============================
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
$include sqlca;
#include <sys/types.h>
#include <sys/file.h>
#include <sys/utsname.h>
#include <sys/stat.h>
#include <dirent.h>
#include "tstapp.h"

int main() {

int mt530cnt;
printf ("PRINTF : Main C Program Start\n");

tstsubc();

EXEC SQL WHENEVER ERROR CALL sqlerror;
EXEC SQL DATABASE swift_in;

mt530cnt = sql_select("SELECT count(*) FROM mt530 WHERE swift_msg_type = 531");

printf ("PRINTF : There are %d 531s in mt530.\n",mt530cnt);
printf ("PRINTF : Main C Program End\n");

return(0);
}

==============================
tstsubc.c - Sub Program in C
==============================
#include <stdio.h>
#include "tstapp.h"

void tstsubc() {
printf ("PRINTF : --Sub C Program - tstsubc\n");
}

==============================
tstsubcp.ec - Sub Program in C++
==============================
#include <stdlib.h>
#include <iostream.h>

extern "C"
{
$include sqlca;
}
#include <sys/types.h>
#include <sys/file.h>
#include <sys/utsname.h>
#include <sys/stat.h>

#include "tstapp.h"

void sqlerror(void)
{
cerr << "SQL = " << sqlca.sqlcode;
if (sqlca.sqlerrd[1] != 0)
cerr << ", ISAM = " << sqlca.sqlerrd[1];
cerr << endl;
exit(1);
}

int sql_select(char *txt)
{
printf ("PRINTF : --Sub C++ Program Start - sql_select\n");

/* COUT HANGS HERE!!! */
cout << "COUT : --Sub C++ Program Start - sql_select" << endl;

EXEC SQL BEGIN DECLARE SECTION;
char *stmt = txt;
int retval;
EXEC SQL END DECLARE SECTION;

EXEC SQL WHENEVER ERROR CALL sqlerror;

EXEC SQL PREPARE p_select FROM :stmt;
EXEC SQL DECLARE c_select CURSOR FOR p_select;
EXEC SQL OPEN c_select;
EXEC SQL FETCH c_select INTO :retval;
EXEC SQL CLOSE c_select;
EXEC SQL FREE c_select;

#if ESQLC_VERSION >= 600
EXEC SQL FREE p_select;
#endif

printf ("PRINTF : --Sub C++ Program End - sql_select\n");

/* COUT will hang here!!! */
cout << "COUT : --Sub C++ Program End - sql_select" << endl;

return(retval);
}

==============================
tstapp.h
==============================
#ifdef __cplusplus
extern "C" {
#endif
void tstsubc();
void sqlerror(void);
int sql_select(char *);
#ifdef __cplusplus
}
#endif