Open thecodechemist99 opened 1 year ago
Hi @thecodechemist99! Thank you for the well-written issue, that is very helpful. Would you like to open a PR for this?
Do you have any ideas regarding the string.h
error?
I'm not very well versed in C, unfortunately and the bug seems to come from the vendor C code(?).
@thecodechemist99 The error says, "fatal error: 'string.h' file not found". I think it is something with your compilation path. It just needs the C header file "string.h" which is usually found in your OS wherever there is a compiler available.
On a quick search, I could find this header file in a few places in my computer:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h
/opt/homebrew/opt/llvm/include/c++/v1/string.h
FYI, I'm not actively maintaining this project anymore: https://github.com/rafaelcaricio/lvgl-rs#-lvgl---open-source-embedded-gui-library-in-rust
In case it helps, the implementation of this header is done in Rust and is available here: https://github.com/rafaelcaricio/lvgl-rs/blob/master/lvgl-sys/src/string_impl.rs The linker will use this implementation.
Hi! Is this issue still happening? A lot has been churned in this library including an update to LVGL 8.x, so if you're still interested @thecodechemist99 let me know if this is still reproducible. Note that there have been major API-breaking changes since this issue was opened.
Hi! Thanks for the update, I gave it another try and now get another error about a missing SDL header file:
❯ cargo build
Compiling lvgl-sys v0.5.2 (https://github.com/rafaelcaricio/lvgl-rs?branch=master#c0263a29)
The following warnings were emitted during compilation:
warning: In file included from /Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/vendor/lv_drivers/sdl/sdl_common.c:8:
warning: /Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/vendor/lv_drivers/sdl/sdl_common_internal.h:21:10: fatal error: 'SDL2/SDL.h' file not found
warning: #include SDL_INCLUDE_PATH
warning: ^~~~~~~~~~~~~~~~
warning: /Users/thecodechemist99/Repos/pi-pico-mp/src/ui/lv_drv_conf.h:109:31: note: expanded from macro 'SDL_INCLUDE_PATH'
warning: # define SDL_INCLUDE_PATH <SDL2/SDL.h>
warning: ^~~~~~~~~~~~
warning: <scratch space>:380:1: note: expanded from here
warning: <SDL2/SDL.h>
warning: ^~~~~~~~~~~~
warning: 1 error generated.
error: failed to run custom build command for `lvgl-sys v0.5.2 (https://github.com/rafaelcaricio/lvgl-rs?branch=master#c0263a29)`
I included the current git version of lvgl-rs
:
lvgl = { git = "https://github.com/rafaelcaricio/lvgl-rs", branch = "master" }
and used the lv_conf.h
and Lv_drv_conf.h
header files from the official example.
Trying to run the official demo directly as described in the Readme file yielded the same result.
Edit: So far I haven't implemented any code regarding the library. I only added the library to Cargo.toml
and added the following to config.toml
:
[features]
# Workaround for lvgl-rs with no_std
default = ["build_dep"]
[env]
DEP_LV_CONFIG_PATH = { value = "src/ui", relative = true }
That's caused by the drivers
feature. Try running the demo
example with --features="alloc embedded_graphics" --no-default-features
, or set the LVGL_INCLUDE
environment variable to wherever SDL headers are (by default, it should look in /usr/include
and /usr/local/include
)
Thanks, the demo ran successfully with this:
DEP_LV_CONFIG_PATH=`pwd`/examples/include cargo run --example demo --features="alloc embedded_graphics" --no-default-features
I changed the settings in my project accordingly to:
[features]
# Workaround for lvgl-rs with no_std
default = ["build_dep", "embedded_graphics"]
[env]
DEP_LV_CONFIG_PATH = { value = "src/ui", relative = true }
LVGL_INCLUDE = "/opt/homebrew/include"
This resolved the previous error (the homebrew location is different on Apple-Silicon Macs), but the compiler complains about more. Shouldn't this have default features disabled and therefore ignore the drivers
feature? Doesn’t look like it does:
The following warnings were emitted during compilation:
warning: /Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/vendor/lv_drivers/display/fbdev.c:26:10: fatal error: 'linux/fb.h' file not found
warning: #include <linux/fb.h>
warning: ^~~~~~~~~~~~
warning: 1 error generated.
error: failed to run custom build command for `lvgl-sys v0.5.2 (https://github.com/rafaelcaricio/lvgl-rs?branch=master#c0263a29)`
[…]
warning: build failed, waiting for other jobs to finish...
The following warnings were emitted during compilation:
warning: In file included from /opt/homebrew/include/SDL2/SDL_main.h:25,
warning: from /opt/homebrew/include/SDL2/SDL.h:32,
warning: from /Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/vendor/lv_drivers/sdl/sdl_common_internal.h:21,
warning: from /Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/vendor/lv_drivers/sdl/sdl_common.c:8:
warning: /opt/homebrew/include/SDL2/SDL_stdinc.h:382:42: error: static assertion failed: "sizeof(SDL_DUMMY_ENUM) == sizeof(int)"
warning: 382 | #define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
warning: | ^~~~~~~~~~~~~~
warning: /opt/homebrew/include/SDL2/SDL_stdinc.h:420:1: note: in expansion of macro 'SDL_COMPILE_TIME_ASSERT'
warning: 420 | SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
warning: | ^~~~~~~~~~~~~~~~~~~~~~~
error: failed to run custom build command for `lvgl-sys v0.5.2 (https://github.com/rafaelcaricio/lvgl-rs?branch=master#c0263a29)`
Oof, that's on me. It really should have, I'll make sure to fix that asap. In the meantime try setting line 11 in the driver config to 0 and let me know if it builds.
Can you post your Cargo.toml
?
Fixed the driver issue … now we’re back to the original problem:
--- stderr
/Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/vendor/lvgl/src/misc/lv_mem.h:20:10: fatal error: 'string.h' file not found
thread 'main' panicked at 'Unable to generate bindings: ClangDiagnostic("/Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/vendor/lvgl/src/misc/lv_mem.h:20:10: fatal error: 'string.h' file not found\n")', /Users/thecodechemist99/.cargo/git/checkouts/lvgl-rs-27f20f23afade818/c0263a2/lvgl-sys/build.rs:222:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
You can check out my Cargo.toml
here: https://github.com/thecodechemist99/pi-pico-mp/blob/lvgl-test/Cargo.toml.
Unfortunately, that yields exactly the same result.
Is there a string.h
file at that location on your device? The README says to install various C libraries, but I'm unsure how they translate to macOS
Is there a
string.h
file at that location on your device?
Yes, there is. Sorry, I forgot to mention that.
Edit: Which README?
Yes, there is. Sorry, I forgot to mention that.
That's... very weird. I'll try a patch on a new branch in a second.
Edit: Which README?
Try branch fix-str-import
Hi, unfortunately, this doesn’t help either. Still the same error.
Here’s the content of the string.h
file, in case that helps:
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STRING_H
#define _LIBCPP_STRING_H
/*
string.h synopsis
Macros:
NULL
Types:
size_t
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
void* memmove(void* s1, const void* s2, size_t n);
char* strcpy (char* restrict s1, const char* restrict s2);
char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
char* strcat (char* restrict s1, const char* restrict s2);
char* strncat(char* restrict s1, const char* restrict s2, size_t n);
int memcmp(const void* s1, const void* s2, size_t n);
int strcmp (const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
int strcoll(const char* s1, const char* s2);
size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
const void* memchr(const void* s, int c, size_t n);
void* memchr( void* s, int c, size_t n);
const char* strchr(const char* s, int c);
char* strchr( char* s, int c);
size_t strcspn(const char* s1, const char* s2);
const char* strpbrk(const char* s1, const char* s2);
char* strpbrk( char* s1, const char* s2);
const char* strrchr(const char* s, int c);
char* strrchr( char* s, int c);
size_t strspn(const char* s1, const char* s2);
const char* strstr(const char* s1, const char* s2);
char* strstr( char* s1, const char* s2);
char* strtok(char* restrict s1, const char* restrict s2);
void* memset(void* s, int c, size_t n);
char* strerror(int errnum);
size_t strlen(const char* s);
*/
#include <__config>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
#include_next <string.h>
// MSVCRT, GNU libc and its derivates may already have the correct prototype in
// <string.h>. This macro can be defined by users if their C library provides
// the right signature.
#if defined(__CORRECT_ISO_CPP_STRING_H_PROTO) || defined(_LIBCPP_MSVCRT) || \
defined(__sun__) || defined(_STRING_H_CPLUSPLUS_98_CONFORMANCE_)
#define _LIBCPP_STRING_H_HAS_CONST_OVERLOADS
#endif
#if defined(__cplusplus) && !defined(_LIBCPP_STRING_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
extern "C++" {
inline _LIBCPP_INLINE_VISIBILITY
char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY
char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
const char* strpbrk(const char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
char* strpbrk( char* __s1, const char* __s2) {return __libcpp_strpbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY
char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
const char* strrchr(const char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
char* strrchr( char* __s, int __c) {return __libcpp_strrchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY
void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
void* memchr( void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
inline _LIBCPP_INLINE_VISIBILITY
char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
const char* strstr(const char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
char* strstr( char* __s1, const char* __s2) {return __libcpp_strstr(__s1, __s2);}
}
#endif
#endif // _LIBCPP_STRING_H
Unfortunately I can't look at this more until tomorrow, but off the top of my head, #53 successfully cross-compiled to a similar triple by using cross
; if nothing there proves useful, I'll spin up a macOS VM and try to debug this.
Original Issue
I tried to compile a project with
lvgl = "0.5.2"
and got the following cargo build error:Suggested Solution
As outlined in the rust docs, the Module
alloc::sync
is not implemented by all platforms and thethumbv6m-none-eabi
target is one of them. This is also mentioned in thecstr_core
docs, together with a suggested solution:So I forked the lvgl-rs repo and changed the dependency in
lvgl/Cargo.toml
:With this change the crate
cstr_core
now compiles just fine during cargo build.I'm planning to create a pull request with this change, but first there is another issue to be resolved.
New Issue
I can now implement the patched library via one of these options:
But in both cased I get a new error. The propably most interesting/useful part:
Full error log: