[gdal-dev] Problem with links and compiling C++ app using GDAL libraries

Michael ODonnell odonnems at yahoo.com
Tue Feb 23 22:09:02 EST 2010


I have written a C++ application that uses GDAL libraries for raster analysis. The compiling crashes when trying to link to gdal libraries. I am getting an error for every GDAL object such as:
  [Linker error] undefined reference to `GDALAllRegister'
  [Linker error] undefined reference to `GDALOpen'
  ...
  ...

Can anyone help me with this because I am entirely lost as to what I have done wrong.

Thank you for your help,
Mike


My include files are:
#include <gdal_priv.h>
#include <cpl_string.h>

Project Options Linker:
-L"<path>/bin" -lgdal14

I have also set project Options Include and library directories.

OS: Windows XP SP3


Makefile.win:
# Project: Focal_Stats
# Makefile created by Dev-C++ 4.9.9.2

CPP  = g++.exe -D__DEBUG__
CC   = gcc.exe -D__DEBUG__
WINDRES = windres.exe
RES  = Focal_Stats_private.res
OBJ  = FocalStats.o $(RES)
LINKOBJ  = FocalStats.o $(RES)
LIBS =  -L"C:/Dev-Cpp/lib" -L"C:/Data_314/MW_C++/Focal_Stats_App/gdal_source_lib/gdalwin32dev141/gdalwin32-1.4.1/lib" -L"C:/Data_314/MW_C++/Focal_Stats_App/gdal_source_lib/gdalwin32exe141/gdalwin32-1.4.1/bin" -L"C:/Data_314/MW_C++/gdal_source_lib/gdalwin32exe141/gdalwin32-1.4.1/bin" -lgdal14  -lgmon -pg  -g3 
INCS =  -I"C:/Dev-Cpp/include"  -I"C:/Data_314/MW_C++/Focal_Stats_App/gdal_source_lib/gdalwin32dev141/gdalwin32-1.4.1/include" 
CXXINCS =  -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"C:/Data_314/MW_C++/Focal_Stats_App/gdal_source_lib/gdalwin32dev141/gdalwin32-1.4.1/include" 
BIN  = Focal_Stats.exe
CXXFLAGS = $(CXXINCS)   -pg -g3
CFLAGS = $(INCS)   -pg -g3
RM = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before Focal_Stats.exe all-after


clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
	$(CPP) $(LINKOBJ) -o "Focal_Stats.exe" $(LIBS)

FocalStats.o: FocalStats.cpp
	$(CPP) -c FocalStats.cpp -o FocalStats.o $(CXXFLAGS)

Focal_Stats_private.res: Focal_Stats_private.rc 
	$(WINDRES) -i Focal_Stats_private.rc --input-format=rc -o Focal_Stats_private.res -O coff



      


More information about the gdal-dev mailing list