Homebrew Homebrew app View video on Nintendo Switch

Luigi31

Member
OP
Newcomer
Joined
May 3, 2023
Messages
14
Trophies
0
Age
15
XP
200
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,296
Trophies
4
Location
Space
XP
13,861
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
200
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,296
Trophies
4
Location
Space
XP
13,861
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
    K3Nv2 @ K3Nv2: It's a shame some people's cake always resort to the same taste