Unix Technical Forum

Getting a C++ Application to compile on AIX 5.1 VACPP

This is a discussion on Getting a C++ Application to compile on AIX 5.1 VACPP within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi All, I have an application that compiles/runs fine on win2000 and solaris 9. I am doing my first ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 03:48 AM
Peter Nolan
 
Posts: n/a
Default Getting a C++ Application to compile on AIX 5.1 VACPP

Hi All,
I have an application that compiles/runs fine on win2000 and solaris
9.

I am doing my first install on AIX 5.1 + Oracle 9.2.x

We have got the compiling issues out of the way but I am having some
troubles getting it to link.......

The include file for headers contains the following lines:

#if defined (unix)
//#include <iostream>
//#include <fstream>
#include <iostream.h>
#include <fstream.h>
//using namespace std ;
#endif


I have tried all sorts of combinations of the old/new stream headers
and the namespace std and this was the only combination that I could
get to work.

In my code I have the normal cout << etc and I have file objects being
created etc.


For example. The following defined the input and output files for my
file handling class.

//////////////////////////////////////////////////////////////////////////////////////////////
// These are the public members of the class.
//
//////////////////////////////////////////////////////////////////////////////////////////////

ifstream input ;
ofstream output ;



The makefile is as follows:

# For AIX
CC=cc
#
# Compiler Options
#
CCFLAGS=-g
DEFS=-DODBCVER=0x0352
INCLUDE=-I/home/peter/idw/include
#
# Definition for standard system linker
#
LD=ld
#
# Define Support Libraries used.
#
#LIBPATH=-L/usr/local/easysoft/unixODBC/lib
/dstage/Ascential/DataStage/DSEngine/lib/vmdsapi.so
LIBPATH=-L/usr/local/easysoft/unixODBC/lib
LIBC=-lc
LIBS=$(LIBPATH) -lodbc
#
# Application that shows a single C source code connecting to
different
# vendor databases by simply changing the passed in DSN.
#
#
# Sample program using C++ Compiler
#
all: CDWU001
#
# $(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS)
$(LIBC)
CDWU001: CDWU001.cpp
$(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS) $(LIBC)
clean:
/bin/rm CDWU001
#
# End of Makefile
#




The error messages are as follows:


