gpt4 book ai didi

c++ - G++ 警告 : built for unsupported file format which is not the architecture being linked

转载 作者:行者123 更新时间:2023-11-30 03:09:01 25 4
gpt4 key购买 nike

每当我尝试编译我的项目时(使用命令行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 下(使用最新的开发者工具)

最佳答案

您正在编译您不应该做的头文件 (.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() 函数 - 否则操作系统将不知道入口点在哪里。

关于c++ - G++ 警告 : built for unsupported file format which is not the architecture being linked,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4467871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com