简体   繁体   English

在Windows上编译和运行示例C ++程序的几个问题

[英]Several Problems Compiling and running an example C++ Program on Windows

As you can see, I'm extremely new to this site. 如您所见,我是这个网站的新手。 I've searched using to find problems like mine, but to no avail. 我使用搜索来查找类似我的问题,但无济于事。

What my problem is, is that I cannot compile a c++ program ( link here Note: source code is found here ), and have found no proper ways to fix the compiler errors. 什么我的问题是,是,我不能编译C ++程序( 此处链接注:源代码被发现在这里 ),并没有发现任何适当的方式来修复编译器错误。

I have tried several ways to compile: 我尝试了几种编译方法:

1) Using cygwin. 1)使用cygwin。

I used the makefile provided to compile and tried to run the file (I had many problems with including the libraries (GLEW, GLUT, GLM) but I fixed them after putting the libraries in the cygwin directory. Then it gave me a freeglut failed to open display error, which I fixed going into xcygwin. This gave me a final error calling a missing GL version. People on other sites have said to initiate glut before glew, but I couldn't find where init glew was run. I have found no soutions to the cygwin problem. 我使用提供的makefile进行编译,并尝试运行该文件(我在包含库(GLEW,GLUT,GLM)时遇到了许多问题,但是在将库放入cygwin目录后,我对其进行了修复。打开显示错误,我将其修复为xcygwin。这给了我最终的错误,称为缺少GL版本。其他网站上的人说过在出现问题之前先启动glut,但我找不到在哪里运行init glew。没有关于cygwin问题的意见。

2) Using the g++ compiler through CMD.exe 2)通过CMD.exe使用g ++编译器

I read you can compile C++ through command prompt, so I tried to do that. 我读到您可以通过命令提示符编译C ++,所以我尝试这样做。 I ran the command g++ glescraft.cpp noise.h noise.cpp textures.c -o glescraft, but also gave errors about not being able to find GLEW. 我运行了g ++ glescraft.cpp noise.h noise.cpp textures.c -o glescraft命令,但是也给出了关于找不到GLEW的错误。 I fixed these yet again by putting the libraries in the correct place. 我通过将库放置在正确的位置来再次修复这些问题。 After all the library issues had been fixed, it threw many issues about multiple declarations, and also undefined references to GL, GLEW, and GLUT commands. 解决所有库问题之后,它引发了有关多个声明的许多问题,并且还引发了对GL,GLEW和GLUT命令的未定义引用。 I can post the errors if yo guys need them by the way. 如果你们需要它们,我可以发布错误。 But, I don't believe there is a programming error in the files, as the program compiled using make on GNU/Linux perfectly fine, but I couldn't test due to myself having many issues with the nVIDIA drivers (X not starting etc etc). 但是,我不认为文件中存在编程错误,因为在GNU / Linux上使用make编译的程序非常好,但是由于我自己遇到了nVIDIA驱动程序很多问题(X无法启动等),所以我无法进行测试等等)。 I tried a g++ compile on gnu/linux as well but the same multiple definitions and undefined references. 我也尝试了在gnu / linux上进行g ++编译,但是相同的多个定义和未定义的引用。 I couldn't find anything on these. 我找不到这些东西。

3)Code::Blocks 3)代码::块

The exact same thing happened was using the g++ compiler, as I believe code::blocks uses the mingw g++ compiler too. 发生的事情完全相同,是使用g ++编译器,因为我相信code :: blocks也使用mingw g ++编译器。

By the way, when I said I tried g++ in the command prompt, I also tried gcc, but also, same errors. 顺便说一句,当我说我在命令提示符下尝试了g ++时,我也尝试了gcc,但是也遇到了同样的错误。

My Question is, how can I get this program to compile, and with little dependencies as possible? 我的问题是,如何才能使该程序编译,并且几乎没有依赖关系?

Can you guys find a way? 你们能找到办法吗? I'm stumped, and cannot find a way to do this at all, I've been trying for a week or so as well. 我很沮丧,也根本找不到办法,我也已经尝试了一个星期左右。

EDIT: As a person pointed out, here are the errors: 编辑:正如一个人指出,这是错误:

The errors shown after using the g++ compiler in cmd and also the same as the ones shown in code::blocks: 在cmd中使用g ++编译器后显示的错误也与code :: blocks中显示的错误相同:

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 `glGetIntegerv@8'
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 `glGenTextures@8'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x10c6): und
efined reference to `glBindTexture@8'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1119): und
efined reference to `glTexImage2D@36'
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 `glViewport@16'
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 `glClearColor@16'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1561): und
efined reference to `glClear@4'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1580): und
efined reference to `glTexParameteri@12'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x159f): und
efined reference to `glTexParameteri@12'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15ae): und
efined reference to `glEnable@4'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15bd): und
efined reference to `glEnable@4'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15d6): und
efined reference to `glPolygonOffset@8'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x15e5): und
efined reference to `glEnable@4'
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 `glReadPixels@28'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1e72): und
efined reference to `glDisable@4'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1e81): und
efined reference to `glDisable@4'
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 `glDrawArrays@12'
C:\Users\patrick\AppData\Local\Temp\ccL5KhgI.o:glescraft.cpp:(.text+0x1f83): und
efined reference to `glDisable@4'
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 `glDrawArrays@12'
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 `glDrawArrays@12'
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

Sorry about the formatting, I can't seem to get the code tags working on a copy-paste. 对格式很抱歉,我似乎无法在复制粘贴中使用代码标签。

Some of those multiple definition error is because the file glescraft.cpp includes the source file of noise.cpp and textures.c, and you also try to compile with on the command line. 这些多定义错误中的某些错误是因为文件glescraft.cpp包含noise.cpp和textures.c的文件,并且您还尝试在命令行上进行编译。 Either change the source to include proper header files, or compile only glescraft.cpp. 更改源以包含适当的头文件,或者仅编译glescraft.cpp。

The problems with undefined references is because you do not link with the OpenGL libraries. 未定义引用的问题是因为您未链接OpenGL库。 Add at least "-lgl -lglut" to the command line. 在命令行中至少添加“ -lgl -lglut”。

You also need to tell the compiler (actually the linker) where to find the libraries. 您还需要告诉编译器(实际上是链接器)在哪里可以找到这些库。 This is done with the "-L" flag. 这是通过“ -L”标志完成的。

The command line after my suggestions should look something like: 我的建议后的命令行应类似于:

g++ glescraft.cpp -o glescraft.exe -L<path to gl and glut libs> -lgl -lglut

Replace " <path to gl and glut libs> " with the actual path to the libraries. <path to gl and glut libs>的实际路径替换“ <path to gl and glut libs>的路径<path to gl and glut libs> ”。

Also, when compiling, header files (files ending in ".h") should never be compiled by you. 另外,在编译时,头文件(以“ .h”结尾的文件)绝对不能由您编译。 Instead they are included by the compiler with the #include "file" directive. 而是由编译器通过#include "file"指令将它们包括在内。

You can see all flags in the GCC manual . 您可以在GCC手册中看到所有标志。 Select the version you have (which can be found with the command g++ --version .) 选择您拥有的版本(可以通过命令g++ --version 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM