【问题标题】:G++ wrong ELF CLASS ErrorG++ 错误 ELF CLASS 错误
【发布时间】:2011-07-24 20:13:22
【问题描述】:

我试图在 Fedora 15 x64 上编译 C++ 程序。并得到了错误:

./game: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory.

我在某处读到我需要做的就是安装glibc.i686

我安装了它,现在即使在 g++ 中使用“-m64”选项后也会出现另一个错误

error while loading shared libraries: libplayer_1.so: wrong ELF class: ELFCLASS64

这是我的 makefile 的样子:

CONC_INC = ./include \
            -I../include
APP = ./src/player_1.cxx


All :  
    g++ -m64 -Wall -g -fPIC -I$(CONC_INC) -c $(APP)
    g++ -m64 -shared -W1 -o libplayer1.so.1.0 *.o
    cp libplayer1.so.1.0 ../lib/libplayer_1.so.1.0
    ln -sf ../lib/libplayer_1.so.1.0 ../lib/libplayer_1.so
    ln -sf ../lib/libplayer_1.so.1.0 ../lib/libplayer_1.so.1
clean: 
    \rm -f *.so.* *.o

【问题讨论】:

    标签: c++ gcc g++ makefile


    【解决方案1】:

    您的原始问题表明./game 是一个 32 位动态链接的可执行文件,由于未安装 32 位动态链接器 (/lib/ld-linux.so.2) 而无法运行;安装 32 位 glibc 包解决了这个问题。

    如果 ./game 是一个 32 位可执行文件,需要将 libplayer_1.so 作为动态库,那么如果 libplayer_1.so 是 64 位,它将无法工作,这就是新错误告诉您的内容。

    尝试将库构建为 32 位(-m32 而不是 -m64)。

    【讨论】:

      猜你喜欢
      • 2010-09-17
      • 2016-05-11
      • 2011-09-04
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      • 2022-01-18
      • 2012-03-23
      • 1970-01-01
      相关资源
      最近更新 更多