bash-2.05a$ make -f makeidw
cc -o CDWU001 -DODBCVER=0x0352 -g
-I/home/peter/idw/include CDWU001.
cpp -L/usr/local/easysoft/unixODBC/lib -lodbc -lc
1540-5215 (I) o licenses available. Contact your program supplier to
add additional users. Compilation will proceed shortly.
1506-507 (W) No licenses available. Contact your program supplier to
add additional users. Compilation will proceed shortly.
ld: 0711-317 ERROR: Undefined symbol: .SQLAllocHandle
ld: 0711-317 ERROR: Undefined symbol: .SQLSetEnvAttr
ld: 0711-317 ERROR: Undefined symbol: .SQLFreeHandle
ld: 0711-317 ERROR: Undefined symbol: .SQLDisconnect
ld: 0711-317 ERROR: Undefined symbol: .SQLSetConnectAttr
ld: 0711-317 ERROR: Undefined symbol: .SQLConnect
ld: 0711-317 ERROR: Undefined symbol: .SQLBrowseConnect
ld: 0711-317 ERROR: Undefined symbol: .SQLDriverConnect
ld: 0711-317 ERROR: Undefined symbol: .SQLGetDiagRec
ld: 0711-317 ERROR: Undefined symbol: .SQLGetConnectAttr
ld: 0711-317 ERROR: Undefined symbol: .SQLExecDirect
ld: 0711-317 ERROR: Undefined symbol: .SQLRowCount
ld: 0711-317 ERROR: Undefined symbol: .SQLFetch
ld: 0711-317 ERROR: Undefined symbol: cout
ld: 0711-317 ERROR: Undefined symbol: .ostream:perator<<(const
char*)
ld: 0711-317 ERROR: Undefined symbol: .ostream:perator<<(int)
ld: 0711-317 ERROR: Undefined symbol: .SQLGetData
ld: 0711-317 ERROR: Undefined symbol: .SQLDescribeCol
ld: 0711-317 ERROR: Undefined symbol: .ostream::ls_complicated(char)
ld: 0711-317 ERROR: Undefined symbol: .SQLNumResultCols
ld: 0711-317 ERROR: Undefined symbol: .operator new(unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .SQLFetchScroll
ld: 0711-317 ERROR: Undefined symbol: .SQLNumParams
ld: 0711-317 ERROR: Undefined symbol: .SQLPrepare
ld: 0711-317 ERROR: Undefined symbol: .SQLBindParameter
ld: 0711-317 ERROR: Undefined symbol: .SQLEndTran
ld: 0711-317 ERROR: Undefined symbol: .SQLExecute
ld: 0711-317 ERROR: Undefined symbol: .SQLCloseCursor
ld: 0711-317 ERROR: Undefined symbol: filebuf:penprot
ld: 0711-317 ERROR: Undefined symbol: .ifstream:pen(const
char*,int,int)
ld: 0711-317 ERROR: Undefined symbol: .ofstream:pen(const
char*,int,int)
ld: 0711-317 ERROR: Undefined symbol:
..istream::getline(char*,int,char)
ld: 0711-317 ERROR: Undefined symbol: .fstreambase::close()
ld: 0711-317 ERROR: Undefined symbol:
..istream::seekg(long,ios::seek_dir)
ld: 0711-317 ERROR: Undefined symbol: .istream::seekg(long)
ld: 0711-317 ERROR: Undefined symbol: .istream::read(char*,int)
ld: 0711-317 ERROR: Undefined symbol: cerr
ld: 0711-317 ERROR: Undefined symbol:
ofstream::virtual-fn-table-ptr-table
ld: 0711-317 ERROR: Undefined symbol: .ofstream:fstream()
ld: 0711-317 ERROR: Undefined symbol: .ofstream::~ofstream()
ld: 0711-317 ERROR: Undefined symbol: .operator delete(void*)
ld: 0711-317 ERROR: Undefined symbol:
ifstream::virtual-fn-table-ptr-table
ld: 0711-317 ERROR: Undefined symbol: .ifstream::ifstream()
ld: 0711-317 ERROR: Undefined symbol: .ifstream::~ifstream()
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
make: 1254-004 The error code from the last command is 8.




I am pretty sure that the problem is that I am not setting some
settings properly on the linkage editor. The dot in front of each
name seems to indicate that the compiler is creating some slightly
different symbol names and that the linkage editor needs to be aware
of these symbols preceeded with a dot. For example the code contains
'SQLAllocHandle' which is translated into '.SQLAllocHandle'. And it
seems to be the same with a number of the io symbols as well.

Has anyone seen this before? It seems like a 'beginners' problem in
getting the compiler set up properly.

Any advice most welcome.

Best Regards

Peter Nolan
www.peternolan.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 03:48 AM
Paul Pluzhnikov
 
Posts: n/a
Default Re: Getting a C++ Application to compile on AIX 5.1 VACPP

peter@peternolan.com (Peter Nolan) writes:

> We have got the compiling issues out of the way but I am having some
> troubles getting it to link.......


You are trying to compile and link a C++ program with 'cc'.
You should use 'xlC' instead (and you really ought to use the "new"
stream headers). Even better would be to use xlC_r, since Oracle
libraries require threads, AFAIK.

> The dot in front of each
> name seems to indicate that the compiler is creating some slightly
> different symbol names and that the linkage editor needs to be aware
> of these symbols preceeded with a dot. For example the code contains
> 'SQLAllocHandle' which is translated into '.SQLAllocHandle'. And it
> seems to be the same with a number of the io symbols as well.


This is "normal" behaviour on AIX; it has nothing to do with your
problem.

> Has anyone seen this before? It seems like a 'beginners' problem in
> getting the compiler set up properly.


The beginner's problem is in using incorrect compiler for the job.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 03:48 AM
Peter Nolan
 
Posts: n/a
Default Re: Getting a C++ Application to compile on AIX 5.1 VACPP

Hi All
we have been working on this for most of the afternoon......we have
gotten further....

The current output of the compile is as follows. ‘__start' is in the c
run time library and it looks like we are having troubles finding the
components of the run time. If we force the linker to use the first
module of run time it complains about the next, then the next etc.

I think there is something we are missing to get it to bring in the
correct libraries but we don't know what.

Any ideas most welcome.. :-)


Best Regards

Peter Nolan


================================================== ============================
Makefile

OBJECT_MODE=64
# For AIX
CXX=/usr/vac/bin/xlc
###CC=cc
# For HP
#CC=CC
# For Solaris
#CC=CC
# For Linux
#CC=CC
#
# Compiler Options
#
CXXFLAGS=-g -q64
DEFS=-DODBCVER=0x0351
INCLUDE=-I/home/peter/idw/include

SOURCES = CDWU001.cpp
OBJECTS = $(SOURCES:.cpp=.o)

