I'm attempting to compile the ruby-shaplib extensions on windows. I've compiled Python-shapelib extensions, but I'd like to move to Ruby.
I'm having difficulty compiling the extensions. I've copied the shapelib source to the directory containing the ruby-shapelib extensions, so all the source files are in the same directory.
I've kicked-off the extconf.rb script, but it complains that it cannot find shapefil.h file.
C:\builds\work\rubysl>ruby ./extconf.rb
checking for shapefil.h... no
./extconf.rb:5: shapefil.h not found (RuntimeError)
That file is in the same directory and should be found. If I comment out the two lines that try to validate that files exist, extconf.rb will create the makefile.
If I run the make file with mingw-make, I receive a bunch of errors.
C:\builds\work\rubysl>mingw32-make.exe
makefile:130: warning: overriding commands for target `{.}.C{}.obj'
makefile:124: warning: ignoring old commands for target `{.}.C{}.obj'
makefile:133: warning: overriding commands for target `.C.obj'
makefile:127: warning: ignoring old commands for target `.C.obj'
cl -nologo -MD -Zi -O2b2xg- -G6 -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -Ic:/ru
by/lib/ruby/1.8/i386-mswin32 -I. -I. -I./.. -I./../missing -c -Tcdbfadd.c
process_begin: CreateProcess((null), cl -nologo -MD -Zi -O2b2xg- -G6 -I. -Ic:/ru
by/lib/ruby/1.8/i386-mswin32 -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -I. -I. -I./..
-I./../missing -c -Tcdbfadd.c, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make.exe: *** [dbfadd.obj] Error 2
I have a feeling this error has to do with the location of the shapelib source. Where should I place the shapelib source in relation to the ruby-shapelib source? I've followed all the instructions in the readme, but I still receive errors.
Any ideas?
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is that extconf.rb of ruby-shapelib assumes that shapelib is installed as libshp.a.
I didn't know that Makefile of shapelib doesn't work well on Windows, but it can be easily fixed.
Here is the procedure.
* get shapelib-1.2.10.tar.gz from maptools.org.
* extract it
(assume you are at, say, /tmp)
$ cd shapelib-1.2.10
$ make
$ make shptree.o
$ ar cru libshp.a shpopen.o shptree.o dbfopen.o
* extract ruby-shapelib-0.6.tar.gz
and cd into ruby-shapelib-0.6
I tried this (on a linux machine) and it gave me the following errors:
$ ruby extconf.rb --with-shapelib-lib=../shapelib-1.2.10/ --with-shapelib-include=../shapelib-1.2.10/
checking for shapefil.h... yes
checking for main() in -lshp... yes
creating Makefile
$ make
gcc -fPIC -Wall -g -fno-strict-aliasing -O2 -fPIC -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -DHAVE_SHAPEFIL_H -I../shapelib-1.2.10/ -c main.c
In file included from main.c:35:
valconv.h:16: error: 'FTLogical' undeclared here (not in a function)
valconv.h: In function 'FieldTypeNameTable':
valconv.h:52: error: array subscript is not an integer
valconv.h:52: warning: statement with no effect
make: *** [main.o] Error 1
-Thomas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The error message indicates that there is no definition of the name FTLogical which should be written in shapefil.h given by shapelib. Try following steps:
1. find where shapefil.h is. In your example, that should be ../shapelib-1.2.10/shapelib.h.
2. look at that file. is there anything like following?
3. if there is not, that is the problem.
4. if there is, that's weird. maybe there is older version of shapelib installed, but I believe -I option overrides that....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had the same "ubygems" problem.
That was caused by RUBYOPT environment variable.
$ echo $RUBYOPT
-rubygems
That causes the ruby interpreter to load rubygems library which is not installed on my (and probably
your) Cygwin.
There are two ways to solve the problem. One is to change the environment variable, probably writing something like "RUBYOPT=" in .bash_profile. The other is to install rubygems. If you are not using rubygems, that may be empty file:
$ touch /usr/lib/ruby/site_ruby/1.8/ubygems.rb
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I added C:\Cygwin\bin to my path and opened a Windows Command Prompt, since Rails is installed in my normal Windows environment, as opposed to Cygwin. When I try to run I get this error, though.
I'm attempting to compile the ruby-shaplib extensions on windows. I've compiled Python-shapelib extensions, but I'd like to move to Ruby.
I'm having difficulty compiling the extensions. I've copied the shapelib source to the directory containing the ruby-shapelib extensions, so all the source files are in the same directory.
I've kicked-off the extconf.rb script, but it complains that it cannot find shapefil.h file.
C:\builds\work\rubysl>ruby ./extconf.rb
checking for shapefil.h... no
./extconf.rb:5: shapefil.h not found (RuntimeError)
That file is in the same directory and should be found. If I comment out the two lines that try to validate that files exist, extconf.rb will create the makefile.
If I run the make file with mingw-make, I receive a bunch of errors.
C:\builds\work\rubysl>mingw32-make.exe
makefile:130: warning: overriding commands for target `{.}.C{}.obj'
makefile:124: warning: ignoring old commands for target `{.}.C{}.obj'
makefile:133: warning: overriding commands for target `.C.obj'
makefile:127: warning: ignoring old commands for target `.C.obj'
cl -nologo -MD -Zi -O2b2xg- -G6 -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -Ic:/ru
by/lib/ruby/1.8/i386-mswin32 -I. -I. -I./.. -I./../missing -c -Tcdbfadd.c
process_begin: CreateProcess((null), cl -nologo -MD -Zi -O2b2xg- -G6 -I. -Ic:/ru
by/lib/ruby/1.8/i386-mswin32 -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -I. -I. -I./..
-I./../missing -c -Tcdbfadd.c, ...) failed.
make (e=2): The system cannot find the file specified.
mingw32-make.exe: *** [dbfadd.obj] Error 2
I have a feeling this error has to do with the location of the shapelib source. Where should I place the shapelib source in relation to the ruby-shapelib source? I've followed all the instructions in the readme, but I still receive errors.
Any ideas?
Thanks.
Denny,
Thank you for reporting problem and sorry for late response. I'm afraid I don't have good Windows environment to test it right now.
My idea is to try to specify
--with-opt-include=C:\blah\blah...
when involing extconf.rb.
(It is described in mkmf documentation
http://www.ruby-lang.org/ja/man/?cmd=view;name=mkmf\).
Thank you very much if you could report the result,
prasinos
Hi, I have the same problem and adding the parameter doesnt seem to change anything.
Is there anything I could try?
Thanks,
Daniel Presgrave
also, do you hink Cygwin would help?
I've compiled ruby-shapelib on Cygwin.
The problem is that extconf.rb of ruby-shapelib assumes that shapelib is installed as libshp.a.
I didn't know that Makefile of shapelib doesn't work well on Windows, but it can be easily fixed.
Here is the procedure.
* get shapelib-1.2.10.tar.gz from maptools.org.
* extract it
(assume you are at, say, /tmp)
$ cd shapelib-1.2.10
$ make
$ make shptree.o
$ ar cru libshp.a shpopen.o shptree.o dbfopen.o
* extract ruby-shapelib-0.6.tar.gz
and cd into ruby-shapelib-0.6
$ ruby extconf.rb
--with-shapelib-lib=/tmp/shapelib-1.2.10
--with-shapelib-include=/tmp/shapelib-1.2.10
prasinos
I tried this (on a linux machine) and it gave me the following errors:
$ ruby extconf.rb --with-shapelib-lib=../shapelib-1.2.10/ --with-shapelib-include=../shapelib-1.2.10/
checking for shapefil.h... yes
checking for main() in -lshp... yes
creating Makefile
$ make
gcc -fPIC -Wall -g -fno-strict-aliasing -O2 -fPIC -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I. -DHAVE_SHAPEFIL_H -I../shapelib-1.2.10/ -c main.c
In file included from main.c:35:
valconv.h:16: error: 'FTLogical' undeclared here (not in a function)
valconv.h: In function 'FieldTypeNameTable':
valconv.h:52: error: array subscript is not an integer
valconv.h:52: warning: statement with no effect
make: *** [main.o] Error 1
-Thomas
Thanks for your interest on ruby-shapelib.
Sorry I don't have enough time this week to examine.
Hopefully I'll test it saturday.
Regards,
prasinos
Hello,
The error message indicates that there is no definition of the name FTLogical which should be written in shapefil.h given by shapelib. Try following steps:
1. find where shapefil.h is. In your example, that should be ../shapelib-1.2.10/shapelib.h.
2. look at that file. is there anything like following?
typedef enum {
FTString,
FTInteger,
FTDouble,
FTLogical,
FTInvalid
} DBFFieldType;
3. if there is not, that is the problem.
4. if there is, that's weird. maybe there is older version of shapelib installed, but I believe -I option overrides that....
Thanks!
I still have aproblem, though:
when I try to run ruby extconf.rb as above I get:
ruby: no such file to load -- ubygems (Load Error)
Any ideas?
I had the same "ubygems" problem.
That was caused by RUBYOPT environment variable.
$ echo $RUBYOPT
-rubygems
That causes the ruby interpreter to load rubygems library which is not installed on my (and probably
your) Cygwin.
There are two ways to solve the problem. One is to change the environment variable, probably writing something like "RUBYOPT=" in .bash_profile. The other is to install rubygems. If you are not using rubygems, that may be empty file:
$ touch /usr/lib/ruby/site_ruby/1.8/ubygems.rb
thanks, everything compiles perfectly.
I added C:\Cygwin\bin to my path and opened a Windows Command Prompt, since Rails is installed in my normal Windows environment, as opposed to Cygwin. When I try to run I get this error, though.
C:\ruby>ruby import_script\importshp2mysql\import_shp_mysql.rb zt01_d00.shp
142 [main] ? (2760) c:\ruby\bin\ruby.exe: *** fatal error - c:\ruby\bin\r
.exe: *** Incompatible cygwin .dll -- incompatible per_process info 0 != 168
Thank you so much for all the help