rails-sqlserver / tiny_tds

TinyTDS - Simple and fast FreeTDS bindings for Ruby using DB-Library.
Other
607 stars 189 forks source link

tiny_tds fails compiling with "libiconv is missing" error #157

Closed fchampreux closed 10 years ago

fchampreux commented 10 years ago

Hi, I installed Ruby 2.0.0 on Windows x64 from rubyinstaller-2.0.0-p451-x64.exe Then DevKit from DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe ThenI tried to gem install tiny_tds, with no success. So I also installed libiconv-1.9.2-1.exe, then run gem install tiny_tds again: no success I tried to specify the path to libiconv: gem install tiny_tds -- --with-iconv-dir=e:/gnuwin32 with no success Looking at the mkmf.log, it searches in the correct directory, but functions returns errors:

"x86_64-w64-mingw32-gcc -o conftest.exe -IE:/Ruby200/include/ruby-2.0.0/x64-mingw32 -IE:/Ruby200/include/ruby-2.0.0/ruby/backward -IE:/Ruby200/include/ruby-2.0.0 -I. -IE:/DevKit/include -IE:/DevKit/mingw/include -IE:/Ruby200/include -Ie:/gnuwin32/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  conftest.c  -L. -LE:/Ruby200/lib -LE:/DevKit/lib -LE:/DevKit/mingw/lib -LE:/Ruby200/lib -Le:/git/lib -Le:/gnuwin32/ -L.       -lx64-msvcrt-ruby200  -lshell32 -lws2_32 -limagehlp -lshlwapi   "
conftest.c: In function 't':
conftest.c:9:32: warning: variable 'p' set but not used [-Wunused-but-set-variable]
C:\Users\ADMINI~1\AppData\Local\Temp\cccAutis.o: In function `t':
E:\Ruby200\lib\ruby\gems\2.0.0\gems\tiny_tds-0.6.1\ext\tiny_tds/conftest.c:9: undefined reference to `__imp_libiconv_open'
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: #include <winsock2.h>
 4: #include <windows.h>
 5: #include <iconv.h>
 6: 
 7: /*top*/
 8: extern int t(void);
 9: int t(void) { void ((*volatile p)()); p = (void ((*)()))iconv_open; return 0; }
10: int main(int argc, char **argv)
11: {
12:   if (argc > 1000000) {
13:     printf("%p", &t);
14:   }
15: 
16:   return 0;
17: }
/* end */

Your help will be highly appreciated !

Thanks,

Fred

wbond commented 10 years ago

From my recent experience, using --with-iconv-dir doesn't necessarily work. I had to use --with-iconv-include and --with-iconv-lib.

wbond commented 10 years ago

The fork we maintain has instructions and updates on how to get the gems for Windows to compile. https://github.com/veracross/tiny_tds#compiling-gems-for-windows

fchampreux commented 10 years ago

Thanks a lot Will, I'll try this next Monday ! Is it supposed to work with both Ruby x32 and Ruby x64 on Windows x64 ? Best regards, Fred

2014-05-02 16:46 GMT+02:00 Will Bond notifications@github.com:

The fork we maintain has instructions and updates on how to get the gems for Windows to compile. https://github.com/veracross/tiny_tds#compiling-gems-for-windows

— Reply to this email directly or view it on GitHubhttps://github.com/rails-sqlserver/tiny_tds/issues/157#issuecomment-42039363 .

Frédéric CHAMPREUX+41 78 87 110 55

wbond commented 10 years ago

FYI, I just did a release with a bunch of pending pull requests at https://github.com/veracross/tiny_tds/releases/tag/0.6.2-beta1. Could you test this version and let me know how it works for you?

fchampreux commented 10 years ago

Hi Will,

I'll do some testing in the afternoon today, and may be evening if necessary ...

Best regards

Fred

2014-05-04 18:12 GMT+02:00 Will Bond notifications@github.com:

FYI, I just did a release with a bunch of pending pull requests at https://github.com/veracross/tiny_tds/releases/tag/0.6.2-beta1. Could you test this version and let me know how it works for you?