#
# Definition for standard system linker
#
LD=ld
LDFLAGS=-bloadmap
LDFLAGS=-b64 -bnoquiet
#
# Define Support Libraries used.
#
#LIBPATH=-L/usr/local/easysoft/unixODBC/lib
/dstage/Ascential/DataStage/DSEngine/lib/vmdsapi.so
LIBPATH=/lib:/usr/vacpp/lib:/usr/ccs/lib:/usr/local/easysoft/unixODBC/lib
LD_LIBRARY_PATH = $(LIBPATH)
#LIBC=-lc
#LIBS=$(LIBPATH) /usr/local/easysoft/unixODBC/lib/libodbc.a
LIBS= /usr/local/easysoft/unixODBC/lib/libodbc.a
#LIBS=$(LIBPATH) -lodbc
#
# Application that shows a single C source code connecting to
different
# vendor databases by simply changing the passed in DSN.
#
#
# Sample program using C++ Compiler
#

#

all: CDWU001

CDWU001: CDWU001.o
$(LD) $(LDFLAGS) -o $@ -lC $(OBJECTS) $(LIBS)


CDWU001.o: CDWU001.cpp
$(CXX) -c $(CXXFLAGS) $(INCLUDE) CDWU001.cpp



# $(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS)
$(LIBC)
#CDWU001: CDWU001.cpp
# $(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS)
$(LIBC)

clean:
/bin/rm CDWU001 CDWU001.o

#
# End of Makefile


================================================== ============================
Compile and link output

peter@hera:idw$ make
/usr/vac/bin/xlc -c -g -q64 -I/home/peter/idw/include
CDWU001.cpp
1540-5215 (I) o licenses available. Contact your program supplier to
add additio
nal users. Compilation will proceed shortly.
ld -b64 -bnoquiet -o CDWU001 -lC CDWU001.o
/usr/local/easysoft/unixODBC/
lib/libodbc.a
(ld): setopt 64
(ld): halt 4
(ld): lrgpage 0
(ld): savename CDWU001
(ld): filelist 3 1
(ld): lib /usr/lib/libC.a
(ld): i CDWU001.o
(ld): i /usr/local/easysoft/unixODBC/lib/libodbc.a
INSERT: Shared object libC.a[shr_64.o]: 398 symbols imported.
INSERT: Shared object libC.a[shr2_64.o]: 25 symbols imported.
INSERT: Shared object libC.a[shr3_64.o]: 27 symbols imported.
INSERT: Shared object libC.a[ansi_64.o]: 2439 symbols imported.
INSERT: Shared object
/usr/local/easysoft/unixODBC/lib/libodbc.a[libodbc.so.1]:
156 symbols imported.
FILELIST: Number of previously inserted files processed: 3
(ld): resolve
ld: 0711-327 WARNING: Entry point not found: __start
RESOLVE: 0 of 4863 symbols were kept.
RESOLVE: The return code is 4.
(ld): addgl /usr/lib/glink64.o
ADDGL: Glink code added for 0 symbols.
(ld): er full
ER: There are no unresolved symbols.
(ld): mismatch
MISMATCH: No type mismatches exist.
(ld): comprld
COMPRLD: Kept 0 of 0 relocation entries.
(ld): origin 0x0 0x0
(ld): save 1L .
ld: 0711-244 ERROR: No csects or exported symbols have been saved.
SAVE: Section sizes = 4+0+0 (0x4+0x0+0x0 hex)
SAVE: The return code is 8.
make: 1254-004 The error code from the last command is 8.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 03:49 AM
Dave Seaman
 
Posts: n/a
Default Re: Getting a C++ Application to compile on AIX 5.1 VACPP

On 20 Jul 2004 09:44:52 -0700, Peter Nolan wrote:
> Hi All
> we have been working on this for most of the afternoon......we have
> gotten further....


> The current output of the compile is as follows. ‘__start' is in the c
> run time library and it looks like we are having troubles finding the
> components of the run time. If we force the linker to use the first
> module of run time it complains about the next, then the next etc.


> I think there is something we are missing to get it to bring in the
> correct libraries but we don't know what.


If you are compiling and linking C++ code, then you should use the C++
compiler (xlC) instead of the C compiler (xlc). It's also best to use
xlC for the link step instead of ld, since xlC knows where to find the
standard libraries.




--
Dave Seaman
Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
<http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-05-2008, 03:49 AM
Peter Nolan
 
Posts: n/a
Default Re: Getting a C++ Application to compile on AIX 5.1 VACPP

Hi All,
thanks so much for your help.......wrong compiler...duh....thems the
problems moving between unixes..


The working make file for those who make the same mistake..;-)

Best Regards

Peter Nolan


