私はシンプルなクラスprogramを作ろうとしていますが、私はそれが問題ではないと思っています。ビルドプロセス中のClionコンパイラエラー
CMakeFiles\Assignment_4.dir/objects.a(Box.cpp.obj):Box.cpp:(.bss+0x0): multiple definition of `Box::objectCount'
CMakeFiles\Assignment_4.dir/objects.a(Q_1.cpp.obj):Q_1.cpp:(.bss+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [Assignment_4.exe] Error 1
CMakeFiles\Assignment_4.dir\build.make:147: recipe for target 'Assignment_4.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/Assignment_4.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/Assignment_4.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/Assignment_4.dir/rule] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/Assignment_4.dir/rule' failed
mingw32-make.exe: *** [Assignment_4] Error 2
Makefile:117: recipe for target 'Assignment_4' failed
g ++で直接コンパイルしても、複数のオブジェクト定義エラーが発生します。以前はビジュアルスタジオで働いていました。
C:\Users\fsa\CLionProjects\McMaster\Assignment_4>g++ Q_1.cpp clock.cpp box.cpp -o Q1.exe
C:\Users\fsa\AppData\Local\Temp\ccmD1R6t.o:box.cpp:(.bss+0x0): multiple definition of `Box::objectCount'
C:\Users\fsa\AppData\Local\Temp\cc0nh7LU.o:Q_1.cpp:(.bss+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
間違ったコマンドでコンパイルしていました。これは 'g ++ Q_1.cpp clock.cpp box.cpp -o Q1.exe' –
でなければなりません。 – GigaRohan
@GigaRohanいいえ、しかし、それはエラー出力を変更しました。私のクラスファイルはまったくコンパイルされていませんでした。今は、 'Box :: objectCount''エラーの多重定義があります。私は原因を見るためにコードを実行しています。 –