gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Errors, please help

#67552 - Maverick - Wed Jan 18, 2006 11:58 pm

hello

i have been trying to compile a slightly cut down version of ethos' sourcecode for lesson 2. The cut down part was removing anything that wasnt there to display the scene

Here is my code:

Code:
#include <nds.h>
#include "..\..\opengl\gl.h"


int main()
{
powerON(POWER_ALL);
videoSetMode(MODE_0_3D);
glViewPort(0,0,255,191);
glClearColor(0,0,0);
glClearDepth(0x7FFF);
while (1) {
glReset();
gluPerspective(35, 256.0 / 192.0, 0.1, 40);
gluLookAt(0.0, 0.0, 1.0,
     0.0, 0.0, 0.0,
     0.0, 1.0, 0.0);
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glColor3f32(intof32(1),intof32(1),intof32(1));
glLoadIdentity();
glTranslate3f32(floatof32(-1.5),0,intof32(-6));
glBegin(GL_TRIANGLES);
glVertex3f32(0, intof32(1), 0);
glVertex3f32(intof32(-1), intof32(-1), 0);
glVertex3f32(intof32( 1), intof32(-1), 0);
glEnd();
glTranslate3f32(intof32(3),0,0);
glBegin(GL_QUADS);
glVertex3f32(intof32(-1), intof32( 1), 0);
glVertex3f32(intof32( 1), intof32( 1), 0);
glVertex3f32(intof32( 1), intof32(-1), 0);
glVertex3f32(intof32(-1), intof32(-1), 0);
glEnd();
glPopMatrix(1);
glFlush();
}
}


And here is the batch file i am using to compile(the arm7.c file is an empty main() btw):

Code:
path=E:\DevKitARM\bin\
arm-elf-gcc -mcpu=arm7tdmi -mtune=arm7tdmi -mthumb-interwork -DARM7 -c arm7.c -oarm7.o
arm-elf-gcc -mthumb-interwork -specs=ds_arm7.specs arm7.o -o arm7.elf
arm-elf-objcopy -O binary arm7.elf arm7.bin
arm-elf-gcc -mcpu=arm9tdmi -mtune=arm9tdmi -mthumb-interwork -DARM9 -IE:\DevKitARM\include\libnds\include -c arm9.c -oarm9.o
arm-elf-gcc -mthumb-interwork -specs=ds_arm9.specs arm9.o -o arm9.elf
arm-elf-objcopy -O binary arm9.elf arm9.bin
ndstool -c arm.nds -9 arm9.bin -7 arm7.bin -b ..\..\icon.bmp "Test;Just a test;To see what it does!" -o ..\..\logo.bin
del *.o *.elf *.bin
pause


And when i compile, i get this:

In file included from arm9.c:2:
..\..\opengl\gl.h:6:1: warning: "f32tot16" redefined
In file included from E:\DevKitARM\include\libnds\include/nds.h:63,
from arm9.c:1:
E:\DevKitARM\include\libnds\include/nds/arm9/videoGL.h:91:1: warning: this is the location of the previous definition
In file included from ..\..\opengl\gl.h:15,
from arm9.c:2:
..\..\opengl\/glRoutines.h:6: error: conflicting types for 'glTranslatef32'
E:\DevKitARM\include\libnds\include/nds/arm9/videoGL.inl:88: error: previous definition of 'glTranslatef32' was here
..\..\opengl\/glRoutines.h:8: error: conflicting types for 'glScalef32'
E:\DevKitARM\include\libnds\include/nds/arm9/videoGL.inl:80: error: previous definition of 'glScalef32' was here

Ive ran out of ideas and was wondering if anybody was able to help, or had sorted this problem for themselves already

Thanks for any help
_________________
http://downtou.ne1.net/

#67587 - HyperHacker - Thu Jan 19, 2006 5:30 am

You sure you're supposed to include the standard gl.h? I haven't used it on DS but it seems unusual. If you are, try switching the order and include gl.h before nds.h. All the errors are complaining of things being defined in one header and redefined in another, so your code probably isn't the problem.

