c++ - make 命令给出不兼容的 i386 架构(i386x86-64)

标签 c++ linux makefile

我在使用我的 make 文件来编写我在 Linux 环境中编写的程序时遇到问题。该程序是一个蕨类分形,它使用我的教授给我的 bitmapImage.h 和 bitmapImage.so 。每当我尝试运行 make 文件时,我都会收到一长串错误,主要的是:

    make
g++    -c -o fern.o fern.cpp
g++    -c -o fernType.o fernType.cpp
g++ -m32 -o fern fern.o fernType.o bitmapImage.so
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
make: *** [spiro] Error 1

我的猜测是bitmapImage.so是为32位系统设计的,但我的虚拟机ubuntu运行64位。我该如何解决这个问题以便编译我的程序?谢谢!

编辑:更新了我的旧帖子以显示我遇到的当前错误

生成文件:

# Make file for spirograph program

## note, uses bitmapImage shared object file (library).

OBJS = fern.o fernType.o
CC  = g++ -m32
DEPS1 = fernType.h
DEPS2 = bitmapImage.h

all: spiro

spiro: $(OBJS)
    $(CC) -m32 -o fern $(OBJS) bitmapImage.so

spiro.o:    fern.cpp $(DEPS1)
    $(CC) -m32 -c fern.cpp

spiroType.o:    fernType.cpp $(DEPS1) $(DEPS2)
    $(CC) -m32 -c fernType.cpp

# -----
# clean by removing object files.

clean:
    rm  $(OBJS)

最佳答案

-m32 选项添加到编译行,强制所有内容都针对 32 位地址空间进行编译。 (它仍将在 64 位系统上运行。)

关于c++ - make 命令给出不兼容的 i386 架构(i386x86-64),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12924456/

相关文章:

c++ - 这种类型的模板参数是什么意思 - `ClassA<T> T::*ELEM` ?

c - 尝试安装 valgrind 但卡在 make valgrind,怎么办?

ruby - 如何在 osx 上使用调试符号从源代码编译 ruby​​?

xcode - 升级到 Mountain Lion 和 XCode 4 打破了我的 "make"?

c++ - g++ 既是 C++ 编译器又是链接器?

c++ - 构造函数参数的求值顺序

c++ - 如何使用 Windows API 自动将 C++ 代码从 Windows 转换为 Linux

c - 限制信号处理程序仅捕获来自定义它的特定文件的信号

c++模板遍历 map

linux - 调试 C 程序中的慢函数(由 gcc 构建)