1

每当我尝试编译我的项目(使用命令行g++ *.hpp *.cpp 2> log.txt)时,这就是我得到的:

log.txt

ld: warning: in configfile.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: in erase.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: in filehandler.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: in insert.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: warning: in operation.hpp, file was built for unsupported file format which is not the architecture being linked (x86_64)

关于为什么会发生这种情况的任何想法?我在 OSX 10.6 下(使用最新的开发者工具)

4

3 回答 3

3

你正在编译你不应该做的头文件(.hpp)。仅编译源文件 (.cpp)

与其编译所有 .cpp 文件,不如一次编译一个,然后适当地链接它们。

g++ -c x.cpp
g++ -c y.cpp
g++ -c z.cpp

g++ -o tst x.o y.o z.o

请注意,只有一个 .cpp 文件可以具有 main() 函数 - 否则操作系统将不知道入口点在哪里。

于 2010-12-17T05:17:26.097 回答
0

我没有 Mac,所以我给你一个 Linux 版本,告诉你发生这种情况时该怎么做。

寻找一个多库版本的 gcc 并使用 -m32 开关重新编译

g++ *.hpp *.cpp -m32

试试这个。您可以使用 gcc 编译头文件以生成预编译的头文件。

于 2010-12-17T05:18:57.503 回答
0

g++ 参数-arch i386应该为您解决问题:

g++ *.hpp *.cpp -m32 -arch i386

那是对的吗?

于 2011-01-26T16:13:45.487 回答