faye / websocket-driver-ruby

WebSocket protocol handler with pluggable I/O
Other
223 stars 43 forks source link

Fails to build on Ubuntu 22.04 #92

Closed soapergem closed 2 months ago

soapergem commented 2 months ago

I am trying to run gem install websocket-driver on my Ubuntu 22.04 machine. This is a legit Ubuntu machine and not Windows/WSL. However I immediately get the following errors:

make DESTDIR\= sitearchdir\=./.gem.20240906-1154250-rn0ift sitelibdir\=./.gem.20240906-1154250-rn0ift
compiling websocket_mask.c
gcc: error: unrecognized command-line option ‘-fdeclspec’
gcc: error: unrecognized command-line option ‘-Wextra-tokens’; did you mean ‘-Wextra-semi’?
gcc: error: unrecognized command-line option ‘-Wdivision-by-zero’; did you mean ‘-Wdiv-by-zero’?
gcc: error: unrecognized command-line option ‘-Wshorten-64-to-32’
make: *** [Makefile:248: websocket_mask.o] Error 1

make failed, exit code 2

If I run gcc --version it reports that I have version 11.4.0 installed. I also have the build-essential package already installed, too. Any advice?

jcoglan commented 2 months ago

I'm not able to reproduce this problem using the same versions of Ubuntu and gcc. You might have more success asking the ruby mailing list if you're having trouble compiling native extensions. This library's extconf.rb doesn't do anything fancy, it makes very basic use of the Ruby mkmf library.

soapergem commented 2 months ago

Thanks for responding. I sent a message to the ruby-talk mailing list but have yet to hear back. But in the meantime I found a working solution. I did a lot of Googling and eventually came across this StackOverflow post (which has nothing to do with Ruby), but I tried out the recommended fix which seemed to work in my scenario as well. BasicallyI had to run these three commands:

sudo apt-get install clang
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

I'm not sure why that was necessary, but I'm posting it here in case anybody else runs into a similar issue down the line.