[FWTools] Compiling using gdal libraries

Mateusz Loskot mateusz at loskot.net
Thu Jan 11 12:23:14 EST 2007


Mike Toothaker wrote:
> I am using the following commandline:
> 
> g++ Color.cpp –I<path to gdal include> -L<path to gdal libs> -lgdal
> 
> I am getting a return saying that it is missing a bunch of other libs,
> surely I don’t have to include all of these libs on the commandline, or
> in my Makefile, do I?

You shouldn't have to.
Could you provide some listing with errors you're getting?


Here is a sample Makefile you can use to build simple programs
that use GDAL. I use such a makefile myself all the time.
I customized this version for your Color.cpp,
just edit /path/to/gdal

CXX = g++
CXXFLAGS = -g -Wall -Wno-long-long -pedantic
LDFLAGS = -L/path/to/gdal -lgdal -lgeos_c -lgeos
CFLAGS = -I/path/to/gdal/port \
         -I/path/to/gdal/gcore \
         -I/path/to/gdal/ogr \
         -I/path/to/gdal/ogrsf_frmts \
         $(CXXFLAGS)
PROGS = color

all: $(PROGS)

color: Color.cpp
	$(CXX) $(CFLAGS) $< -o $@ $(LDFLAGS)


If you want to add more programs, copy & paste these lines:

another: another.cpp
	$(CXX) $(CFLAGS) $< -o $@ $(LDFLAGS)


Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net


More information about the FWTools mailing list