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

fix windows related issues #40

Open
clitic opened this issue Dec 18, 2021 · 2 comments · May be fixed by #42
Open

fix windows related issues #40

clitic opened this issue Dec 18, 2021 · 2 comments · May be fixed by #42

Comments

@clitic
Copy link

clitic commented Dec 18, 2021

cross compiling for windows

CC=x86_64-w64-mingw32-gcc luastatic main.lua /usr/x86_64-w64-mingw32/lib/liblua5.2.a -I/usr/x86_64-w64-mingw32/include/lua5.2/

cross compiling for windows is good but creating a cross platform code will be more convenient for end users.

I have created a variable is_windows which check wheter this script is running on windows or not. Most of the windows user use mingw so i used gcc instead of cc.

-- The boolean check for building on windows platform
local is_windows = _G.package.config:sub(1, 1) == "\\"

-- The C compiler used to compile and link the generated C source file.
local CC = os.getenv("CC") or (is_windows and "gcc" or "cc")

uname is not available in windows which causes this error.

'uname' is not recognized as an internal or external command,
operable program or batch file.

to solve this error I used this code.

local UNAME = "Unknown"

if is_windows then
	UNAME = "Windows"
else
	UNAME = (shellout("uname -s") or "Unknown"):match("%a+") or "Unknown"
end

also we cannot check a command by /dev/null in windows. so I just replaced previous code with this.

if not execute(CC .. " --version" .. (is_windows and "" or " 1>/dev/null 2>/dev/null")) then
	io.stderr:write("C compiler not found.\n")
	os.exit(1)
end
@clitic clitic changed the title create a windows native binary and fix windows related issues fix windows related issues Dec 29, 2021
@aceyin
Copy link

aceyin commented Nov 7, 2022

will these fixes be merged into trunk?

@clitic clitic linked a pull request Dec 2, 2022 that will close this issue
@clitic
Copy link
Author

clitic commented Dec 2, 2022

@aceyin I have created a PR #42 with support for windows. Meanwhile you can use luastatic from my fork lua-batteries/luastatic.

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 a pull request may close this issue.

2 participants