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

Post Reply
Cyfer_Ninja_3006
Posts: 3
Joined: Wed Jan 22, 2020 9:30 pm

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

Post by Cyfer_Ninja_3006 » Fri Mar 20, 2020 8:00 pm

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

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 103
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

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

Post by fincs » 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
Donate to devkitPro - help us stay alive!

Cyfer_Ninja_3006
Posts: 3
Joined: Wed Jan 22, 2020 9:30 pm

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

Post by Cyfer_Ninja_3006 » Sat Mar 21, 2020 3:51 pm

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.

Cyfer_Ninja_3006
Posts: 3
Joined: Wed Jan 22, 2020 9:30 pm

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

Post by Cyfer_Ninja_3006 » Sat Mar 21, 2020 4:53 pm

My code (https://gist.github.com/oxi0de69/bcd777 ... 27a6747dea) causes my console to crash and load onto the "an exception occurred error screen"

User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 103
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

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

Post by fincs » Sun Mar 22, 2020 1:59 am

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.
Donate to devkitPro - help us stay alive!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests