Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile for libcamera #25

Closed
ojio-san opened this issue Mar 26, 2024 · 6 comments
Closed

Can't compile for libcamera #25

ojio-san opened this issue Mar 26, 2024 · 6 comments

Comments

@ojio-san
Copy link

ojio-san commented Mar 26, 2024

Hello there,

I'm trying to build the libcamera project (0.2.0+rpt20240215) but this libpisp is causing me an issue :

165.0 ninja: job failed: g++ -Isubprojects/libpisp/src/libpisp.so.1.0.4.p -Isubprojects/libpisp/src -I../subprojects/libpisp/src -Isubprojects/libpisp/src/libpisp -I../subprojects/libpisp/src/libpisp -I../subprojects/nlohmann_json-3.11.2/single_include -I/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c++17 -O0 -g -DPISP_LOGGING_ENABLE=1 -DBOOST_BIND_GLOBAL_PLACEHOLDERS -Os -fstack-clash-protection -Wformat -Werror=format-security -D_GLIBCXX_ASSERTIONS=1 -D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1 -D_LIBCPP_ENABLE_HARDENED_MODE=1 -fPIC -pthread -DBOOST_LOG_DYN_LINK=1 -DBOOST_LOG_SETUP_DYN_LINK=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_THREAD_USE_DLL=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_ALL_NO_LIB -MD -MQ subprojects/libpisp/src/libpisp.so.1.0.4.p/libpisp_backend_backend_default_config.cpp.o -MF subprojects/libpisp/src/libpisp.so.1.0.4.p/libpisp_backend_backend_default_config.cpp.o.d -o subprojects/libpisp/src/libpisp.so.1.0.4.p/libpisp_backend_backend_default_config.cpp.o -c ../subprojects/libpisp/src/libpisp/backend/backend_default_config.cpp
165.0 ../subprojects/libpisp/src/libpisp/backend/backend_default_config.cpp: In function 'bool {anonymous}::is_installed()':
165.0 ../subprojects/libpisp/src/libpisp/backend/backend_default_config.cpp:37:32: error: '_DYNAMIC' was not declared in this scope; did you mean 'PT_DYNAMIC'?
165.0 37 | const ElfW(Dyn) *dyn = _DYNAMIC;
165.0 | ^~~~~~~~
165.0 | PT_DYNAMIC
221.7 ninja: subcommand failed

More output here : https://pastebin.com/raw/3hbXBdVh and here https://pastebin.com/raw/yTvEfUVG

Environment : alpine 3.19 on armv6

Any advices ? Thank you :)

@naushir
Copy link
Collaborator

naushir commented Mar 27, 2024

_DYNAMIC is defined in link.h, which is #included in the file. Not sure why you are seeing this error message. Can you check the contents of /usr/include/link.h and see if the definition exists?

@ojio-san
Copy link
Author

ojio-san commented Mar 27, 2024

Hello and thank you for your reply :)

Unfortunately, I can't find the _DYNAMIC in the file : /usr/include/link.h

You can download the musl-dev package on the alpine repository here : https://dl-cdn.alpinelinux.org/alpine/v3.19/main/armv7/musl-dev-1.2.4_git20230717-r4.apk which contains the /usr/include/link.h file.

Nevertheless, this is the content of this file :

#ifndef _LINK_H
#define _LINK_H

#ifdef __cplusplus
extern "C" {
#endif

#include <elf.h>
#define __NEED_size_t
#define __NEED_uint32_t
#include <bits/alltypes.h>

#if UINTPTR_MAX > 0xffffffff
#define ElfW(type) Elf64_ ## type
#else
#define ElfW(type) Elf32_ ## type
#endif

#include <bits/link.h>

struct dl_phdr_info {
	ElfW(Addr) dlpi_addr;
	const char *dlpi_name;
	const ElfW(Phdr) *dlpi_phdr;
	ElfW(Half) dlpi_phnum;
	unsigned long long int dlpi_adds;
	unsigned long long int dlpi_subs;
	size_t dlpi_tls_modid;
	void *dlpi_tls_data;
};

struct link_map {
	ElfW(Addr) l_addr;
	char *l_name;
	ElfW(Dyn) *l_ld;
	struct link_map *l_next, *l_prev;
};

struct r_debug {
	int r_version;
	struct link_map *r_map;
	ElfW(Addr) r_brk;
	enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
	ElfW(Addr) r_ldbase;
};

int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *);

#ifdef __cplusplus
}
#endif

#endif

@pinchartl
Copy link
Collaborator

In libcamera, we have

/* musl doesn't declare _DYNAMIC in link.h, declare it manually. */
extern ElfW(Dyn) _DYNAMIC[];

@naushir
Copy link
Collaborator

naushir commented Mar 28, 2024

Thanks @pinchartl I'll add that declaration and hopefully it should fix this issue.

@naushir
Copy link
Collaborator

naushir commented Mar 28, 2024

#26 is now merged. Please do give it a try and let me know if it is fixed.

Environment : alpine 3.19 on armv7

I'm curious what platform you are running this on? libpisp is only really relevant for Pi 5 (armv8). So perhaps your libcamera meson build config should not include rpi/pisp support?

@ojio-san
Copy link
Author

ojio-san commented Mar 28, 2024

=> This is now building fine with your last commit on main branch!

So, I am building packages for https://github.com/raspberrypi/rpicam-apps and https://github.com/raspberrypi/libcamera

And I am trying to cross compiling from amd64 (debian) with docker buildx to armv6 on alpine linux (sorry I said armv7 in the first post) : for a rpi0 on alpine linux. Sadly no one seems to distribute packages for alpine, only for rpi os.

I have successfully built v1.2.1 and libcamera 0.1.0+rpt20231122, but thoses new versions are giving me quite a hard time.

You said that maybe I don't need this, so now I am trying to rebuild the libcamera package with :

meson setup --prefix=/usr build --buildtype=release -Dpipelines=rpi/vc4 -Dipas=rpi/vc4 -Dv4l2=true -Dgstreamer=disabled -Dtest=false -Dlc-compliance=disabled -Dcam=disabled -Dqcam=disabled -Ddocumentation=disabled -Dpycamera=disabled

If it will work, that should mean that this is a false issue and the last commit on the main branch should maybe not be there

--
EDIT : building works fine with meson setup line up here, and building rpicam-apps with this dependency too. thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants