What seemed as the most straightfoward technique is actually giving me alot of issues. I’m trying to run a program that generates multiple lines with various widths and stipple patterns. However after compiling it, from the Linux command prompt, I recieve the following error:
[NOTE]lines: In function _start': (.text+0x0): multiple definition of
_start’
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld:…
[/NOTE]
After tireless review of the code, I have nothing. The only thing that comes to mind that may cause this error to occur is either something is wrong with the drawOneLine macro specified at the top, or possibly one of the hex values are messing it up although I have already checked and it doesn’t seem to be the issue. If anyone can some up with a explanation of why this program is behaving the way it is I will be most greatful. Here is my code, note I commented some of the lines out for simplicity sake:
//Inclide OpenGL header files
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#include <iostream>
#include <stdlib.h> //needed for exit funtion
#define drawOneLine(x1, y1, x2, y2) glBegin(GL_LINES); \
glVertex2f((x1), (y1)); glVertex2f((x2), (y2)); glEnd();
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0); //select clearing screen color
glShadeModel(GL_FLAT); //sets shading model to flat
}
void display(void)
{
int i;
glClear(GL_COLOR_BUFFER_BIT);
//select white for all lines
glColor3f(1.0, 1.0, 1.0);
//in 1st row, 3 lines, each with a different stipple
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0x0101); //dotted
drawOneLine(50.0, 125.0, 150.0, 125.0);
glLineStipple(1, 0x00FF); //dashed
drawOneLine(150.0, 125.0, 250.0, 125.0);
glLineStipple(1, 0x1C47); //dash-dot-dash
drawOneLine(250.0, 125.0, 350.0, 125.0);
//in 2st row, 3 wide lines, each with a different stipple
glLineWidth(5.0);
glLineStipple(1, 0x0101); //dotted
drawOneLine(50.0, 100.0, 150.0, 100.0);
glLineStipple(1, 0x00FF); //dashed
drawOneLine(150.0, 100.0, 250.0, 100.0);
glLineStipple(1, 0x1C47); //dash-dot-dash
drawOneLine(250.0, 100.0, 350.0, 100.0);
//in 3ed row, 6 lines, with dash-dot-dash stipple as part of a single connected line strip
//glLineStipple(1, 0x1C47);
//glBegin(GL_LINE_STRIP);
//for(i=0; i < 7; i++)
// glVertex2f(50.0 + ((GLfloat)i * 50.0), 75.0);
//glEnd();
//in 4th row, 6 independent lines with same stipple
//for(i=0; i < 6; i++)
// drawOneLine(50.0 + ((GLfloat)i * 50.0), 50.0, (50.0 + ((GLfloat)(i+1) * 50.0), 50.0);
//In 5th row, 1 line, with dash-dot-dash stipple and a stipple repeat factor of 5
glLineStipple(5, 0x1c47); //dash-dot-dash
drawOneLine(50.0, 25.0, 350.0, 25.0);
glDisable(GL_LINE_STIPPLE);
glFlush();
}
//called when the window is resized
void reshape(int w, int h) {
glViewport(0, 0, w, h); //tell OpenGL how to convert from coordinates to pixel values
glMatrixMode(GL_PROJECTION); //switch to setting the camera perspective
//set the camera perspective
glLoadIdentity(); //reset the camera
glOrtho(0.0, (GLdouble) w, 0.0, (GLdouble) h, 1.0, 0.0); //creates a matrix for an orthographic parallel viewing volume and multiplies the current matrix by it
}
int main(int argc, char** argv)
{
glutInit(&argc, argv); //initialize GLUT and proccesses any command line arguments.
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); //specifies to use a double buffer window, RGB color, and depth buffer
glutInitWindowSize(400, 150); //specifies the size, in pixels, of the window
glutInitWindowPosition(100, 100); //specifies the screen locations for the upper left corner of the window
glutCreateWindow(argv[0]); //create window and specifies identifier
//Top function calls
init(); //initialize window
glutDisplayFunc(display); //specifies the function needed to display the windpw
glutReshapeFunc(reshape); //specifies the function needed to resi(ze the windpw
glutMainLoop(); //Event processing begins, and the registred display callback is triggered. Essentially runs the program
return 0;
}