— Reply to this email directly or view it on GitHubhttps://github.com/rails-sqlserver/tiny_tds/issues/157#issuecomment-42136728 .

Frédéric CHAMPREUX+41 78 87 110 55

fchampreux commented 10 years ago

Hi Will,

Here is the place where I stand at the moment. Tiny_tds installed correctly, but I did not test it. Do you have a test procedure at this point ? Please take a look at the screenshots, and let me know if I can go on with the warnings and configuration as is. Thanks a lot,

Fred

2014-05-05 10:16 GMT+02:00 Frédéric Champreux fchampreux@gmail.com:

Hi Will,

I'll do some testing in the afternoon today, and may be evening if necessary ...

Best regards

Fred

2014-05-04 18:12 GMT+02:00 Will Bond notifications@github.com:

FYI, I just did a release with a bunch of pending pull requests at

https://github.com/veracross/tiny_tds/releases/tag/0.6.2-beta1. Could you test this version and let me know how it works for you?

— Reply to this email directly or view it on GitHubhttps://github.com/rails-sqlserver/tiny_tds/issues/157#issuecomment-42136728 .

Frédéric CHAMPREUX+41 78 87 110 55 <%2B41%2078%2087%20110%2055>

Frédéric CHAMPREUX+41 78 87 110 55

wbond commented 10 years ago

@fchampreux There is a test suite, but it would require you setting up a database called tinytdstest and a login named tinytds that does not have a password that is dbowner of tinytdstest.

Alternatively you can just let me know if your application seems to be working alright with it. I basically just want to make sure people don't hit any obvious issues with it. I ran the tests on OS X and Windows and we seem to be in pretty good shape.

fchampreux commented 10 years ago

Hi Will,

Rails fails starting with this message:

