Skip to content

Building examples on windows #8

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

Closed
anaanook opened this issue Dec 7, 2020 · 4 comments
Closed

Building examples on windows #8

anaanook opened this issue Dec 7, 2020 · 4 comments

Comments

@anaanook
Copy link

anaanook commented Dec 7, 2020

I'm sure I'm just doing something wrong in the set up but something is going wrong when its pulling in the raylib module and compiling it. Here's an excerpt:

This is from just cloning the repo and following the 'getting started' steps to build the examples

attempting to fetch submodule(s)...
error(compilation): clang failed with stderr: In file included from C:\TSHEngine\Zig\raylib-zig\raylib\src\rglfw.c:54:
In file included from C:\folder\raylib-zig\raylib\src/external/glfw/src/context.c:30:
In file included from C:\folder\raylib-zig\raylib\src/external/glfw/src/internal.h:186:
In file included from C:\folder\raylib-zig\raylib\src/external/glfw/src/win32_platform.h:70:
C:\folder\raylib-zig\raylib\src\external\glfw\deps\mingw\xinput.h:227:26: error: a parameter list without types is only allowed in a function definition
In file included from C:\folder\raylib-zig\raylib\src\rglfw.c:54:
C:\folder\raylib-zig\raylib\src/external/glfw/src/context.c:407:10: warning: 'sscanf' is deprecated: This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
@anaanook
Copy link
Author

anaanook commented Dec 7, 2020

Just for the record, I am able to get things working by manually building and linking raylib, but it would seem that something isn't quite functioning with the automated build.

@Not-Nik
Copy link
Owner

Not-Nik commented Dec 9, 2020

I don't have a Windows system to test and debug this, but from what I can see this seems to be a zig cc error. Can you try creating a zig build script only for GLFW? If the issue persists when only building that, please create an issue over in the zig repo.

@anaanook
Copy link
Author

anaanook commented Dec 14, 2020

Hey I've got an update here.. so as it turns out the reason its not working is that the default target on windows is set to "-target native-native-msvc". If you set the target to "-target native-native-gnu" it builds just fine.
Here's what I added to the build file, I'm still pretty green with this stuff... so forgive me if there's a better way of setting this up:

pub fn build(b: *Builder) void {
    const mode = b.standardReleaseOptions();
    const target = b.standardTargetOptions(.{.default_target = .{ .abi=.gnu}});

and then down in the examples

    for (examples) |ex| {
        const exe = b.addExecutable(ex.name, ex.path);
        exe.setBuildMode(mode);
        exe.setTarget(target);

I got the idea from this suggestion: ziglang/zig#6565 , apparently this default target causes other issues too.

@andrewrk
Copy link

ziglang/zig#6565 is solved now; the workaround will not be necessary in the upcoming 0.8.0 release.

@Not-Nik Not-Nik closed this as completed Jun 19, 2022
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

No branches or pull requests

3 participants