ご覧のとおり、私はこのサイトで非常に新しいです。私は私のような問題を見つけるために使いましたが、役に立たなかった。いくつかの問題WindowsでのサンプルC++プログラムのコンパイルと実行
私の問題は、C++プログラム(link here注:ソースコードはhereです)をコンパイルできないことと、コンパイラエラーを修正する適切な方法が見つからないことです。
私はコンパイルするいくつかの方法を試してみました:
1)Cygwinを使用します。
ファイルをコンパイルして実行しようとしましたが(私はライブラリ(GLEW、GLUT、GLM)を含めて多くの問題がありましたが、ライブラリをcygwinディレクトリに置いた後に修正しました。私はfreeglutが表示エラーを開くのに失敗しましたが、これはxcygwinに固定されていましたが、これは私にGLのバージョンが見つからないという最終的なエラーをもたらしました。実行します。私はcygwinの問題に何らsoutionsは認められません。cmd.exeのを通じてグラム++コンパイラを使用して
2)
私はコマンドプロンプトでC++をコンパイルできると読んだので、それを試みました。 g ++ glescraft.cpp noise.h noise.cpp textures.c -o glescraftというコマンドを実行しましたが、GLEWが見つからないというエラーも表示されました。図書館を正しい場所に置くことによって、これらをもう一度修正しました。すべてのライブラリの問題が修正された後、複数の宣言、GL、GLEW、およびGLUTコマンドへの未定義の参照について、多くの問題が発生しました。私はあなたが途中でそれらを必要とする場合、私はエラーを投稿することができます。しかし、GNU/Linux上でmakeを使ってコンパイルしたプログラムが完璧にコンパイルされているので、ファイルにプログラミングエラーがあるとは思わないが、nVIDIAドライバには多くの問題があるためテストできなかった。等)。私はgnu/linuxでもg ++コンパイルを試みましたが、同じ複数定義と未定義参照がありました。私はこれらについて何も見つけることができませんでした。
3)コード::ブロック私はコード::ブロックがあまりにもmingwのG ++コンパイラを使用しています信じているとまったく同じことが、G ++コンパイラを使用していたが起こった
。
ところで、私はg ++をコマンドプロンプトで試してみたと言いましたが、gccも試しましたが、同じエラーが出ました。
私の質問は、このプログラムをコンパイルするにはどうすればできますか?できるだけ依存性はほとんどありません。
あなたは方法を見つけることができますか?私は困惑しており、これを行う方法を見つけることができません。私は1週間ほどやっています。
これまで読んでいただきありがとうございます。私はあなたの回答をお聞きしたいと思います(これは正しいセクションにあることを願っています)。
EDIT:人が指摘したように、ここでのエラーは、次のとおりです。また、
cmdの中のG ++コンパイラを使用した後に示されたエラーとは、コード::ブロックで示したものと同じ:
C:\prog\glescraft>g++ glescraft.cpp noise.h noise.cpp textures.c -o glescraft.ex e C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x0): multiple d efinition of `linearInterpolation(float, float, float)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x58): first defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x11): multiple definition of `biLinearInterpolation(float, float, float, float, float, float)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x69): first defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x76): multiple definition of `triLinearInterpolation(float, float, float, float, float, float, float, float, float, float, float)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xce): first defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x111): multiple definition of `noise2d(int, int, int)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x169): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x1e7): multiple definition of `noise3d(int, int, int, int)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x23f): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x2f4): multiple definition of `noise2d_gradient(float, float, int)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x34c): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x454): multiple definition of `noise3d_gradient(float, float, float, int)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x4ac): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x6e0): multiple definition of `noise2d_perlin(float, float, int, int, float)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x738): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x765): multiple definition of `noise2d_perlin_abs(float, float, int, int, float)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x7bd): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x7f6): multiple definition of `noise3d_perlin(float, float, float, int, int, float)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x84e): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccCAHbwO.o:noise.cpp:(.text+0x885): multiple definition of `noise3d_perlin_abs(float, float, float, int, int, float)' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x8dd): firs t defined here C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1c): undef ined reference to `__glutInitWithExit' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x37): undef ined reference to `__glutCreateWindowWithExit' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x52): undef ined reference to `__glutCreateMenuWithExit' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xa9e): unde fined reference to `_imp____glewIsShader' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xab9): unde fined reference to `_imp____glewGetShaderiv' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xadc): unde fined reference to `_imp____glewIsProgram' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xaf7): unde fined reference to `_imp____glewGetProgramiv' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xb55): unde fined reference to `_imp____glewIsShader' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xb70): unde fined reference to `_imp____glewGetShaderInfoLog' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xb9a): unde fined reference to `_imp____glewIsProgram' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xbb5): unde fined reference to `_imp____glewGetProgramInfoLog' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xc51): unde fined reference to `_imp____glewCreateShader' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xc66): unde fined reference to `_imp____glewShaderSource' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xc9a): unde fined reference to `_imp____glewCompileShader' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xcb3): unde fined reference to `_imp____glewGetShaderiv' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xd05): unde fined reference to `_imp____glewDeleteShader' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xe48): unde fined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xefc): unde fined reference to `_imp____glewCreateProgram' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xf14): unde fined reference to `_imp____glewAttachShader' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xf2f): unde fined reference to `_imp____glewAttachShader' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xf4a): unde fined reference to `_imp____glewLinkProgram' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xf5e): unde fined reference to `_imp____glewGetProgramiv' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0xfc1): unde fined reference to `_imp____glewGetAttribLocation' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1025): und efined reference to `_imp____glewGetUniformLocation' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1082): und efined reference to `_imp____glewActiveTexture' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x10ae): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x10c6): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1119): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1121): und efined reference to `_imp____glewGenerateMipmap' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1211): und efined reference to `_imp____glewGenBuffers' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1244): und efined reference to `_imp____glewBindBuffer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1260): und efined reference to `_imp____glewBufferData' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x128d): und efined reference to `_imp____glewGenBuffers' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x134e): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x13a2): und efined reference to `_imp____glewUseProgram' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x13b6): und efined reference to `_imp____glewUniform1i' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x14f8): und efined reference to `_imp____glewUniformMatrix4fv' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1552): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1561): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1580): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x159f): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15ae): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15bd): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15d6): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15e5): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15ed): und efined reference to `_imp____glewEnableVertexAttribArray' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1666): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1e72): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1e81): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1e89): und efined reference to `_imp____glewUniformMatrix4fv' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1ec0): und efined reference to `_imp____glewBindBuffer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1edc): und efined reference to `_imp____glewBufferData' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1f09): und efined reference to `_imp____glewVertexAttribPointer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1f5c): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1f83): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1fa7): und efined reference to `_imp____glewUniformMatrix4fv' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1fde): und efined reference to `_imp____glewBindBuffer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1ffa): und efined reference to `_imp____glewBufferData' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2027): und efined reference to `_imp____glewVertexAttribPointer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x207a): und efined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2082): und efined reference to `glutSwapBuffers' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x22f4): und efined reference to `glutGet' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x24d7): und efined reference to `glutPostRedisplay' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2643): und efined reference to `glutWarpPointer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2825): und efined reference to `_imp____glewDeleteProgram' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2862): und efined reference to `glutInitDisplayMode' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2876): und efined reference to `glutInitWindowSize' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2887): und efined reference to `_imp__glewInit' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x28a0): und efined reference to `_imp__glewGetErrorString' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x28ce): und efined reference to `_imp____GLEW_VERSION_2_0' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x296c): und efined reference to `glutSetCursor' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2980): und efined reference to `glutWarpPointer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x298c): und efined reference to `glutDisplayFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x2998): und efined reference to `glutReshapeFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29a4): und efined reference to `glutIdleFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29b0): und efined reference to `glutSpecialFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29bc): und efined reference to `glutSpecialUpFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29c8): und efined reference to `glutIdleFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29d4): und efined reference to `glutPassiveMotionFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29e0): und efined reference to `glutMotionFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29ec): und efined reference to `glutMouseFunc' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x29f1): und efined reference to `glutMainLoop' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text$_ZN5chunk6up dateEv[chunk::update()]+0x237e): undefined reference to `_imp____glewGenBuffers' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text$_ZN5chunk6up dateEv[chunk::update()]+0x23e9): undefined reference to `_imp____glewBindBuffer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text$_ZN5chunk6up dateEv[chunk::update()]+0x2409): undefined reference to `_imp____glewBufferData' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text$_ZN5chunk6re nderEv[chunk::render()]+0x3f): undefined reference to `_imp____glewBindBuffer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text$_ZN5chunk6re nderEv[chunk::render()]+0x5f): undefined reference to `_imp____glewVertexAttribP ointer' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text$_ZN5chunk6re nderEv[chunk::render()]+0xb7): undefined reference to `[email protected]' C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text$_ZN10superch unk6renderERKN3glm6detail7tmat4x4IfEE[superchunk::render(glm::detail::tmat4x4 const&)]+0x2c7): undefined reference to `_imp____glewUniformMatrix4fv' collect2: ld returned 1 exit status
申し訳ありませんが、書式設定については、コピー貼り付けでコードタグが機能しないようです。
['compile.txt'](https://gitorious.org/wikibooks-opengl/modern-tutorials/blobs/master/compile) txt)は、コードがLinux用に設計されていることを示しています。私はそれがWindows上でまったく動作するように設計されているという証拠は見当たりません。 Linuxでビルドしようとしましたか? –
はい、私は持っていますが、GLUT、GLEW、GLMはWindows上で動作するはずです。 「フリー」のドライバは3Dをサポートしていないため、私はコードを実行できません。 このプロジェクトをcode :: blocksに設定するページがありますが、私の質問で説明したように、g ++のcmdコンパイルメソッドと同じエラーがスローされます。 http://en.wikibooks.org/wiki/OpenGL_Programming/Installation/Windows これはWindowsのセットアップページです。 – AnotherNewCPPDev
あなたの質問には実際の*コンパイルエラーが含まれていることがあります。あなたの質問は簡単に答えるだけでなく(あなたのコードがなぜ構築されないのかを知ることはできません)、後で同じエラーメッセージを検索する他の人に役立ちます。 –