Search code examples
cprogram-entry-pointundefined-symbol

I was running a a program and came by this error. what does it mean?


#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();
}










 


Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

This the error i got but i couldn't figure it out

i copy pasted this because i needed more words in body

Ld /Users/dahirali/Library/Developer/Xcode/DerivedData/scene-ccsieluddlpredauupsijrhisooo/Build/Products/Debug/scene normal (in target 'scene' from project '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/DerivedData/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/Build/Products/Debug/scene


Solution

  • It means you tried to compile a C source file as an executable, but there's no main function. main is called by the operating system when the executable is run.