pikvm / ustreamer

µStreamer - Lightweight and fast MJPEG-HTTP streamer
https://pikvm.org
GNU General Public License v3.0
1.71k stars 230 forks source link

Failed to build on openwrt - encoder.c:(.text+0x2dc): undefined reference to `frame_copy_meta' #121

Closed JohnTar22 closed 3 years ago

JohnTar22 commented 3 years ago

as described in the title, can't get the package to build using openwrt build system. getting "encoder.c:(.text+0x2dc): undefined reference to `frame_copy_meta'"

i've installed the deps on host pc, ran the make WITH_PTHREAD_NP=0.

but still getting errors.

any help will be much appreciated.

john.

mdevaev commented 3 years ago

Try to use GNU Make

JohnTar22 commented 3 years ago

I am using GNU Make 4.2.1, the native make that comes with ubuntu 20.04, the target board is not raspberry pi, maybe that's the problem?

mdevaev commented 3 years ago

ustreamer works on any platform, I use it on arch/x86_64.

If you can build it on ubuntu outside of openwrt, then there is something wrong with the build system. I don't know much about openwrt and I can't say what could have broken there.

First, try building on ubuntu from the README to make sure that it works at all.

aggieNick02 commented 3 years ago

Just FYI, I build on ubuntu 20 just fine

JohnTar22 commented 3 years ago

True, on x64 it works fine.

On Wed, Sep 8, 2021 at 8:41 PM aggieNick02 @.***> wrote:

Just FYI, I build on ubuntu 20 just fine

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pikvm/ustreamer/issues/121#issuecomment-915439451, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUDSCYOLIRYSQC66E6RPTKTUA6N33ANCNFSM5CL5QBTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kaizensparc commented 3 years ago

Hello, I got the same issue. Seems the frame_copy_meta is defined in https://github.com/pikvm/ustreamer/blob/2d82adb2ba6fcf68530f00f1bcee89302d2a3731/src/libs/frame.h#L71

As per C11 (6.7.4 Function specifiers, line 7):

An inline definition does not provide an external definition for the function,
and does not forbid an external definition in another translation unit. An inline definition
provides an alternative to an external definition, which a translator may use to implement
any call to the function in the same translation unit. It is unspecified whether a call to the
function uses the inline definition or the external definition.

This explains why those inline definitions are compiling on some compilers with some optimizations but not everytime. Sometimes the compiler decides to use this internal definition, sometimes it decides to wait until it gets the external one (but there is none).

A quick fix would be to let the compiler do the optimizations by itself by not inlining the function and defining it as static also :)

From what I can experiment it is the only reference that has this issue in practice but all the inline definitions in this file are also impacted.

mdevaev commented 3 years ago

How can I reproduce it? Which GCC flags should I use?

gendalf commented 3 years ago

The same error, while build with openwrt 21.02

.../../../../../aarch64-openwrt-linux-musl/bin/ld: build/libs/unjpeg.o: in function `unjpeg':
unjpeg.c:(.text+0x31c): undefined reference to `frame_copy_meta'
.../../../../../aarch64-openwrt-linux-musl/bin/ld: build/ustreamer/encoder.o: in function `_worker_run_job':
encoder.c:(.text+0x2b4): undefined reference to `frame_copy_meta'

flags:

WITH_OMX=0 WITH_PTHREAD_NP=0 make -C /openwrt/build_dir/target-aarch64_cortex-a72_musl/ustreamer-4.7 CC="aarch64-openwrt-linux-musl-gcc" CFLAGS="-Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/openwrt/build_dir/target-aarch64_cortex-a72_musl/ustreamer-4.7=ustreamer-4.7 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/firmware/opt/vc/include -Wall"