E:\demo>rails server e:/Ruby200/lib/ruby/gems/2.0.0/gems/tiny_tds-0.6.1-x86-mingw32/lib/tiny_tds.rb:1 6:in `require': 126: The specified module could not be found. - e:/Ruby200/lib /ruby/gems/2.0.0/gems/tiny_tds-0.6.1-x86-mingw32/lib/tiny_tds/tiny_tds.so (LoadE rror)

I Installed Tiny_TDS fine, as of yesterday: E:>gem install tiny_tds-0.6.2.pre.beta1-x64-mingw32.gem Successfully installed tiny_tds-0.6.2.pre.beta1-x64-mingw32 Parsing documentation for tiny_tds-0.6.2.pre.beta1-x64-mingw32 Done installing documentation for tiny_tds after 0 seconds 1 gem installed

Then I installed Rails 4.0.0, which supports my application: successful

Then I updated the gemfile with: gem 'tiny_tds' gem 'activerecord-sqlserver-adapter', '~> 4.0.0', :git => "git:// github.com/rails-sqlserver/activerecord-sqlserver-adapter.git"

Run bundle install successfully, but as shown above, rails server command fails.

Investigating, I now have 2 versions of the gem: E:\Ruby200\lib\ruby\gems\2.0.0\gems\tiny_tds-0.6.1-x86-mingw32 E:\Ruby200\lib\ruby\gems\2.0.0\gems\tiny_tds-0.6.2.pre.beta1-x64-mingw32

So I uninstalled tiny_tds-0.6.1-x86-mingw32 and updated the gemfile with : gem 'tiny_tds', '~> 0.6.2', :git => "git://github.com/veracross/tiny_tds.git " gem 'activerecord-sqlserver-adapter', '~> 4.0.0', :git => "git:// github.com/rails-sqlserver/activerecord-sqlserver-adapter.git"

I delete the gemfile.lock, run bundle install which fails with: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

e:/Ruby200/bin/ruby.exe extconf.rb

checking for iconv_open() in iconv.h... no

checking for iconv_open() in -liconv... no

libiconv is missing.

* extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

... some options listed ...

Gem files will remain installed in e:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/t iny_tds-763704bfe0ce for inspection. Results logged to e:/Ruby200/lib/ruby/gems/2.0.0/bundler/gems/extensions/x86-min gw32/2.0.0/tiny_tds-763704bfe0ce/gem_make.out An error occurred while installing tiny_tds (0.6.2), and Bundler cannot continue.

It looks like there is a mix up between x86 and x64. Attached is mkmf.log

As I am new at Ruby, I probably made a mistake, and I'd be glad if you can explain me how to finish up the installation or configuration.

Thanks a lot,

Best regards,

Fred

2014-05-05 18:55 GMT+02:00 Will Bond notifications@github.com:

@fchampreux https://github.com/fchampreux There is a test suite, but it would require you setting up a database called tinytdstest and a login named tinytds that does not have a password that is dbowner of tinytdstest .

Alternatively you can just let me know if your application seems to be working alright with it. I basically just want to make sure people don't hit any obvious issues with it. I ran the tests on OS X and Windows and we seem to be in pretty good shape.

— Reply to this email directly or view it on GitHubhttps://github.com/rails-sqlserver/tiny_tds/issues/157#issuecomment-42209832 .

Frédéric CHAMPREUX+41 78 87 110 55

metaskills commented 10 years ago

@wbond Are those gem downloads using this (https://github.com/veracross/tiny_tds/blob/master/lib/tiny_tds/version.rb) 0.6.2 version? If so, your pre distributions may be causing the problem. I recommend release real 0.6.2.rc1 version that changes the version file and published to rubygems. That way @fchampreux can install and use via normal conventions.

wbond commented 10 years ago

I just pushed 0.6.2 to rubygems, so you should be able to use that now. Feel free to open a new issue if you run into bugs with 0.6.2.

fchampreux commented 10 years ago

Hi Will,

I finally found some time to implement the recommended versions of the gems. It went straight forward and works perfectly. Great job ! Thanks a lot for your help !

Best regards,

Fred

2014-05-19 18:58 GMT+02:00 Will Bond notifications@github.com:

I just pushed 0.6.2 to rubygems, so you should be able to use that now. Feel free to open a new issue if you run into bugs with 0.6.2.

— Reply to this email directly or view it on GitHub https://github.com/rails-sqlserver/tiny_tds/issues/157#issuecomment-43529339 .

Frédéric CHAMPREUX+41 78 87 110 55

ryan-mars commented 10 years ago

I'm running into this problem (missing libiconv) with 0.6.2. gem install tiny_tds produces the same error @fchampreux was reporting at the top of this thread. This is on Microsoft Windows Server 2012 R2 Standard with ruby 2.1.3p242 (2014-09-19 revision 47630) [x64-mingw32] from Ruby Installer

I've tried installing MinGW by hand as well, that didn't seem to make a difference either. I've tried specifying 0.6.2 to make sure I'm not getting an old version I also installed Cygwin to get libiconv but I think that only provides libiconv to bash.

Here's the full output if it helps: https://gist.github.com/ryanwmarsh/bdd26d6dbd0f450ce792

fchampreux commented 10 years ago

Hi Will, My windows machine has been sleeping for a time. I'll wake it up on the week-end to test this. Best regards, Fred Le 4 mai 2014 18:12, "Will Bond" notifications@github.com a écrit :

FYI, I just did a release with a bunch of pending pull requests at https://github.com/veracross/tiny_tds/releases/tag/0.6.2-beta1. Could you test this version and let me know how it works for you?

— Reply to this email directly or view it on GitHub https://github.com/rails-sqlserver/tiny_tds/issues/157#issuecomment-42136728 .

ryan-mars commented 10 years ago

Thanks. I tried out Ruby 2.0.0 and it worked fine. It must be something to do with 2.1 and might not have anything to do with tiny_tds. I did notice however that 2.0.0 didn't seem to compile any extensions. It just downloaded and was done. I tested it and it could query the DB. Are there such things as gems with binary distributions of the extensions?=

wbond commented 10 years ago

@fchampreux 0.6.2 was released a while ago.

@ryanwmarsh Yes, for windows tiny_tds ships with precompiled binaries since getting the compilation environment set up properly is kind of a pain. I don't think we ship binaries for Ruby 2.1 since there is no Ruby 2.1 for Windows unless you compile it all yourself. My memory could be wrong on this since I no longer work with SQL Server.

ryan-mars commented 10 years ago

@wbond Ok, that makes plenty of sense. Ruby 2.1 is now available via the RubyInstaller so if you could please build the binaries that would be awesome. Until then I'll run on 2.0

wbond commented 10 years ago

@ryanwmarsh I just looked and the gems on rubygems should work with Ruby 2.1.

The instructions for compiling for Windows are available at https://github.com/rails-sqlserver/tiny_tds#compiling-gems-for-windows. When I was at my previous company I spent a bunch of time getting that all working consistently.

ghost commented 9 years ago

0.6.3rc1 and ":github => 'rails-sqlserver/tiny_tds', :branch => 'master'" doesn't work with rubyinstaller 2.1 on Windows 8.1.

Please help. :dancer:

Thanks.

larskanis commented 9 years ago

@ginolon Check out https://github.com/rails-sqlserver/tiny_tds/pull/207 :

git clone https://github.com/larskanis/tiny_tds.git
cd tiny_tds
git checkout rake-compiler-dock
rake gem
gem inst pkg/tiny_tds-0.6.3.rc1.gem

This should download and install all dependencies. And it should equally work per Gemfile.

dharmdip commented 9 years ago

Keep getting this error for this command, provided proper path as well.

I am doing this on windows 2012 R2 servers.

Ruby : ruby 2.1.6p336 (2015-04-13 revision 50298) [x64-mingw32]

gem install tiny_tds --pre --no-ri --no-rdoc -- --with-freetds-include=C:\freetds-0.95rc2\include --with-freetds-lib=C:\freetds-0.95rc2\lib --with-iconv-include=C:\Utility\libiconv-1.9.2\include --with-iconv-lib=C:\Utility\libiconv-1.9.2\lib

ERROR: Error installing tiny_tds: ERROR: Failed to build gem native extension.

checking for iconv_open() in iconv.h... no checking for iconv_open() in -liconv... no

libiconv is missing.

Thanks, Dharmdip

metaskills commented 9 years ago

This will be solved when #207 is done.

dharmdip commented 9 years ago

Thank you.

Okay, that's great.. i surpass this error but while custom build i checked this code.

FREETDS_VERSION_INFO = Hash.new { |h,k|
  h[k] = {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-#{k}.tar.gz"}
}.merge({
  "0.82" => {:files => "ftp://ftp.freetds.org/pub/freetds/old/0.82/freetds-0.82.tar.gz"},
  "0.91" => {:files => "ftp://ftp.freetds.org/pub/freetds/stable/freetds-0.91.112.tar.gz"},
  "current" => {:files => "ftp://ftp.freetds.org/pub/freetds/current/freetds-current.tar.gz"}
})

source is no longer available and it is moved to git.

metaskills commented 9 years ago

I knew the code is on GitHub. Are you telling me the FTP site is down intentionally? I did not think FreeTDS' github mirror was even tagged properly for releases?

dharmdip commented 9 years ago

yes, FTP is down.

metaskills commented 9 years ago

FTP is down.

I knew that. See #207. It has happened before and just waiting for it to come back up.

dharmdip commented 9 years ago

oh ! okay.. because libiconv and openssl works fine and i was keep getting error for this. I have changed in code and point to the Git for testing.

metaskills commented 9 years ago

That's good, but we can not use GitHub because they do not tag versions there. Thanks tho!

dharmdip commented 9 years ago

Yes true. Thank you, for your valuable time. I am going to test against different versions.

dharmdip commented 9 years ago

Hi @metaskills,

i am getting this error while connecting, any thought?

tiny_tds-0.6.3.rc2-x64-mingw32/lib/tiny_tds/client.rb:74:inconnect': Write to the server failed (TinyTds::Error)

Thanks, Dharmdip