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)

なぜこれが起こっているのかについてのアイデアはありますか?私はOSX10.6を使用しています(最新の開発者ツールを使用)

4

3 に答える 3

3

まだ実行してはならないヘッダーファイル(.hpp)をコンパイルしています。ソースファイル(.cpp)のみをコンパイルする

すべての.cppファイルをコンパイルするのではなく、一度に1つずつコンパイルしてから、適切にリンクします。

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

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

main()関数を持つことができるのは.cppファイルの1つだけであることに注意してください。そうしないと、OSはエントリポイントがどこにあるかを認識できません。

于 2010-12-17T05:17:26.097 に答える
0

私はMacを所有していないので、これが発生したときに何をすべきかについてLinuxバージョンを提供します。

gccのmultilibバージョンを探し、-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 に答える