zzzzxl

当我更换 mac m2 芯片 无法使用使用 mysql2 报错 symbol not found in flat namespace (_mysql_affected_rows)

  •  
  •   zzzzxl · Sep 3, 2022 · 6624 views
    This topic created in 1347 days ago, the information mentioned may be changed or developed.

    Rails 版本 7.0.3

    MySQL 版本 5.7.29

    Ruby 版本 3.1.1

    Rvm 版本 1.29.12

    mysql2 版本 ~> 0.5

    我的项目正在尝试迁移 m2 芯片,当我尝试运行rails s时 出现了以下错误

    `require': dlopen(/Users/list/.rvm/rubies/ruby-3.1.1/lib/ruby/gems/3.1.0/gems/mysql2-0.5.4/lib/mysql2/mysql2.bundle, 0x0009): symbol not found in flat namespace (_mysql_affected_rows)
    

    我尝试过以下解决方案,都不能解决

    bundle config build.mysql2 "--with-ldflags=-L/usr/local/mysql/lib --with-cppflags=-I/usr/local/mysql/include"
    
     gem install mysql2 -v '0.5' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-ldflags="-L/usr/local/mysql/lib -L$(brew --prefix openssl)/lib" --with-cppflags=-I$(brew --prefix openssl)/include
    

    请问如何解决这个问题?

    2 replies    2022-09-03 10:49:19 +08:00
    cxh116
        2
    cxh116  
       Sep 3, 2022 via Android   ❤️ 1
    --with-ldflags=-L/usr/local/mysql/lib --with-cppflags=-I/usr/local/mysql/include"


    这里的目录不对,要你安装的 mysql 5.7 的头文件目录,你用 brew 安装完时应该有提示,或 brew info package_name 也可以看到。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1172 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 23:10 · PVG 07:10 · LAX 16:10 · JFK 19:10
    ♥ Do have faith in what you're doing.