Homebrew Homebrew app View video on Nintendo Switch

Luigi31

Member
OP
Newcomer
Joined
May 3, 2023
Messages
14
Trophies
0
Age
15
XP
222
Country
France
Hello / good evening, recently I looked into the development of hombrew application for switch. I wanted to start very simply so I tried to display a video with FFmpg + SDL2. But when compiling I get this:

Code:
linking Rickroll2000.elf

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.o: in function `main':

main.cpp:(.text.startup.main+0xf8): undefined reference to `av_register_all()'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x118): undefined reference to `avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x128): undefined reference to `avformat_find_stream_info(AVFormatContext*, AVDictionary**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x17c): undefined reference to `avcodec_find_decoder(AVCodecID)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x184): undefined reference to `avcodec_alloc_context3(AVCodec const*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x190): undefined reference to `avcodec_parameters_to_context(AVCodecContext*, AVCodecParameters const*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x1a4): undefined reference to `avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x1fc): undefined reference to `av_frame_alloc()'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x204): undefined reference to `av_packet_alloc()'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x214): undefined reference to `av_packet_unref(AVPacket*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x220): undefined reference to `av_read_frame(AVFormatContext*, AVPacket*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x240): undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x24c): undefined reference to `avcodec_receive_frame(AVCodecContext*, AVFrame*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2a8): undefined reference to `av_frame_free(AVFrame**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2b0): undefined reference to `av_packet_free(AVPacket**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2bc): undefined reference to `avcodec_close(AVCodecContext*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2c4): undefined reference to `avformat_close_input(AVFormatContext**)'

collect2.exe: error: ld returned 1 exit status

make[1]: *** [/opt/devkitpro/libnx/switch_rules:81: /home/mpopc/Desktop/Rickroll2000/Rickroll2000.elf] Error 1

make: *** [Makefile:160: build] Error 2

I think it comes from the make file, by the way if you need it, here it is:

Makefile:
ARCH    :=    -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE

CFLAGS    :=    `$(PREFIX)pkg-config --cflags sdl2 SDL2_mixer SDL2_image` -Wall -O2 -ffunction-sections \
            $(ARCH) $(DEFINES)

CFLAGS    +=    $(INCLUDE) -D__SWITCH__

CXXFLAGS    := $(CFLAGS) -std=c++14

ASFLAGS    :=    -g $(ARCH)
LDFLAGS    =    -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS    :=    `$(PREFIX)pkg-config --libs sdl2 SDL2_mixer SDL2_image SDL2_ttf` \
            -lavformat -lavcodec -lswresample -lswscale -lavutil -lbz2 -lass -ltheora -lvorbis -logg -lz -lnx

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS    := $(PORTLIBS) $(LIBNX)

I didn't give the whole makefile because I think the rest is useless.
Does anyone know about it and can explain to me why the references are indefinite ?
Thanks in advance for your reply.
 

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,373
Trophies
4
Location
Space
XP
13,977
Country
Norway
Hello / good evening, recently I looked into the development of hombrew application for switch. I wanted to start very simply so I tried to display a video with FFmpg + SDL2. But when compiling I get this:

Code:
linking Rickroll2000.elf

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.o: in function `main':

main.cpp:(.text.startup.main+0xf8): undefined reference to `av_register_all()'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x118): undefined reference to `avformat_open_input(AVFormatContext**, char const*, AVInputFormat*, AVDictionary**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x128): undefined reference to `avformat_find_stream_info(AVFormatContext*, AVDictionary**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x17c): undefined reference to `avcodec_find_decoder(AVCodecID)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x184): undefined reference to `avcodec_alloc_context3(AVCodec const*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x190): undefined reference to `avcodec_parameters_to_context(AVCodecContext*, AVCodecParameters const*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x1a4): undefined reference to `avcodec_open2(AVCodecContext*, AVCodec const*, AVDictionary**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x1fc): undefined reference to `av_frame_alloc()'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x204): undefined reference to `av_packet_alloc()'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x214): undefined reference to `av_packet_unref(AVPacket*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x220): undefined reference to `av_read_frame(AVFormatContext*, AVPacket*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x240): undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x24c): undefined reference to `avcodec_receive_frame(AVCodecContext*, AVFrame*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2a8): undefined reference to `av_frame_free(AVFrame**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2b0): undefined reference to `av_packet_free(AVPacket**)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2bc): undefined reference to `avcodec_close(AVCodecContext*)'

C:/devkitPro/devkitA64/bin/../lib/gcc/aarch64-none-elf/13.1.0/../../../../aarch64-none-elf/bin/ld.exe: main.cpp:(.text.startup.main+0x2c4): undefined reference to `avformat_close_input(AVFormatContext**)'

collect2.exe: error: ld returned 1 exit status

make[1]: *** [/opt/devkitpro/libnx/switch_rules:81: /home/mpopc/Desktop/Rickroll2000/Rickroll2000.elf] Error 1

make: *** [Makefile:160: build] Error 2

I think it comes from the make file, by the way if you need it, here it is:

Makefile:
ARCH    :=    -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE

CFLAGS    :=    `$(PREFIX)pkg-config --cflags sdl2 SDL2_mixer SDL2_image` -Wall -O2 -ffunction-sections \
            $(ARCH) $(DEFINES)

CFLAGS    +=    $(INCLUDE) -D__SWITCH__

CXXFLAGS    := $(CFLAGS) -std=c++14

