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

Fix with --with-mysql-dir #952

Merged
merged 1 commit into from
Apr 7, 2018
Merged

Conversation

tmtm
Copy link
Contributor

@tmtm tmtm commented Mar 24, 2018

When gem install with --with-mysql-dir, the mysql2.so library does not link libmysqlclient.so.

% gem install mysql2 -- --with-mysql-dir=/usr/local/mysql-5.7
Building native extensions with: '--with-mysql-dir=/usr/local/mysql-5.7'
This could take a while...
Successfully installed mysql2-0.5.0
Parsing documentation for mysql2-0.5.0
Done installing documentation for mysql2 after 0 seconds
1 gem installed

% ruby -rmysql2 -e ''                                        
ruby: symbol lookup error: /home/tommy/gems25/gems/mysql2-0.5.0/lib/mysql2/mysql2.so: undefined symbol: mysql_server_init

% ldd /home/tommy/gems25/gems/mysql2-0.5.0/lib/mysql2/mysql2.so 
	linux-vdso.so.1 =>  (0x00007ffd78134000)
	libruby.so.2.5 => /home/tommy/ruby25/lib/libruby.so.2.5 (0x00007f1822b5e000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f182293f000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f182255f000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f182235b000)
	libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f1822123000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1821dcd000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f18232a0000)

@sodabrew sodabrew merged commit e30a3e0 into brianmario:master Apr 7, 2018
@sodabrew sodabrew added this to the 0.5.1 milestone Apr 7, 2018
@tmtm tmtm deleted the fix-with-mysql-dir branch April 7, 2018 09:56
jeremy added a commit to jeremy/mysql2 that referenced this pull request Mar 5, 2019
* upstream/master:
  Expose windows client authentication (brianmario#1018)
  Fix code snippet (brianmario#1002)
  Add CentOS on Travis CI. (brianmario#989)
  Bump version to 0.5.2
  Travis apt-get update for MySQL 5.5 install
  Updating the mysql2_mysql_enc_to_rb conversion table to 8.0 List (brianmario#976)
  Add default-libmysqlclient-dev to the likely packages list
  Bump version to 0.5.1
  Use the prepared statement performance schema if available (brianmario#960)
  README mysql2 0.5.x works with Rails 5.0.7, 5.1.6, and higher
  README be sure to read about the known limitations of prepared statements
  Add missing FREE_BINDS to prepared statement streaming error case (brianmario#958)
  Fix with --with-mysql-dir (brianmario#952)
  Prevent command out of sync errors with Prepared Statements (brianmario#958)
@glouton
Copy link

glouton commented Apr 10, 2020

Hi there,

I'm facing this issue with mysql2-0.5.3 when trying to install Redmine on CentOS 8.

I first install it using
$ gem install mysql2 -- --with-mysql-dir=/usr

Then uninstall the gem and set the bundle config
$ bundle config set build.mysql2 --with-mysql-lib=/usr/lib64/mysql --with-mysql-include=/usr/include/mysql
$ bundle install

In both case the installation of mysql2 went well but then this error occur
$ bundle exec rake generate_secret_token ruby /home/redmine/.rvm/gems/ruby-2.6.5/bin/rake generate_secret_token: symbol lookup error: /home/redmine/.rvm/gems/ruby-2.6.5/gems/mysql2-0.5.3/lib/mysql2/mysql2.so: undefined symbol: mysql_server_init
$ bundle exec rake db:migrate RAILS_ENV=production ruby /home/redmine/.rvm/gems/ruby-2.6.5/bin/rake db:migrate RAILS_ENV=production: symbol lookup error: /home/redmine/.rvm/gems/ruby-2.6.5/gems/mysql2-0.5.3/lib/mysql2/mysql2.so: undefined symbol: mysql_server_init

If I follow the link above it seems to say that the fix has been merged since 0.5.2 but I have 0.5.3.

Please note that I'm using MariaDB server installed with their repository.

Regards,

@glouton
Copy link

glouton commented Apr 10, 2020

PS :
$ ldd /home/redmine/.rvm/gems/ruby-2.6.5/gems/mysql2-0.5.3/lib/mysql2/mysql2.so
linux-vdso.so.1 (0x00007ffd48794000)
libruby.so.2.6 => /home/redmine/.rvm/rubies/ruby-2.6.5/lib/libruby.so.2.6 (0x00007fbb55af5000)
libm.so.6 => /lib64/libm.so.6 (0x00007fbb55773000)
libc.so.6 => /lib64/libc.so.6 (0x00007fbb553b0000)
libz.so.1 => /lib64/libz.so.1 (0x00007fbb55199000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fbb54f79000)
librt.so.1 => /lib64/librt.so.1 (0x00007fbb54d70000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fbb54b6c000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fbb54943000)
/lib64/ld-linux-x86-64.so.2 (0x00007fbb56266000)

@sodabrew
Copy link
Collaborator

sodabrew commented Apr 10, 2020

@glouton 1. Please open a new issue. 2. I don't follow why you're using any config options at all. Your libraries are in a standard location. The build auto-detects standard locations by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants