g3n / g3nd

G3N Game Engine Demo
BSD 2-Clause "Simplified" License
279 stars 32 forks source link

Installation fails. #33

Closed SamTov closed 3 years ago

SamTov commented 3 years ago

Hello, I was trying to install the g3nd package and the installation fails import some header files. I have attached the output below.

Output

# github.com/go-gl/glfw/v3.2/glfw
In file included from ../../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20190409004039-e6da0acd62b1/v3.2/glfw/c_glfw_darwin.go:8:
../../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20190409004039-e6da0acd62b1/v3.2/glfw/glfw/src/cocoa_window.m:989:9: warning: multiple methods named 'center' found [-Wobjc-multiple-method-names]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSCollectionViewCompositionalLayout.h:604:19: note: using
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:341:1: note: also found
# github.com/g3n/engine/audio/vorbis
../../../go/pkg/mod/github.com/g3n/engine@v0.1.1-0.20200214161420-db7282a2ba23/audio/vorbis/vorbis.go:17:11: fatal error: 'codec.h' file not found
 #include "codec.h"
          ^~~~~~~~~
1 error generated.
# github.com/g3n/engine/audio/ov
../../../go/pkg/mod/github.com/g3n/engine@v0.1.1-0.20200214161420-db7282a2ba23/audio/ov/vorbisfile.go:18:11: fatal error: 'vorbisfile.h' file not found
 #include "vorbisfile.h"
          ^~~~~~~~~~~~~~
1 error generated.
# github.com/g3n/engine/audio/al
../../../go/pkg/mod/github.com/g3n/engine@v0.1.1-0.20200214161420-db7282a2ba23/audio/al/al.go:18:11: fatal error: 'al.h' file not found
 #include "al.h"
          ^~~~~~
1 error generated.

I have already run brew install libvorbis openal-soft and have added them to my path in line with the other issues that mention this error. Still, the installation fails.

Update Running on Mac intel the brew install method works for the header files. However, in this case I get the following output and no binary is created.

# github.com/go-gl/glfw/v3.2/glfw
In file included from ../../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20190409004039-e6da0acd62b1/v3.2/glfw/c_glfw_darwin.go:8:
../../../go/pkg/mod/github.com/go-gl/glfw@v0.0.0-20190409004039-e6da0acd62b1/v3.2/glfw/glfw/src/cocoa_window.m:989:9: warning: multiple methods named 'center' found [-Wobjc-multiple-method-names]
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSCollectionViewCompositionalLayout.h:604:19: note: using
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSWindow.h:341:1: note: also found
danaugrs commented 3 years ago

Hi! The first error there is happening in go-gl/glfw and according to https://github.com/go-gl/glfw/issues/303 it's because Apple silicon is only supported by GLFW 3.3.3 and above. I updated g3n to use the latest go-gl/glfw (and g3nd to use the latest g3n). Please try again and let me know.

SamTov commented 3 years ago

I sorted it on Mac intel. On Apple silicon I am working out the best way to make the header files available.

Apple Silicon In the case of Apple silicon I initially used home-brew but it still failed to locate the header files. To get around this I installed OpenAl, libvorbis, and libogg from source, all of which can be done with no issues although you will need sudo permission to run the install. I also needed to update some of the g3n/engine files because still some of the header files just could not be found without me specifying the path, namely al.h, alc.h, and the efx.h. Once this is done, it works perfectly.

It is probably worth working out how to link the header files without requiring sudo for the future. Perhaps I can learn a little more about go and try to implement this better.

I am not so familiar with the go install pipeline, but in the case of c++ or c I would say better package locating or something. If there is something I can do please let me know and I will get onto it. Otherwise, I can write some specific Apple silicon documentation for the install. This has been my approach with my software projects as I like to take advantage of the Apple silicon performance.

danaugrs commented 3 years ago

It would be awesome if you figure out how to link the headers files automatically on Apple silicon! Otherwise, if you feel like there are tricky steps to installing from source and linking, a quick write up on it would probably help others.

SamTov commented 3 years ago

Yeah I think definitely if people aren't familiar with header files it would be good for them. I will write something up and try to think of a good way to do the linking automatically to avoid it if possible. Are you interested in hosting docs for the code? I could set something small up with sphinx, maybe put together some small tests too if you're interested.

mat007 commented 3 years ago

Oh I just noticed this issue, I ran into this as well (Apple silicon) as I commented on https://github.com/g3n/engine/issues/47#issuecomment-884107366 I didn’t need to modify any source code file or use sudo, I just did

CGO_CFLAGS="-I/opt/homebrew/include/vorbis -I/opt/homebrew/opt/openal-soft/include/AL" CGO_LDFLAGS="-L/opt/homebrew/lib -L/opt/homebrew/opt/openal-soft/lib" go install
mat007 commented 3 years ago

Tentative fix in: https://github.com/g3n/engine/pull/236

danaugrs commented 3 years ago

Thanks @mat007! @SamTov any thoughts on that PR https://github.com/g3n/engine/pull/236 ?

Are you interested in hosting docs for the code?

Just saw this. For the API reference I think GoDoc is fine. High level docs, sure! - but someone just has to write them and I don't have bandwidth for that currently.

SamTov commented 3 years ago

@danaugrs I think the PR is good. I will check it on my system when I have some time as well.

I have been a little distracted with other work recently so have not come back to this g3n project. As for docs, I think it is really important to have something high level out there for people to see and work with. I will need to get back into the code to see if I want to use it for my software but if so, then I would start working on the documentation for my own learning.