Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mingw Compilation Broken #71

Closed
ged opened this issue May 16, 2011 · 2 comments
Closed

Mingw Compilation Broken #71

ged opened this issue May 16, 2011 · 2 comments

Comments

@ged
Copy link
Owner

ged commented May 16, 2011

Original report by Anonymous.


Version 0.11 no longer compiles on Windows using mingw32 + mysy. Trace back is below. The issue is that the linking line is not including the correct libraries. It is possible to work around by doing this:

export CROSS_COMPILING=true

$ gem update pg --platform=ruby

Fix is easy, in the extconf.rb file check for CROSS_COMPILING or mingw or mswin.

Thanks,

Charlie


$ gem update pg --platform=ruby
Updating installed gems
Updating pg
Fetching: pg-0.11.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

        c:/MinGW/local/ruby/bin/ruby.exe extconf.rb
checking for pg_config... yes
Using config values from c:\MinGW\local\bin/pg_config.exe
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for PQsetClientEncoding()... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
creating extconf.h
creating Makefile

make
gcc -I. -I. -Ic:/MinGW/local/ruby/lib/ruby/1.8/i386-mingw32 -I. -DRUBY_EXTCONF_H=\"extconf.h\"    -Ic:/MinGW/local/include -g -O2    -c compat.c
gcc -I. -I. -Ic:/MinGW/local/ruby/lib/ruby/1.8/i386-mingw32 -I. -DRUBY_EXTCONF_H=\"extconf.h\"    -Ic:/MinGW/local/include -g -O2    -c pg.c
gcc -shared -s -o pg_ext.so compat.o pg.o -L. -Lc:/MinGW/local/ruby/lib -L.  -Lc:/MinGW/local/lib -Wl,--enable-auto-image-base,--enable-auto-import,--export-all   -lmsvcrt-ruby18 -lpq  -lshell32 -lwsock32
pg.o: In function `create_crt_fd':
c:/MinGW/local/ruby/lib/ruby/gems/1.8/gems/pg-0.11.0/ext/pg.c:2031: undefined reference to `WSADuplicateSocketA@12'
c:/MinGW/local/ruby/lib/ruby/gems/1.8/gems/pg-0.11.0/ext/pg.c:2032: undefined reference to `WSASocketA@24'
collect2: ld returned 1 exit status
make: *** [pg_ext.so] Error 1


Gem files will remain installed in c:/MinGW/local/ruby/lib/ruby/gems/1.8/gems/pg-0.11.0 for inspection.
Results logged to c:/MinGW/local/ruby/lib/ruby/gems/1.8/gems/pg-0.11.0/ext/gem_make.out
Nothing to update
@ged
Copy link
Owner Author

ged commented May 31, 2011

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


The 'CROSS_COMPILING' ENV var is for extconf.rb, for the binary Windows gem builds, so extconf already checks it. I suspect what's causing your compile to succeed is the line:

have_library( 'ws2_32', 'WSASocket') && append_library( $libs, 'ws2_32' )

which is inside that conditional. I don't know enough about about Windows programming to know if more than just that library are required, but I'll try duplicating your issue and see if adding a check for RUBY_PLATFORM =~ /mswin|mingw/ will fix it.

@ged
Copy link
Owner Author

ged commented Dec 12, 2011

Original comment by Michael Granger (Bitbucket: ged, GitHub: ged).


This should be fixed by Lars's patch: <>

@ged ged closed this as completed Dec 12, 2011
@ged ged added this to the Pending milestone Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant