G ++警告:为不支持的文件格式构建,而不是链接的体系结构

每当我尝试编译我的项目时(使用命令行
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()函数 - 否则操作系统将无法知道入口点的位置。     
我没有Mac,所以当你发生这种情况时,我会给你Linux版本的操作。 查找gl的multilib版本并使用-m32开关重新编译
g++ *.hpp *.cpp -m32
试试这个。您可以使用gcc编译头文件以生成预编译的头文件。     
g ++参数
-arch i386
应该适合你:
g++ *.hpp *.cpp -m32 -arch i386
那是对的吗?     

要回复问题请先登录注册