Search code examples
opengldstatic-linking

trouble linking to libglut.a in D


I have a simple openGL D program that compiles, but I can't get it to link with libglut.a. I've tried a few different command lines:

$ dmd life.d -lglut
$ dmd life.d -L-lglut
$ dmd life.d -L/usr/lib/libglut.a
$ dmd life.d /usr/lib/libglut.a

All of these print the following errors:

life.o:(.data+0x10): undefined reference to `_D1c2gl4glut12__ModuleInfoZ'
life.o:(.data+0x14): undefined reference to `_D1c2gl2gl12__ModuleInfoZ'
life.o: In function `_Dmain':
life.d:(.text._Dmain+0x72): undefined reference to `_D1c2gl4glut8glutInitT1c2gl4glut10pfglutInit'
life.d:(.text._Dmain+0x87): undefined reference to `_D1c2gl4glut19glutInitDisplayModeT1c2gl4glut21pfglutInitDisplayMode'
life.d:(.text._Dmain+0xa1): undefined reference to `_D1c2gl4glut18glutInitWindowSizeT1c2gl4glut20pfglutInitWindowSize'
life.d:(.text._Dmain+0xc2): undefined reference to `_D1c2gl4glut16glutCreateWindowT1c2gl4glut18pfglutCreateWindow'
life.d:(.text._Dmain+0xd7): undefined reference to `_D1c2gl4glut15glutDisplayFuncT1c2gl4glut17pfglutDisplayFunc'
life.d:(.text._Dmain+0xe6): undefined reference to `_D1c2gl4glut12glutMainLoopT1c2gl4glut14pfglutMainLoop'
collect2: ld returned 1 exit status
--- errorlevel 1

Is there a problem with my command lines, or is it something else?


Solution

  • Those look like mangled symbols from D code. You mentioned on your previous question that you were using some kind of compatibility layer – did you make sure to include the files or libraries from that in your build?