ASFLAGS    :=    -g $(ARCH)
LDFLAGS    =    -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS    :=    `$(PREFIX)pkg-config --libs sdl2 SDL2_mixer SDL2_image SDL2_ttf` \
            -lavformat -lavcodec -lswresample -lswscale -lavutil -lbz2 -lass -ltheora -lvorbis -logg -lz -lnx

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS    := $(PORTLIBS) $(LIBNX)

I didn't give the whole makefile because I think the rest is useless.
Does anyone know about it and can explain to me why the references are indefinite ?
Thanks in advance for your reply.
Do you have libavcodec and related libraries?
 

Luigi31

Member
OP
Newcomer
Joined
May 3, 2023
Messages
14
Trophies
0
Age
15
XP
222
Country
France
It's mentioned here that av_register_all has been deprecated :
https://github.com/leandromoreira/ffmpeg-libav-tutorial/issues/29

There seems to be missing something or not referenced.
Maybe there are some hints here :
https://github.com/leandromoreira/ffmpeg-libav-tutorial/issues/27
Thank you for your answer, I think the problem comes from the fact that I am not the lib.
Do you have libavcodec and related libraries?
Thank you for your answer. I don't think I have the libs, because when I run the command
Code:
pacman -Ss libavacodec
it does not return anything to me, unless it is not this command that must be executed 😅.
Even when I try to install the package with this command:
Code:
pacman -S libavacodec
gives me an error that the packet is not found.
What command should I use to install this lib ?
 

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,373
Trophies
4
Location
Space
XP
13,977
Country
Norway
Thank you for your answer, I think the problem comes from the fact that I am not the lib.

Thank you for your answer. I don't think I have the libs, because when I run the command
Code:
pacman -Ss libavacodec
it does not return anything to me, unless it is not this command that must be executed 😅.
Even when I try to install the package with this command:
Code:
pacman -S libavacodec
gives me an error that the packet is not found.
What command should I use to install this lib ?
libavcodec, not libavacodec
From your makefile:
LIBS := `$(PREFIX)pkg-config --libs sdl2 SDL2_mixer SDL2_image SDL2_ttf` \
-lavformat -lavcodec -lswresample -lswscale -lavutil -lbz2 -lass -ltheora -lvorbis -logg -lz -lnx
Make sure you have all of these. Most of them are probably separate packages. But you need devkitPro/ARM64 specific versions, devkitPro can not use normal packages installed on your Linux system.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
  • BigOnYa @ BigOnYa:
    Biomutant looks cool tho, may have to try that
  • Quincy @ Quincy:
    Usually when such a big title leaks the Temp will be the first to report about it (going off of historical reports here, Pokemon SV being the latest one I can recall seeing pop up here)
  • K3Nv2 @ K3Nv2:
    I still like how a freaking mp3 file hacks webos all that security defeated by text yet again
  • BigOnYa @ BigOnYa:
    They have simulators for everything nowdays, cray cray. How about a sim that shows you playing the Switch.
  • K3Nv2 @ K3Nv2:
    That's called yuzu
    +1
  • BigOnYa @ BigOnYa:
    I want a 120hz 4k tv but crazy how more expensive the 120hz over the 60hz are. Or even more crazy is the price of 8k's.
  • K3Nv2 @ K3Nv2:
    No real point since movies are 30fps
  • BigOnYa @ BigOnYa:
    Not a big movie buff, more of a gamer tbh. And Series X is 120hz 8k ready, but yea only 120hz 4k games out right now, but thinking of in the future.
  • K3Nv2 @ K3Nv2:
    Mostly why you never see TV manufacturers going post 60hz
  • BigOnYa @ BigOnYa:
    I only watch tv when i goto bed, it puts me to sleep, and I have a nas drive filled w my fav shows so i can watch them in order, commercial free. I usually watch Married w Children, or South Park
  • K3Nv2 @ K3Nv2:
    Stremio ruined my need for nas
  • BigOnYa @ BigOnYa:
    I stream from Nas to firestick, one on every tv, and use Kodi. I'm happy w it, plays everything. (I pirate/torrent shows/movies on pc, and put on nas)
  • K3Nv2 @ K3Nv2:
    Kodi repost are still pretty popular
  • BigOnYa @ BigOnYa:
    What the hell is Kodi reposts? what do you mean, or "Wut?" -xdqwerty
  • K3Nv2 @ K3Nv2:
    Google them basically web crawlers to movie sites
  • BigOnYa @ BigOnYa:
    oh you mean the 3rd party apps on Kodi, yea i know what you mean, yea there are still a few cool ones, in fact watched the new planet of the apes movie other night w wifey thru one, was good pic surprisingly, not a cam
  • BigOnYa @ BigOnYa:
    Damn, only $2.06 and free shipping. Gotta cost more for them to ship than $2.06
  • BigOnYa @ BigOnYa:
    I got my Dad a firestick for Xmas and showed him those 3rd party sites on Kodi, he loves it, all he watches anymore. He said he has got 3 letters from AT&T already about pirating, but he says f them, let them shut my internet off (He wants out of his AT&T contract anyways)
  • K3Nv2 @ K3Nv2:
    That's where stremio comes to play never got a letter about it
  • BigOnYa @ BigOnYa:
    I just use a VPN, even give him my login and password so can use it also, and he refuses, he's funny.
  • BigOnYa @ BigOnYa:
    I had to find and get him an old style flip phone even without text, cause thats what he wanted. No text, no internet, only phone calls. Old, old school.
    K3Nv2 @ K3Nv2: @BigOnYa...