[gdal-dev] Problem in an application calling GDAL library
Limei Ran
lran at unc.edu
Fri Nov 30 13:45:21 EST 2007
Hi:
I obtained GDAL1.4.2 and install the software with PROJ.4 statically on
a linux server. Now, I am writting a small program using some classes
in GDAL. Here is my Makefile to create exe file for the gdal_gridpoly.cpp:
=============================
# for Linux or any gcc/g++ compiler
CC = gcc
CPP = g++
# for IBM VisualAge compiler on AIX
#CC = c89
#CPP = xlC_r
#Optional flags - uncomment one OPTFLAGS line
OPTFLAGS = -O2
#OPTFLAGS = -O -DDEBUG
#link flag
LNK_FLAGS = -pg
#set GDAL library and include directories
GDAL_DIR = /nas/uncch/depts/cep/emc/lran/soft/gdal-1.4.2/local/lib
GDAL_INCLUDE = /nas/uncch/depts/cep/emc/lran/soft/gdal-1.4.2/local/include
LOCAL_DIR = /usr/lib
# Library paths
LIBS = -L$(GDAL_DIR) -lgdal -L$(LOCAL_DIR) -lpq -lz -lm -lrt -ldl -static
EXE_LIBS = $(GDAL_DIR)/libgdal.la
CPPFLAGS = $(OPTFLAGS) -I$(GDAL_INCLUDE)
all: ogr_gridpoly.exe
ogr_gridpoly.exe: ogr_gridpoly.o $(EXE_LIBS)
$(CPP) $(LNK_FLAGS ) ogr_gridpoly.o -o $ogr_gridpoly.exe $(LIBS)
clean:
-rm -f *.o ogr_gridpoly.exe
ogr_gridpoly.o: ogr_gridpoly.cpp
$(CPP) $(CPPFLAGS) ogr_gridpoly.cpp -c -o $@
==================================================
When I make the exe file, I got a lot error messages related to
undefined references such as:
===================================================
/nas/uncch/depts/cep/emc/lran/soft/gdal-1.4.2/local/lib/libgdal.a(cplgetsymbol.o)(.text+0x24):
In function `CPLGetSymbol':
: Using 'dlopen' in statically linked applications requires at runtime
the shared libraries from the glibc version used for linking
/usr/lib/libpq.a(fe-secure.o)(.text+0x3a6): In function `load_dh_file':
/usr/src/build/475942-i386/BUILD/postgresql-7.3.8/src/interfaces/libpq/fe-secure.c:503:
Using 'getpwuid' in statically linked applications requires at runtime
the shared libraries from the glibc version used for linking
/usr/lib/libpq.a(fe-connect.o)(.text+0xccc): In function `connectDBStart':
/usr/src/build/475942-i386/BUILD/postgresql-7.3.8/src/interfaces/libpq/fe-connect.c:844:
Using 'gethostbyname' in statically linked applications requires at
runtime the shared libraries from the glibc version used for linking
/nas/uncch/depts/cep/emc/lran/soft/gdal-1.4.2/local/lib/libgdal.a(ogrociselectlayer.o)(.text+0x181):
In function `OGROCISelectLayer::ReadTableDefinition(OGROCIStatement*)':
: undefined reference to `OCIParamGet'
/nas/uncch/depts/cep/emc/lran/soft/gdal-1.4.2/local/lib/libgdal.a(ogrocisession.o)(.text+0x128):
In function `OGROCISession::~OGROCISession()':
: undefined reference to `OCILogoff'
/nas/uncch/depts/cep/emc/lran/soft/gdal-1.4.2/local/lib/libgdal.a(ogrocisession.o)(.text+0x13b):
In function `OGROCISession::~OGROCISession()':
.............................
=========================================================
There must be some problems in defining LIBS. It looks like OCI* stuffs
are related to oracle. I looked GDAL's GDALmake.opt. LIBS is defined as:
LIBS = -L/nas/uncch/depts/cep/emc/lran/soft/proj-4.5.0/exe/lib
-lproj -L/afs/isis.unc.edu/pkg/oracle-1020/client//lib -lclntsh -lnnz10
-lgif -ljpeg -lpng -L/usr/lib -lpq -lz -lm -lrt -ldl $(DWG_LIBS)
$(SDE_LIB) $(CURL_LIB) $(IDB_LIB)
My question is how I can define GDAL library in my application's
makefile? Do I need to include PROJ and oracle lib likes LIBS in GDAL's
GDALmake.opt in my application Makefile LIBS?
Thanks,
Limei
More information about the gdal-dev
mailing list