[gdal-dev] GDAL SWIG + Java and MS VC 9.0

Nidel, Mike mike.nidel at lmco.com
Thu Jul 10 09:29:02 EDT 2008


Hi everyone,

I've finally managed to get GDAL building and running on Windows with
MrSID 7.0, using nmake from MS Visual Studio 9.0/2008. I'm building from
the 1.5 branch; 1.5.2 doesn't have quite what I need for MrSID 7.0 and I
didn't want to build from the 1.6/trunk.

I was getting this error R6034 that caused my Java app to fail to load
the gdaljni.dll. After days of investigation suggesting that the problem
was related to manifest files, I finally learned that although
gdal15.dll does get built with a manifest, the gdaljni.dll and
gdalconst.dll do not. Here is a thread about manifests that helped me:

http://forums.msdn.microsoft.com/en-US/vcgeneral/thread/9fbc9292-11b8-4e
e4-94a4-5223546df280

The fix that I had to implement was small once I found it (aren't they
always?):

In GDAL_HOME/swig/java/makefile.vc, change the following:

gdal_dir:
	cd gdal
	$(MAKE) /f makefile.vc
	cd ..
	link gdal_wrap.obj $(GDALLIB) /out:gdaljni.dll /DLL


to add a line at the end to incorporate the manifest into the dll:

gdal_dir:
	cd gdal
	$(MAKE) /f makefile.vc
	cd ..
	link gdal_wrap.obj $(GDALLIB) /out:gdaljni.dll /DLL
	if exist gdaljni.dll.manifest mt -manifest gdaljni.dll.manifest
-outputresource:gdaljni.dll;2



I repeated this same thing for the other 3 dlls in that makefile.

I'm still not sure why it wasn't enough to put the gdaljni.dll.manifest
file in the same dir as the dll, but after debugging inside of the MS
CRT source code, I was convinced it wasn't loading the CRT DLLs from a
manifest. I did this fix and it works, and it means a few less files
(.manifest) to bundle with my apps so that's good too.

Do you think this could be patched and checked into the gdal 1.5 branch?
That would help me greatly. I am going to be shipping a product based on
this build... is there a plan to release a 1.5.3 in the next couple
weeks? If not, the downside is that I will have built DLLs that cannot
be reproduced easily because they will be from a snapshot of the build.
Even a tag like 1.5.3b or 1.5.3-pre would help me recover the exact
version I'm building against in case I run into problems down the road
and need to rebuild.

I've attached my makefile.vc, hopefully it'll go through. Please note: I
also had to remove the line:

  set JAVA_HOME="$(JAVA_HOME)"

because it caused the quotes around JAVA_HOME to get doubled, e.g.
""C:\Program Files..."", which ant did not like. If this part of the fix
is not acceptible for general users, go ahead and take it out.

It's my hope that this will help somebody else who's trying to build in
a similar environment as myself.


Thanks,

Mike


PS - if you ever have a similar problem, one useful trick is to drag
your .dll into the MS Visual Studio window, and it can show you whether
the DLL has a manifest.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: makefile.vc
Type: application/octet-stream
Size: 1530 bytes
Desc: makefile.vc
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080710/a6156c5b/makefile.obj


More information about the gdal-dev mailing list