尽管在库中用-l链接,我似乎无法再在GCC发布Ubuntu 11.10更新中编译我的代码.编译:
gcc -lm -lGL -lGLU -lglut T1.c
(我试图链接的两个库,包含的是过剩和数学)
所有的库和头文件都应该是它们的位置(自更新以来它们没有出现过),我已经检查了所有相关的软件包安装.另外这里是我的环境变量,它们似乎是有序的:
PATH =/usr/lib目录/ lightdm/lightdm:在/ usr/local/sbin中:在/ usr/local/bin目录:/ usr/sbin目录:在/ usr/bin中:/ sbin目录:/ bin中:在/ usr /游戏
C_INCLUDE_PATH =的/ usr /包括
我不认为这是代码的问题,因为我无法编译昨天成功编译的文件.但是为了以防万一我还是会链接它:
#include <math.h>
#include <GL/glut.h>
const int WIDTH=640;
const int HEIGHT=480;
const float NEAR_CLIP=0.1f;
const float FAR_CLIP=100.0f;
const double INC_ROTATE=5;
double rotate=0;
void rotateObject() {
rotate+=INC_ROTATE;
}
void update() {
//rotateObject();
}
void drawAxes() {
double x = 1.5, y = 1.5, z = 1.5;
glLineWidth(4);
glBegin(GL_LINES);
glColor3d(1,0,0);
glVertex3d(0,0,0);
glVertex3d(x,0,0);
glColor3d(0,1,0);
glVertex3d(0,0,0);
glVertex3d(0,y,0);
glColor3d(0,0,1);
glVertex3d(0,0,0); …Run Code Online (Sandbox Code Playgroud) 我必须做一些纯ANSI C,我试图在Visual Studio 2010中这样做.问题是; 无论将编译器设置为纯C并翻转\ Za编译器开关以禁用Windows扩展 - 代码都不会编译:
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
cout << M_PI;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是一个名为Test.c的文件 - 没有预编译的头文件,一切都应该没问题,但这就是编译器吐出的内容:
1>ClCompile:
1> Test.c
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'acosf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: syntax error : ';'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'asinf'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: syntax error …Run Code Online (Sandbox Code Playgroud)