# For AIX
CXX=/usr/vacpp/bin/xlC
###CC=cc
# For HP
#CC=CC
# For Solaris
#CC=CC
# For Linux
#CC=CC
#
# Compiler Options
#
CXXFLAGS=-g -q64
DEFS=-DODBCVER=0x0351
INCLUDE=-I/home/peter/idw/include

SOURCES = CDWU001.cpp
OBJECTS = $(SOURCES:.cpp=.o)

#
# Definition for standard system linker
#
#LD=ld
LD=/usr/vacpp/bin/xlC
LDFLAGS=-bloadmap
LDFLAGS=-b64
#LDFLAGS=-b64 -bnoquiet
#
# Define Support Libraries used.
#
#LIBPATH=-L/usr/local/easysoft/unixODBC/lib
/dstage/Ascential/DataStage/DSEngine/lib/vmdsapi.so
LIBPATH=/lib:/usr/vacpp/lib:/usr/ccs/lib:/usr/local/easysoft/unixODBC/lib
LD_LIBRARY_PATH = $(LIBPATH)
#LIBC=-lc
#LIBS=$(LIBPATH) /usr/local/easysoft/unixODBC/lib/libodbc.a
LIBS= /usr/local/easysoft/unixODBC/lib/libodbc.a
#LIBS=$(LIBPATH) -lodbc
#
# Application that shows a single C source code connecting to
different
# vendor databases by simply changing the passed in DSN.
#
#
# Sample program using C++ Compiler
#

#

all: CDWU001

CDWU001: CDWU001.o
$(LD) $(LDFLAGS) -o $@ -lC $(OBJECTS) $(LIBS)


CDWU001.o: CDWU001.cpp
$(CXX) -c $(CXXFLAGS) $(INCLUDE) CDWU001.cpp



# $(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS)
$(LIBC)
#CDWU001: CDWU001.cpp
# $(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS)
$(LIBC)

clean:
/bin/rm CDWU001 CDWU001.o

#
# End of Makefile
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-05-2008, 03:49 AM
Peter Nolan
 
Posts: n/a
Default Re: Getting a C++ Application to compile on AIX 5.1 VACPP

Hi All,
we finally got this going...

So just for anybody else using 64 bit easysoft odbc drivers for AIX
who might come across this problem.

The key point was -DSIZEOF_LONG=8
on the line
DEFS=-DODBCVER=0x0351 -DSIZEOF_LONG=8

Without -DSIZEOF_LONG=8 the code will compile and execute but unsigned
integers get filled up with very large numbers for some reason.

The new, final, working make file is as follows. I hope this saves
someone else the 1.5 days it took us to figure out.

Best Regards

Peter Nolan

CXX=/usr/vacpp/bin/xlC
###CC=cc
# For HP
#CC=CC
# For Solaris
#CC=CC
# For Linux
#CC=CC
#
# Compiler Options
#
CXXFLAGS=-g -q64
#DEFS=-DODBCVER=0x0351
DEFS=-DODBCVER=0x0351 -DSIZEOF_LONG=8
INCLUDE=-I/home/peter/idw/include

SOURCES = CDWU001.cpp
OBJECTS = $(SOURCES:.cpp=.o)

#
# Definition for standard system linker
#
#LD=ld
LD=/usr/vacpp/bin/xlC
LDFLAGS=-bloadmap
LDFLAGS=-b64
#LDFLAGS=-b64 -bnoquiet
#
# Define Support Libraries used.
#
#LIBPATH=-L/usr/local/easysoft/unixODBC/lib
/dstage/Ascential/DataStage/DSEngine/lib/vmdsapi.so
LIBPATH=/lib:/usr/vacpp/lib:/usr/ccs/lib:/usr/local/easysoft/unixODBC/lib
LD_LIBRARY_PATH = $(LIBPATH)
#LIBC=-lc
#LIBS=$(LIBPATH) /usr/local/easysoft/unixODBC/lib/libodbc.a
LIBS= /usr/local/easysoft/unixODBC/lib/libodbc.a
#LIBS=$(LIBPATH) -lodbc
#
#

all: CDWU001

CDWU001: CDWU001.o
$(LD) $(LDFLAGS) -o $@ -lC $(OBJECTS) $(LIBS)


CDWU001.o: CDWU001.cpp
$(CXX) -c $(DEFS) $(CXXFLAGS) $(INCLUDE) CDWU001.cpp



# $(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS)
$(LIBC)
#CDWU001: CDWU001.cpp
# $(CC) -o $@ $(DEFS) $(CCFLAGS) $(INCLUDE) CDWU001.cpp $(LIBS)
$(LIBC)

clean:
/bin/rm CDWU001 CDWU001.o

#
# End of Makefile
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:45 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com