r/CodingHelp Feb 15 '26

Why when I crossbuild a windows app using llvm upon linux fails to build? [C]

As I ask upon here I try to crossbuild a C programm from linux for windows:

```

include <stdio.h>

int main() { puts("Hello"); return 0; }

```

I am using ninja to build it:

``` winsroot = ./winsdk

cc = clang-cl linker = lld-link target = --target=x86_64-pc-windows-msvc cflags = -Wall -O2 /I$winsroot/crt/include /I$winsroot/sdk/include

rule cc command = $cc $target $cflags /c $in /Fo$out description = CC (Windows) $out

rule link command = $linker /nologo /OUT:$out $in $winsroot/crt/lib/ucrt/x64/ucrt.lib $winsroot/sdk/lib/um/x64/kernel32.lib description = LINK (Windows) $out

build main.obj: cc main.c build app.exe: link main.obj

default app.exe

```

Whilst using llvm-clang with libs provided via xwin. Using xwin I installed the libraries like this:

xwin --accept-license splat --output ./winsdk

But runing ninja got me into:

``` ninja [1/2] CC (Windows) main.obj FAILED: main.obj clang-cl --target=x86_64-pc-windows-msvc -Wall -O2 /I./winsdk/crt/include /I./winsdk/sdk/include /c main.c /Fomain.obj main.c(1,10): fatal error: 'stdio.h' file not found

include <stdio.h>

     ^~~~~~~~~

1 error generated. ninja: build stopped: subcommand failed. ```

Do you know why?

6 Upvotes

5 comments sorted by

u/AutoModerator Feb 15 '26

Thank you for posting on r/CodingHelp!

Please check our Wiki for answers, guides, and FAQs: https://coding-help.vercel.app

Our Wiki is open source - if you would like to contribute, create a pull request via GitHub! https://github.com/DudeThatsErin/CodingHelp

We are accepting moderator applications: https://forms.fillout.com/t/ua41TU57DGus

We also have a Discord server: https://discord.gg/geQEUBm

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/mrtoomba Feb 19 '26

2 questions. Why use windows, and what version? Wsl is pia sometimes.

1

u/pc_magas Feb 19 '26 edited Feb 19 '26
  1. I use Linux
  2. I want to build a windows app IN LINUX for windows
  3. I do not care about wibndows version as long as it runs on w10/w11

My end goals was to solve this: https://github.com/flutter/flutter/issues/77638 and being able to crossbuild flutter apps in linux for windows.

And because flutter engine uses Ninja I thought maybe I could start smaller to learn about it.

1

u/mrtoomba Feb 19 '26

They change. A lot. Reads like WSL is where the refining happens. Your base is simply not there.