【问题标题】:I was running a a program and came by this error. what does it mean?我正在运行一个程序并遇到此错误。这是什么意思?
【发布时间】:2020-12-04 00:46:24
【问题描述】:
#if __APPLE_CC__
#include <GLUT/glut.h>
#else
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include "glut.h"
#endif



#include <math.h>
#include <stdio.h>
#include "scene.h"
#include <string.h>




extern float g_t;




//function prototypes for the local functions
void drawCone(float x, float y, float z, float radius, float height, int nSides, float startColor[3], float endColor[3]);

void drawBox(float left, float bottom, float front,
    float length, float height, float depth);

/*
   this function is called whenever OpenGL needs to redraw
   the screen
   
*/
void drawScene(void)
{
  float startColor[3] = { 0.5, 0.0, 0.0}, endColor[3] = {1.0, 1.0, 0.0};
//    drawCone(0,-1,0, 0.5, 1.0, 20, startColor, endColor);
 //   drawCone(0,1,0, 0.5, -1.0, 20, startColor, endColor);

//    glEnable(GL_CULL_FACE);
//    glCullFace(GL_BACK);
    
    
    //tabletop
    drawBox(-1, 1, 0.5, 2.0, 0.1, 1);
    
    //left, front leg
    drawBox(-1, 0, 0.5, .1, 1, .1);
    
    glColor3f(0,0,0);
    glutWireTorus(0.1, .25, 12, 16);
    
    glTranslatef(0.0, 1.25, 0.0);
    glutWireTeapot(0.2);
    glTranslatef(0.0, -1.25, 0.0);


}//drawScene

void drawCone(float x, float y, float z, float radius, float height, int nSides, float startColor[3], float endColor[3])
{
    int i, j, next;
    float angle;
    
    float circlePoints[100][3];
    float colors[100][3];
    
    //first calculate the points on a circle and the color for each point
    
    for(i = 0; i < nSides; ++i)
    {
       angle = 2* M_PI/nSides * i;
       circlePoints[i][0] = radius * sin(angle) + x;
       circlePoints[i][1] = y;
       circlePoints[i][2] = radius * cos(angle) + z;
       
       colors[i][0] = (endColor[0]- startColor[0])/ nSides * i + startColor[0];
       colors[i][1] = (endColor[1]- startColor[1])/ nSides * i + startColor[1];
       colors[i][2] = (endColor[2]- startColor[2])/ nSides * i + startColor[2];
    }
     //draw the cone
    glBegin(GL_TRIANGLES);
    for(i = 0; i < nSides; ++i)
    {
        next = (i + 1) % nSides;
        glColor3f(colors[i][0], colors[i][1], colors[i][2]);
        glVertex3f(circlePoints[next][0], circlePoints[next][1], circlePoints[next][2]);
        glVertex3f(x, y + height, z);
        
        glVertex3f(circlePoints[i][0], circlePoints[i][1], circlePoints[i][2]);
       // glVertex3f(x, y + height, z);
    }
    glEnd();
    
    //draw the circle
    glBegin(GL_POLYGON);
    for(i = 0; i < nSides; ++i)
    {
        glColor3f(startColor[0], startColor[1], startColor[2]);
        glVertex3f(circlePoints[i][0], circlePoints[i][1], circlePoints[i][2]);
    }
     glVertex3f(circlePoints[0][0], circlePoints[0][1], circlePoints[0][2]);
    glEnd();
}

/*
            x,X left
            y,Y bottom
            z Z front
            l L length
            h H height
            d D depth
*/
               
void handleKey(char key)
{
    printf("key = %c\n", key);

}

void drawBox(float left, float bottom, float front,
    float length, float height, float depth)
    {
    float right = left + length;
    float top = bottom + height;
    float back = front - depth;
    //draw the front
    glBegin(GL_QUADS);
    
    //front
    glColor3f(1.0, 0.0, 0.0);
    glVertex3f(left, bottom, front);
    glVertex3f(right, bottom, front);
    glVertex3f(right, top, front);
    glVertex3f(left, top, front);
    
    //left
    glColor3f(0.0, 1.0, 0.0);
    glVertex3f(left, bottom, front);
    glVertex3f(left, top, front);
    glVertex3f(left, top, back);
    glVertex3f(left, bottom, back);
    
    //back
    glColor3f(0.0, 0.0, 1.0);
    glVertex3f(left, bottom, back);
    glVertex3f(left, top, back);
    glVertex3f(right, top, back);
    glVertex3f(right, bottom, back);
    
    //top
    glColor3f(0.0, 1.0, 1.0);
    glVertex3f(left, top, front);
    glVertex3f(right, top, front);
    glVertex3f(right, top, back);
    glVertex3f(left, top, back);

    //bottom
    glColor3f(1.0, 0.0, 1.0);
    glVertex3f(left, bottom, front);
    glVertex3f(right, bottom, front);
    glVertex3f(right, bottom, back);
    glVertex3f(left, bottom, back);
    
    glEnd();
}










 


架构 x86_64 的未定义符号: “_main”,引用自: 主可执行文件的隐式入口/启动 ld:未找到架构 x86_64 的符号 clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

这是我得到的错误,但我无法弄清楚

我复制粘贴了这个,因为我需要更多的词在正文中

Ld /Users/dahirali/Library/Developer/Xcode/DerivedData/scene-ccsieluddlpredauupsijrhisooo/Build/Products/Debug/scene normal(在项目'scene'的目标'scene'中) cd /Users/dahirali/Desktop/1101/scene /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-macos10.15 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/ Developer/SDKs/MacOSX10.15.sdk -L/Users/dahirali/Library/Developer/Xcode/DerivedData/scene-ccsieluddlpredauupsijrhisooo/Build/Products/Debug -F/Users/dahirali/Library/Developer/Xcode/DerivedData/scene- ccsieluddlpredauupsijrhisooo/Build/Products/Debug -filelist /Users/dahirali/Library/Developer/Xcode/DerivedData/scene-ccsieluddlpredauupsijrhisooo/Build/Intermediates.noindex/scene.build/Debug/scene.build/Objects-normal/x86_64/scene。 LinkFileList -Xlinker -object_path_lto -Xlinker /Users/dahirali/Library/Developer/Xcode/DerivedData/scene-ccsieluddlpredauupsijrhisooo/Build/Intermediates.noindex/scene.build/Debug/scene.build/Objects-normal/x86_64/scene_lto.o - Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -dependency_info -Xlinker /Users/dahirali/Library/Developer/Xcode/DerivedDat a/scene-ccsieluddlpredauupsijrhisooo/Build/Intermediates.noindex/scene.build/Debug/scene.build/Objects-normal/x86_64/scene_dependency_info.dat -o /Users/dahirali/Library/Developer/Xcode/DerivedData/scene-ccsieluddlpredauupsijrhisooo/构建/产品/调试/场景

【问题讨论】:

  • 请显示您的代码和构建命令。

标签: c main undefined-symbol


【解决方案1】:

这意味着您尝试将 C 源文件编译为可执行文件,但没有 main functionmain 在可执行文件运行时被操作系统调用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-29
    • 2011-03-01
    相关资源
    最近更新 更多