[Proj] Re: Compiling Eric Millers proj_api.dll

Eric Miller EMiller at dfg.ca.gov
Mon Sep 20 15:44:11 EDT 2004


>>> "Tony Seiscons" <gu2l5z3wt001 at sneakemail.com> 9/19/2004 9:25:16 PM
>>>
> I have got a bit further with this but have not yet been successful. 
I
> have put the Proj files in c:\msys\1.0\Proj.  The proj.exe,
proj.dll,
> libproj.a and *.o files are in c:\msys\1.0\Proj\bin and the*.c and
*.h
> files are in c:\msys\1.0\Proj\proj_4.4.8\src.  If I put proj_api.c
in
> c:\msys\1.0\Proj and in mSys I change directories to /proj and then
> execute on the command line the following:
> 
> $ gcc proj_api.c -O -Wall -W -mwindows -DBUILD_DLL=1 -I.
> -I../proj/proj-4.4.8/src
> 
> I get:
> 
> C:/DOCUME~1/Tony/LOCALS~1/Temp/ccOGaaaa.o(.text+0xa):proj_api.c: \
> undefined reference to `pj_init_plus'
> C:/DOCUME~1/Tony/LOCALS~1/Temp/ccOGaaaa.o(.text+0x1e):proj_api.c: \
> undefined reference to `pj_free'
> C:/DOCUME~1/Tony/LOCALS~1/Temp/ccOGaaaa.o(.text+0x44):proj_api.c: \
> undefined reference to `pj_transform' etc. followed by
>
c:/mingw/bin/../lib/gcc-lib/mingw32/3.2.3/../../../libmingw32.a(main.o)
\
> (.text+0x97):main.c: undefined reference to `WinMain at 16'

This will never work, since the default behavior of gcc is to create
an
executable, but there is no "main" function in proj_api.c and the
errors
are due to missing link path/libs info (besides WinMain).

> If I execute:
> 
> $ gcc proj_api.c -O -Wall -W -mwindows -DBUILD_DLL=1 -I.
> -I../proj/proj-4.4.8/src
> 
> I get
> 
> proj_api.c:63:22: projects.h: No such file or directory 
> proj_api.c:64:22: proj_api.h: No such file or directory 
> proj_api.c:75: warning: type defaults to `int' in declaration of
`projPJ'
> etc.
> 
> indicating, I guess that it can't find the header files listed in
> proj_api.c

Yes. The -I../proj/proj-4.4.8/src must not be correct.
 
> So If the compiler is picking up projects.h and proj_api.h, why all
the
> undefined references to whatever.
> 
> I had a similar problem using Dev-C++ which is an IDE.  If I included
only
> the proj.c file in the IDE project I got a series of "undefined
reference"
> errors when I tried to compile it, even if I got the include
directories
> right.  To get proj.c to compile I had to drag and drop all of the
*.c and
> *.h files into the IDE project (except cs2cs.c, nad2nad.c etc.).

I'd guess you're not specifying the link path for libproj nor the link
flag
-lproj.  The compilation and linking phases are separate and have
separate
arguments (-L<PATH_TO_LIB> -l<library_name>)

> If I use Eric Millers make file with the include and lib paths
suitably
> modified I get the same series of "undefined reference" errors
followed
> by:
> 
> c:\mingw\bin\dllwrap.exe: no export definition file provided. 
Creating
> one, but that may not be what you want 

This should be okay.  We're having dllwrap create the exports file.

> c:\mingw\bin\dllwrap.exe: c:\mingw\bin\gcc exited with status 1 make:
***
> [proj_api.dll] Error 1

Not useful.  Presumably proj_api.dll failed to build.  Double check
the
include path...




Eric G. Miller
GIS Analyst
Wildlife and Habitat Data Analysis Branch
Department of Fish and Game



More information about the Proj mailing list