Opened 11 years ago

Closed 7 years ago

#926 closed enhancement (invalid)

Patch to support building of osm2pgsql under mingw32

Reported by: Thomas Wood Owned by: jburgess777@…
Priority: major Milestone:
Component: osm2pgsql Version:
Keywords: windows win32 mingw Cc:

Description

Attached is a patch to sprompt.c to fix a compile error under mingw32/msys.

I'll note that I have no clue about c development, a patch for the Makefile is also required, but is above my level to make it platform-sensitive. I did note that -lz is missing from the LDFLAGS, causing a linker error on mingw.

Attachments (2)

sprompt.c.patch (584 bytes) - added by Thomas Wood 11 years ago.
osm2pgsql_all.patches (1.8 KB) - added by Thomas Wood 11 years ago.

Download all attachments as: .zip

Change History (20)

Changed 11 years ago by Thomas Wood

Attachment: sprompt.c.patch added

comment:1 Changed 11 years ago by Tom Hughes

Owner: changed from Tom Hughes to jburgess777@…

Does windows.h really provide termios?!? That seems very unlikely...

One for Jon anyway - he knows more about this code than me.

comment:2 Changed 11 years ago by Thomas Wood

The code seemed to already have WIN32 measures in place if termios was not available, I've just removed the hard-coded termios define, which appears to work.

comment:3 Changed 11 years ago by Thomas Wood

My original compile was with pgsql 8.3 and postgis 1.3.3.

Since steve8 had only pgsql 8.2 and an older postgis, I had to recompile.

As requested by kleptog, attached is the patch file for that. Most of the changes to the Makefile are because I used the geos bundled with postgis this time around. There is one change to the headers for geos as well.

Changed 11 years ago by Thomas Wood

Attachment: osm2pgsql_all.patches added

comment:4 Changed 11 years ago by martinvoosterhout

(In [7976]) Add some changes from Edgemaster for MinGW support, see #926

comment:5 in reply to:  4 ; Changed 11 years ago by osm@…

I committed the non-makefile changes already, what's not clear to me is how much of the Makefile changes are specific to windows and how much is specific to Edgemaster's installation. Does windows really not have geos-config, for example?

comment:6 in reply to:  5 Changed 11 years ago by Thomas Wood

Replying to osm@kleptog.org:

I committed the non-makefile changes already, what's not clear to me is how much of the Makefile changes are specific to windows and how much is specific to Edgemaster's installation. Does windows really not have geos-config, for example?

I was too lazy to recompile it all, so just downloaded the headers from the source package and linked against the geos-2 bundled with PostGIS. The compile I had of 1.3 did include geos-config, so this is one of those things you should ignore.

I do reckon that quite a lot of the makefile stuff is just my local build, although I suspect the -lz requirement is a mingw thing?

I'm also not sure about geos.h and geos_c.h, the latter doesn't exist in the 1.2 headers, not sure about the former in 1.3.

comment:7 Changed 11 years ago by Thomas Wood

The -lpthreadGC2 is a Win32 implementation of pthreads (googled for it when the linker complained), not sure if it's required, since I just spotted the -DHAVE_PTHREAD flag.

comment:8 Changed 11 years ago by Tom Hughes

geos.h is correct when you're writing C++ code and linking against libgeos - if you're linking against libgeos_c then you should use geos_c.h

comment:9 in reply to:  7 Changed 11 years ago by osm@…

The pthread stuff is new for parallelizing the final index build. It would probably be easier to simply remove the HAVE_PTHREAD, the code will still work. The -lz should have been needed, no idea why the linker doesn't complain.

comment:10 Changed 11 years ago by Thomas Wood

Can makefiles contain platform-specific instructions, if not I'll just write a howto up with what to patch in the makefile (and what dependancies are required) to build under mingw.

Feel free to close this if nothing else can be done, the main codebase changes are in, which is probably the most important part.

comment:11 in reply to:  10 Changed 11 years ago by osm@…

Replying to grand.edgemaster@gmail.com:

Can makefiles contain platform-specific instructions, if not I'll just write a howto up with what to patch in the makefile (and what dependancies are required) to build under mingw.

There are a number of ways to handle this:

  • Makefiles can contains conditionals and file tests, so you can make things conditional on the existance of a file (say /dev/null) which doesn't exist on Windows.
  • You can group the different settings by system and ask people to uncomment the settings relevent for them.

What I was hoping for was Artems patch for VC which AIUI required more work. But given that it now works under MinGW perhaps that isn't important anymore. Especially if the resulting binary can be uploaded somewhere so anyone can use it.

comment:12 Changed 11 years ago by Thomas Wood

It would probably be sensible to revert the change made to applications/utils/export/osm2pgsql/build_geometry.cpp in r7976, it now breaks my build on Debian sid. I'm guessing the difference in header file was due to differing versions of geos.

comment:13 in reply to:  12 Changed 11 years ago by osm@…

Replying to grand.edgemaster@gmail.com:

It would probably be sensible to revert the change made to applications/utils/export/osm2pgsql/build_geometry.cpp in r7976, it now breaks my build on Debian sid. I'm guessing the difference in header file was due to differing versions of geos.

Please confirm your version of libgeos-dev. 2.2.3-3 is etch has both and 3.0.0 in sid has both. Or do you mean some other kind of error?

comment:14 Changed 11 years ago by emj

Keywords: windows win32 mingw added

comment:15 Changed 10 years ago by jburgess777@…

Owner: changed from jburgess777@… to jburgess777@…

comment:16 Changed 8 years ago by Tom Hughes

Component: utilsosm2pgsql

comment:17 Changed 8 years ago by amm

As anyone recently tried to compile osm2pgsql on Windows? Does it work? Can this bug be close for outdatedness?

comment:18 Changed 7 years ago by amm

Resolution: invalid
Status: newclosed

Closing this bug as outdated.

Note: See TracTickets for help on using tickets.