Skip to content

Instantly share code, notes, and snippets.

@larskanis
Created January 12, 2018 09:09
Show Gist options
  • Save larskanis/503f0a24af6ee871a8666c6e3a037487 to your computer and use it in GitHub Desktop.
Save larskanis/503f0a24af6ee871a8666c6e3a037487 to your computer and use it in GitHub Desktop.
Fix ruby-odbc on Ruby-2.4 and MINGW
From 53fe2f8c992c28d57b19733723ce43f260376eac Mon Sep 17 00:00:00 2001
From: Lars Kanis <[email protected]>
Date: Wed, 6 Dec 2017 08:53:24 +0100
Subject: [PATCH] Fix Ruby-2.4 MINGW build
Since the following commit to Ruby-2.4, have_library() with an empty function
is no longer treated as "main()". Therefore
"gem install ruby-odbc -v 0.99998" fails on RubyInstaller-2.4 currently.
https://github.com/ruby/ruby/commit/6ff3a8e3bb6c6cf25c134300ebf9877907d739c1
Calling have_library() with one argument fixes this issue.
Calling have_library() with the desired function name as second parameter,
works with RubyInstaller-2.4, but fails on older versions, so that it's
probably best to omit the function name.
The patch has been tested on RubyInstaller-2.0, 2.2, 2.3 and 2.4 and on both
i386 and x86_64.
---
ext/extconf.rb | 6 +++---
ext/utf8/extconf.rb | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/ext/extconf.rb b/ext/extconf.rb
index 5e7023c..eb35b6f 100644
--- a/ext/extconf.rb
+++ b/ext/extconf.rb
@@ -124,9 +124,9 @@ if PLATFORM =~ /mswin32/ then
have_func("SQLInstallerError", "odbcinst.h")
# mingw untested !!!
elsif PLATFORM =~ /(mingw|cygwin)/ then
- have_library("odbc32", "")
- have_library("odbccp32", "")
- have_library("user32", "")
+ have_library("odbc32")
+ have_library("odbccp32")
+ have_library("user32")
elsif (testdlopen && PLATFORM !~ /(macos|darwin)/ && CONFIG["CC"] =~ /gcc/ && have_func("dlopen", "dlfcn.h") && have_library("dl", "dlopen")) then
$LDFLAGS+=" -Wl,-init -Wl,ruby_odbc_init -Wl,-fini -Wl,ruby_odbc_fini"
$CPPFLAGS+=" -DHAVE_SQLCONFIGDATASOURCE"
diff --git a/ext/utf8/extconf.rb b/ext/utf8/extconf.rb
index 344329f..aa99196 100644
--- a/ext/utf8/extconf.rb
+++ b/ext/utf8/extconf.rb
@@ -113,9 +113,9 @@ if PLATFORM =~ /mswin32/ then
have_func("SQLInstallerError", "odbcinst.h")
have_func("SQLInstallerErrorW", "odbcinst.h")
elsif PLATFORM =~ /(mingw|cygwin)/ then
- have_library("odbc32", "")
- have_library("odbccp32", "")
- have_library("user32", "")
+ have_library("odbc32")
+ have_library("odbccp32")
+ have_library("user32")
header = ["windows.h", "odbcinst.h"]
have_func("SQLConfigDataSourceW", header)
have_func("SQLWriteFileDSNW", header)
--
2.6.2.windows.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment