Skip to content

build: Add support building with msvc#59

Open
lygstate wants to merge 10 commits into
lvgl:masterfrom
lygstate:msvc
Open

build: Add support building with msvc#59
lygstate wants to merge 10 commits into
lvgl:masterfrom
lygstate:msvc

Conversation

@lygstate
Copy link
Copy Markdown

@lygstate lygstate commented May 10, 2026

        "-DCMAKE_PREFIX_PATH=C:/work/vcpkg/packages/zlib_x64-windows;C:/work/vcpkg/packages/curl_x64-windows;C:/work/vcpkg/packages/libffi_x64-windows;C:/work/vcpkg/packages/sdl2_x64-windows",
        "-DBUILD_LVGL_SIMULATOR=ON",
        "-DUSE_EXTERNAL_FFI=ON",
        "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>"

vcpkg install:

.\vcpkg.exe install curl zlib libffi sdl2 libffi:x64-windows-static

Summary by cubic

Add MSVC build support for Windows (simulator + vcpkg), upgrade txiki to v26.5.0, and harden QuickJS bindings to prevent argument OOB reads. Also improves QuickJS and Windows compatibility for smoother cross‑platform builds.

  • New Features

    • MSVC support: C++23 on MSVC (C++14 elsewhere); adds "/utf-8" and WIN32_LEAN_AND_MEAN; new BUILD_LVGL_SIMULATOR=ON flag with Makefile updated; non‑MSVC simulator builds relax -Werror for unused-but-set variables.
    • Compatibility and fixes: centralized LVGL/QuickJS includes in src/render/native/lv_bindings_js.h; use single‑arg JS_IsArray; boolean literals and event handlers return JS_UNDEFINED; accurate argc guards and declared function arities for native methods to avoid OOB argv reads and report correct lengths; rename Arc to avoid a Windows name clash; remove zero‑length ComponentClassFuncs arrays; initialize is_new in style handling.
    • Dependencies: bump txiki to v26.5.0 and @txikijs/types to ^26.5.0.
  • Migration

    • Install with vcpkg: .\vcpkg.exe install curl zlib libffi sdl2 libffi:x64-windows-static
    • Example CMake: -DBUILD_LVGL_SIMULATOR=ON -DUSE_EXTERNAL_FFI=ON -DCMAKE_PREFIX_PATH=C:/work/vcpkg/packages/zlib_x64-windows;C:/work/vcpkg/packages/curl_x64-windows;C:/work/vcpkg/packages/libffi_x64-windows;C:/work/vcpkg/packages/sdl2_x64-windows -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>

Written for commit 34ffc37. Summary will update on new commits.

Review in cubic

Closes: #57

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 45 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/engine/hal/simulator/simulator.cpp">

<violation number="1" location="src/engine/hal/simulator/simulator.cpp:3">
P1: Wrapping `LV_IMG_DECLARE(mouse_cursor_icon)` in `extern "C"` creates a C-linkage reference, but `mouse_cursor_icon.c` is compiled with the C++ compiler in this build, so the definition will not match and linking can fail.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/render/native/components/roller/roller_wrap.cpp Outdated
Comment thread src/render/native/components/dropdownlist/dropdownlist_wrap.cpp Outdated
Comment on lines +3 to +7
extern "C" {

LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/

}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Wrapping LV_IMG_DECLARE(mouse_cursor_icon) in extern "C" creates a C-linkage reference, but mouse_cursor_icon.c is compiled with the C++ compiler in this build, so the definition will not match and linking can fail.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/engine/hal/simulator/simulator.cpp, line 3:

<comment>Wrapping `LV_IMG_DECLARE(mouse_cursor_icon)` in `extern "C"` creates a C-linkage reference, but `mouse_cursor_icon.c` is compiled with the C++ compiler in this build, so the definition will not match and linking can fail.</comment>

<file context>
@@ -1,5 +1,11 @@
 #include "./simulator.hpp"
 
+extern "C" {
+
+LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
</file context>
Suggested change
extern "C" {
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
}
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were wrong about mouse_cursor_icon.c, the compiler for mouse_cursor_icon.c is default to c, that's why I use
extern "C"

Comment thread src/render/native/components/line/line_wrap.cpp Outdated
Comment thread src/render/native/components/calendar/calendar_wrap.cpp Outdated
@lygstate
Copy link
Copy Markdown
Author

I create a fork https://github.com/lvgljs/lvgljs to get this merged

lygstate added 10 commits May 31, 2026 06:32
Bump @txikijs/types in package.json
Several JS-callable component methods guarded with a smaller argc than the highest argv[] index they read. Since these functions are registered with declared length 0, QuickJS does not pad argv, so passing too few arguments caused out-of-bounds reads of the argument array. Align each argc check with the highest argv index accessed.
Set the TJS_CFUNC_DEF length field to each method's real arity so QuickJS pads argv with undefined up to that count. This provides a defensive backstop against out-of-bounds argv reads on top of the argc guards, and reports correct Function.prototype.length. Scoped to methods that read beyond argv[0].
…riable]

[build] /mnt/c/work/lvgl/lv_binding_js/deps/txiki/deps/libwebsockets/lib/system/async-dns/async-dns.c:801:27: error: variable ‘c’ set but not used [-Werror=unused-but-set-variable]
[build]   801 |         lws_adns_cache_t *c;
[build]       |                           ^
[build] cc1: all warnings being treated as errors
MSVC do not support for zero length array:

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
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

Successfully merging this pull request may close these issues.

Add msvc support by upgrading txiki and other deps

1 participant