Also, that make script looks like a stripped-down version of mine. Is it? (Don't mind if it is, just curious.)

#67601 - Maverick - Thu Jan 19, 2006 10:35 am

This is the gl libs that came with ethos' source. If i take it out, i get:

arm9.o: In function `main':
arm9.c:(.text+0x50): undefined reference to `glReset'
arm9.c:(.text+0x64): undefined reference to `gluPerspective'
arm9.c:(.text+0xa0): undefined reference to `gluLookAt'
arm9.c:(.text+0xc4): undefined reference to `glColor3f32'
arm9.c:(.text+0xf0): undefined reference to `glVertex3f32'
arm9.c:(.text+0x100): undefined reference to `glVertex3f32'
arm9.c:(.text+0x110): undefined reference to `glVertex3f32'
arm9.c:(.text+0x13c): undefined reference to `glVertex3f32'
arm9.c:(.text+0x14c): undefined reference to `glVertex3f32'
arm9.o:arm9.c:(.text+0x15c): more undefined references to `glVertex3f32' follow

The make was very simple at first and has evolved to this point, strange coincedence that we might code in similar ways.
_________________
http://downtou.ne1.net/

#67760 - HyperHacker - Fri Jan 20, 2006 3:37 am

Great minds think alike I suppose. :-p (Mine's posted in one of my threads if you want to take a look.)

If removing that file gives undefined reference errors, then yeah, you probably want to leave it in. Did you try switching the order of the #includes? Also make sure you're not just missing a semicolon somewhere, that seems to make some compilers just go completely nuts, especially if it's in a header file.

#67802 - Maverick - Fri Jan 20, 2006 2:11 pm

This is what i get when the includes are switched:

In file included from arm9.c:1:
..\..\opengl\gl.h:6:1: warning: "f32tot16" redefined
In file included from E:\DevKitARM\include\libnds\include/NDS.h:63,
from ..\..\opengl\gl.h:4,
from arm9.c:1:
E:\DevKitARM\include\libnds\include/nds/arm9/videoGL.h:91:1: warning: this is th
e location of the previous definition
In file included from ..\..\opengl\gl.h:15,
from arm9.c:1:
..\..\opengl\/glRoutines.h:6: error: conflicting types for 'glTranslatef32'
E:\DevKitARM\include\libnds\include/nds/arm9/videoGL.inl:88: error: previous def
inition of 'glTranslatef32' was here
..\..\opengl\/glRoutines.h:8: error: conflicting types for 'glScalef32'
E:\DevKitARM\include\libnds\include/nds/arm9/videoGL.inl:80: error: previous def
inition of 'glScalef32' was here

I couldnt see any missed ;'s, but hey, i might be wrong

Has anyone managed to get this to work with libnds?
_________________
http://downtou.ne1.net/

#67803 - Maverick - Fri Jan 20, 2006 2:19 pm

If i go into ethos' source and change his glTranslatef32 and glScalef32 to glTranslate3f32 and glScale3f32, then i get this:

E:\DSDev\Mine(libnds)\NeHe\Lesson02>arm-elf-gcc -mcpu=arm9tdmi -mtune=arm9tdmi -
mthumb-interwork -DARM9 -IE:\DevKitARM\include\libnds\include -c arm9.c -oarm9.o

In file included from arm9.c:2:
..\..\opengl\gl.h:6:1: warning: "f32tot16" redefined
In file included from E:\DevKitARM\include\libnds\include/nds.h:63,
from arm9.c:1:
E:\DevKitARM\include\libnds\include/nds/arm9/videoGL.h:91:1: warning: this is th
e location of the previous definition

E:\DSDev\Mine(libnds)\NeHe\Lesson02>arm-elf-gcc -mthumb-interwork -specs=ds_arm9
.specs arm9.o -o arm9.elf
arm9.o: In function `main':
arm9.c:(.text+0x50): undefined reference to `glReset'
arm9.c:(.text+0x64): undefined reference to `gluPerspective'
arm9.c:(.text+0xa0): undefined reference to `gluLookAt'
arm9.c:(.text+0xc4): undefined reference to `glColor3f32'
arm9.c:(.text+0xf0): undefined reference to `glVertex3f32'
arm9.c:(.text+0x100): undefined reference to `glVertex3f32'
arm9.c:(.text+0x110): undefined reference to `glVertex3f32'
arm9.c:(.text+0x13c): undefined reference to `glVertex3f32'
arm9.c:(.text+0x14c): undefined reference to `glVertex3f32'
arm9.o:arm9.c:(.text+0x15c): more undefined references to `glVertex3f32' follow
_________________
http://downtou.ne1.net/

#67905 - tepples - Sat Jan 21, 2006 6:34 am

"undefined reference" usually means you forgot to specify a library to be linked into your arm9.elf file.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#67935 - Maverick - Sat Jan 21, 2006 10:19 am

I know, i think its the videogl.inl file, they are being prototyped but no code is present after this.

Here is my source, if anyone can get it to work with libnds, id love to know how:

http://downtou.ne1.net/ds/source/Lesson02.rar
_________________
http://downtou.ne1.net/


Last edited by Maverick on Mon Jan 23, 2006 5:27 pm; edited 1 time in total

#68289 - Maverick - Mon Jan 23, 2006 4:14 pm

I have got it as far as this by forcing the .c files to be included:


arm9.o: In function `glRotateZi':
arm9.c:(.text+0x9c8): undefined reference to `SIN_bin'
arm9.c:(.text+0x9cc): undefined reference to `COS_bin'
arm9.o: In function `glRotateYi':
arm9.c:(.text+0xab4): undefined reference to `SIN_bin'
arm9.c:(.text+0xab8): undefined reference to `COS_bin'
arm9.o: In function `glRotateXi':
arm9.c:(.text+0xba0): undefined reference to `SIN_bin'
arm9.c:(.text+0xba4): undefined reference to `COS_bin'
arm9.o: In function `glRotatef32i':
arm9.c:(.text+0xeb0): undefined reference to `SIN_bin'
arm9.c:(.text+0xeb4): undefined reference to `COS_bin'
arm9.o: In function `gluPerspectivef32':
arm9.c:(.text+0x25e8): undefined reference to `TAN_bin'
arm9.o: In function `glTexImage2D':
arm9.c:(.text+0x3350): undefined reference to `swiCopy'
arm9.o: In function `glTexLoadPal':
arm9.c:(.text+0x33d4): undefined reference to `swiCopy'

But cannot get any further. I have updated the source code download. Is anyone able to help?
_________________
http://downtou.ne1.net/

#68290 - Normmatt - Mon Jan 23, 2006 4:33 pm

your link doesnt seem to work

#68300 - Maverick - Mon Jan 23, 2006 5:28 pm

Sorry, fixed
_________________
http://downtou.ne1.net/