Page 1 of 1

Im getting the "undefined reference to [i]function[/i] when using citro2d

Posted: Fri Mar 20, 2020 8:00 pm
by Cyfer_Ninja_3006
I was testing some stuff will citro2d, but when i compile it, cmd return these errors

Code: Select all

c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: main.o: in function `main':
C:/Users/<usrnme>/Desktop/ShinMegamiGinsei/source/main.cpp:16: undefined reference to `C2D_Init'
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: C:/Users/<usrnme>/Desktop/ShinMegamiGinsei/source/main.cpp:17: undefined reference to `C2D_Prepare'
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: C:/Users/<usrnme>/Desktop/ShinMegamiGinsei/source/main.cpp:25: undefined reference to `C2D_CreateScreenTarget'
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: C:/Users/<usrnme>/Desktop/ShinMegamiGinsei/source/main.cpp:34: undefined reference to `C2D_TargetClear'
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: main.o: in function `C2D_SceneBegin':
C:/devkitPro/libctru/include/c2d/base.h:243: undefined reference to `C2D_Flush'
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: main.o: in function `C2D_SceneTarget':
C:/devkitPro/libctru/include/c2d/base.h:222: undefined reference to `C2D_SceneSize'
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: main.o: in function `main':
C:/Users/<usrnme>/Desktop/ShinMegamiGinsei/source/main.cpp:43: undefined reference to `C2D_DrawRectangle'
c:/devkitpro/devkitarm/bin/../lib/gcc/arm-none-eabi/9.1.0/../../../../arm-none-eabi/bin/ld.exe: C:/Users/<usrnme>/Desktop/ShinMegamiGinsei/source/main.cpp:61: undefined reference to `C2D_Fini'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [/opt/devkitpro/devkitARM/3ds_rules:42: /home/<usrnme>/Desktop/ShinMegamiGinsei/ShinMegamiGinsei.elf] Error 1
make: *** [Makefile:165: all] Error 2
I have added the <citro2d.h> and <citro3d.h> headers and this still persists

Re: Im getting the "undefined reference to [i]function[/i] when using citro2d

Posted: Fri Mar 20, 2020 10:10 pm
by fincs
Make sure the LIBS in your Makefile looks like this:

Code: Select all

LIBS	:= -lcitro2d -lcitro3d -lctru -lm

Re: Im getting the "undefined reference to [i]function[/i] when using citro2d

Posted: Sat Mar 21, 2020 3:51 pm
by Cyfer_Ninja_3006
fincs wrote: Fri Mar 20, 2020 10:10 pm Make sure the LIBS in your Makefile looks like this:

Code: Select all

LIBS	:= -lcitro2d -lcitro3d -lctru -lm
Omg, it worked, I love you guys! I would donate but im only 14 and my parents wont allow me to spend money online.

Re: Im getting the "undefined reference to [i]function[/i] when using citro2d

Posted: Sat Mar 21, 2020 4:53 pm
by Cyfer_Ninja_3006
My code (https://gist.github.com/oxi0de69/bcd777 ... 27a6747dea) causes my console to crash and load onto the "an exception occurred error screen"

Re: Im getting the "undefined reference to [i]function[/i] when using citro2d

Posted: Sun Mar 22, 2020 1:59 am
by fincs
A few things:
  • When using citro3d or citro2d, you mustn't call the following functions; remove these calls:

    Code: Select all

    		gfxFlushBuffers();
    		gfxSwapBuffers();
    		gspWaitForVBlank();
  • You're missing a call to C3D_FrameEnd(0) in your main loop. Place said function call after you're done drawing.
  • The main loop should be ordered like this: 1) get and process input; 2) do the rendering.