Skip to content

Some build issues #13

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
gen2brain opened this issue May 9, 2024 · 11 comments
Closed

Some build issues #13

gen2brain opened this issue May 9, 2024 · 11 comments

Comments

@gen2brain
Copy link

I added the RGFW backend to my Raylib Go bindings and noticed a few issues with MinGW and macOS.

This happens when I try to compile with OSXCross:

$ CGO_ENABLED=1 CC=x86_64-apple-darwin21.4-clang GOOS=darwin GOARCH=amd64 go build -tags rgfw -ldflags "-linkmode external -s -w"

./platforms/../external/RGFW.h:892:15: error: redefinition of 'NSString' as different kind of symbol
/opt/osxcross/target/bin/../SDK/MacOSX12.3.sdk/usr/include/objc/NSObject.h:13:8: note: previous definition is here
In file included from rcore.c:502:
In file included from ./platforms/rcore_desktop_rgfw.c:76:
./platforms/../external/RGFW.h:896:15: error: redefinition of 'NSArray' as different kind of symbol
/opt/osxcross/target/bin/../SDK/MacOSX12.3.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h:254:8: note: previous definition is here

I just "fixed" this but commenting offending lines, but with GitHub actions, there are more, I guess that SDK versions are different:

$ go build -tags rgfw
# github.com/gen2brain/raylib-go/raylib
In file included from rcore.c:502:
In file included from ./platforms/rcore_desktop_rgfw.c:80:
./platforms/../external/RGFW.h:896:15: error: redefinition of 'NSString' as different kind of symbol
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:111: note: previous definition is here
In file included from rcore.c:502:
In file included from ./platforms/rcore_desktop_rgfw.c:80:
./platforms/../external/RGFW.h:900:15: error: redefinition of 'NSArray' as different kind of symbol
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserScriptTask.h:8:32: note: previous definition is here
In file included from rcore.c:502:
In file included from ./platforms/rcore_desktop_rgfw.c:80:
./platforms/../external/RGFW.h:902:15: error: redefinition of 'NSImage' as different kind of symbol
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h:8:112: note: previous definition is here
In file included from rcore.c:502:
In file included from ./platforms/rcore_desktop_rgfw.c:80:
./platforms/../external/RGFW.h:1000:9: error: redefinition of 'NSMakeRect'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSGeometry.h:151:18: note: previous definition is here
In file included from rcore.c:502:
In file included from ./platforms/rcore_desktop_rgfw.c:80:
./platforms/../external/RGFW.h:1010:10: error: redefinition of 'NSMakePoint'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSGeometry.h:137:19: note: previous definition is here
In file included from rcore.c:502:
In file included from ./platforms/rcore_desktop_rgfw.c:80:
./platforms/../external/RGFW.h:1017:9: error: redefinition of 'NSMakeSize'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSGeometry.h:144:18: note: previous definition is here

And then, there is the issue with MinGW:

CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -tags rgfw -ldflags '-s -w'
# github.com/gen2brain/raylib-go/raylib
In file included from platforms/rcore_desktop_rgfw.c:76,
                 from rcore.c:502:
platforms/../external/RGFW.h:134: warning: "WIN32" redefined
  134 | #define WIN32
      |
<built-in>: note: this is the location of the previous definition
platforms/../external/RGFW.h:138: warning: "WIN64" redefined
  138 | #define WIN64
      |
<built-in>: note: this is the location of the previous definition
platforms/rcore_desktop_rgfw.c:83: warning: "Rectangle" redefined
   83 | #define Rectangle struct Rectangle
      |
platforms/rcore_desktop_rgfw.c:65: note: this is the location of the previous definition
   65 | #define Rectangle rectangle_win32
      |
# examples/core/basic_window
/usr/lib/go/pkg/tool/linux_amd64/link: running x86_64-w64-mingw32-gcc failed: exit status 1
/usr/libexec/gcc/x86_64-w64-mingw32/ld: /tmp/go-link-2142769958/000015.o: in function `RGFW_sleep':
/home/milann/Projects/raylib-go/raylib/platforms/../external/RGFW.h:6082: undefined reference to `nanosleep'
/usr/libexec/gcc/x86_64-w64-mingw32/ld: /home/milann/Projects/raylib-go/raylib/platforms/../external/RGFW.h:6082: undefined reference to `nanosleep'
/usr/libexec/gcc/x86_64-w64-mingw32/ld: /home/milann/Projects/raylib-go/raylib/platforms/../external/RGFW.h:6082: undefined reference to `nanosleep'

The problem with nanosleep is on line 6077 #ifndef _MSC_VER, I just fixed this with #if !defined(_MSC_VER) && !defined(__MINGW32__).

Linux only had some redefinition errors, I hacked it with some undefs. They are unfortunate because I cannot silence only redefinition warnings.

Hope this is helpful.

@ColleagueRiley
Copy link
Owner

ColleagueRiley commented May 9, 2024

Nanosleep should be available with mingw, I'm not sure why that issue is happening.

As for the macOS issues, those confuse me as well. The header causing that issue shouldn't exist because RGFW is designed for C and that is an objective c header iirc. That's why RGFW needs to define these types and functions.

None of these issues happen when compiling with C normally.
https://github.com/colleagueRiley/raylib

@ColleagueRiley
Copy link
Owner

ColleagueRiley commented May 9, 2024

Never mind on nanosleep. It seems that only some versions of mingw include nanosleep.

I'll look more into this issue asap.

@gen2brain
Copy link
Author

Ok, I understand now, I have this in CFLAGS -x objective-c, not sure if this was for miniaudio and if I still need it. Thanks.

@ColleagueRiley
Copy link
Owner

Ok, I understand now, I have this in CFLAGS -x objective-c, not sure if this was for miniaudio and if I still need it. Thanks.

I'm pretty sure Miniaudio should be able to compile without objective-c.

@gen2brain
Copy link
Author

For iOS needs to be compiled as objective-c, and this was probably left then from some experiment. I will remove it.

@ColleagueRiley
Copy link
Owner

Could you also tell me what the redef errors for Linux were?

@gen2brain
Copy link
Author

For Linux, similar warnings as above for Windows, about redefined Rectangle.

@gen2brain
Copy link
Author

Yes, for Linux, only warnings, there were no errors, sorry.

@ColleagueRiley
Copy link
Owner

Ok, then the windows error is the only one that's left?

I'll fix it later by adding
#ifndef RGFW_WINDOWS

@ColleagueRiley
Copy link
Owner

Should be solved now.

@gen2brain
Copy link
Author

All good, thanks.

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

2 participants