Skip to content

Fix Cross Compilation for Windows #6461

Open
@mccakit

Description

@mccakit

Xmake 版本

2.9.9

操作系统版本和架构

Windows 10

描述问题

Cross compilation doesn't works for windows host.

期待的结果

Cross compilation should work for windows

工程配置

package("glfw")
    add_deps("cmake")
    set_sourcedir("glfw-3.4")
    on_install(function (package)
        local configs = {}
        import("package.tools.cmake")
        cmake.install(package, configs)
    end)
package_end()
add_requires("glfw")

target("glad")
    set_kind("static")
    add_files("glad/src/*.c")
    add_headerfiles("glad/include/glad/*.h")
    add_headerfiles("glad/include/KHR/*.h")
    add_includedirs("glad/include",{public=true})

target("hi")
    set_kind("binary")
    add_files("src/*.cpp")
    add_deps("glad")
    add_packages("glfw")
    if is_plat("windows") then
        add_syslinks("opengl32", "gdi32", "user32", "shell32")
    elseif is_plat("linux") then
        add_syslinks("GL", "m", "dl", "X11", "pthread")
    end
xmake config --toolchain=llvm --plat=linux --arch=x86_64 --sdk=C:\devtools\llvm\

This fails, so do this

xmake config --toolchain=llvm --plat=cross --cross=x86_64-pc-linux-gnu

and this

xmake config --toolchain=llvm --plat=cross `
--cross=x86_64-pc-linux-gnu `
--sdk=C:/devtools/llvm `
--cxflags=C:/devtools/sysroots/deb `
--ldflags=C:/devtools/sysroots/deb

and this

xmake config --toolchain=llvm --plat=linux --arch=x86_64 --sdk=C:\devtools\llvm\ --runtimes=stdc++_shared

附加信息和错误日志

I could write a lot, but the main thing is standard library cannot be found anad pacakge install fails due to not finding os specifics stuff like pthread

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions