0

The issue I'm getting is: undefined reference to 'set_argv'

I've tried just about everything I could think of, yet nothing appears to work. I followed the installation guide step by step on how to configure freeglut with Codeblocks.

#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

#include <stdlib.h>

void RenderScena(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_TRIANGLES);
        glVertex3f(-0.5,-0.5,0.0);
        glVertex3f(0.5,0.0,0.0);
        glVertex3f(0.0,0.5,0.0);
    glEnd();

    glutSwapBuffers();

}
int main(int argc, char **argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(320,320);
    glutCreateWindow("Title");
    glutDisplayFunc(RenderScena);
    glutMainLoop();
    return 0;


}
alk
  • 69,737
  • 10
  • 105
  • 255
Wulfe
  • 1
  • 1
  • 1
    How are you compiling your program, and in particular, how are you linking the program? –  May 15 '16 at 13:06
  • 1
    `set_argv` or `_setargv`? –  May 15 '16 at 13:06
  • ||=== Build: Debug in Glutest (compiler: GNU GCC Compiler) ===| c:\mingw\bin\..\lib\gcc\mingw32\4.9.3\..\..\..\crt2.o|| undefined reference to `_setargv'| ||error: ld returned 1 exit status| ||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 2 second(s)) ===| is the exact error – Wulfe May 15 '16 at 13:37
  • Hard to read, but it appears you're not linking with the freeglut library. –  May 15 '16 at 14:17
  • As far as I can tell, everything should be in order. Once more, I've followed this tutorial http://wiki.codeblocks.org/index.php/Using_FreeGlut_with_Code::Blocks on setting it up. – Wulfe May 15 '16 at 14:35
  • Maybe I should try and re-install freeglut with a previous version? I used 3.0.0 – Wulfe May 15 '16 at 16:00

1 Answers1

3

In my case, codeblocks was setting the path to the compiler to the installation under C:. When I changed to the installation in the directory of codeblocks, compilation worked:

In the codeblocks, go to settings-compiler-toolchain executables, and change the compiler's installation directory to the installation of MinGW in the codeblocks directory.

hoijui
  • 3,615
  • 2
  • 33
  • 41
Joao Pedro
  • 61
  • 6
  • you saved my ass :) – Al Walid Ashik Nov 26 '18 at 18:27
  • This worked for me, too. Thank you very much. This was wasting a lot of my time. The moral of the story is, if you already have an up-to-date version of MinGW insatlled, don't have Code::Blocks install it again -- otherwise, delete the old MinGW, let Code::Blocks reinstall it, update your path variable(s) as necessary, then Code::Blocks will autodetect MinGW in the right place. Looks like a bug-fix opportunity in Code::Blocks. – Bob Nov 10 '19 at 17:35