kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 75 forks source link

Problems during compilation on cygwin 32bit #113

Closed tomasjura closed 8 years ago

tomasjura commented 8 years ago

I had problems is during compiling and linking plthook_win32.c. A command gem install ruby-oci8 was used for installation.

Patch:

--- ext/oci8/extconf.rb.old  2015-12-16 11:09:41.030091800 +0100
+++ ext/oci8/extconf.rb 2015-12-16 11:06:31.179893500 +0100
@@ -143,6 +183,13 @@
   raise 'unsupported ruby engine: ' + RUBY_ENGINE
 end

+case RUBY_PLATFORM
+when /mswin32|cygwin|mingw32|bccwin32/
+  have_func('stricmp', 'string.h')
+  have_func('strcasecmp', 'string.h')
+  have_library('dbghelp','ImageDirectoryEntryToData',['windows.h','dbghelp.h'])
+end
+
 print "checking for plthook... "
 STDOUT.flush
 case RUBY_PLATFORM
--- ext/oci8/plthook_win32.c.old     2015-12-16 11:09:41.123693600 +0100
+++ ext/oci8/plthook_win32.c       2015-12-16 11:06:31.179893500 +0100

@@ -39,6 +39,8 @@
 #include <windows.h>
 #include <dbghelp.h>
 #include "plthook.h"
+#include <string.h>
+#include "extconf.h"

 #ifdef _MSC_VER
 #pragma comment(lib, "dbghelp.lib")
@@ -57,6 +59,12 @@
 #define SIZE_T_FMT "u"
 #endif

+#ifndef HAVE_STRICMP
+#ifdef HAVE_STRCASECMP
+#define stricmp strcasecmp
+#endif
+#endif
+
 typedef struct {
     const char *mod_name;
     const char *name;
tomasjura commented 8 years ago

One more patch to compile on cygwin.

--- ext/oci8/oraconf.rb.old     2015-12-16 12:15:04.256368800 +0100
+++ ext/oci8/oraconf.rb 2015-12-16 12:15:07.158024600 +0100
@@ -713,7 +713,7 @@
           f.puts("EXPORTS")
           open("|nm #{lib_dir}/MSVC/OCI.LIB") do |r|
             while line = r.gets
-              f.puts($1) if regex =~ line and oci_funcs.include?($1)
+              f.puts($1) if regex =~ line
             end
           end
         end
kubo commented 8 years ago

Thank you! I'll check it later.

kubo commented 8 years ago

I fixed it by 936071ca28f4eb620d58116e523b4ac2109526fb, 677ab253fffa249590646436a3dd33b2122dbf5e and 5571da4084396f9c8567951de8ca4f2b5cb783a4.

Thanks again.

5571da4084396f9c8567951de8ca4f2b5cb783a4 uses _LP64 to decide the printf format of size_t on cygwin 64 because it is safer when the code snippet is reused. FIY _WIN64 is not defined without including windows.h on cygwin 64 though it is included there.