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

Mac OS X support #6

Closed
GabrieleInvernizzi opened this issue Nov 18, 2018 · 22 comments
Closed

Mac OS X support #6

GabrieleInvernizzi opened this issue Nov 18, 2018 · 22 comments
Labels
OS:MacOS Operating system MacOS

Comments

@GabrieleInvernizzi
Copy link

How can I use the code in Xcode on Mac? If there is a way of course

@S-Marais
Copy link

following today's video you should be able to create a an xcode solution. you will need to get premake5 binaries from github and the launch premake5 xcode4 which should generate the xcode project files

@RohitAwate
Copy link

RohitAwate commented Nov 18, 2018

You'd also have to add some macOS-specific macros and configuration stuff to premake5.lua. EntryPoint.h would also need some changes since it uses the Windows header guard, which you could just remove since there is no Windows-specific code in there, yet.

@ghost
Copy link

ghost commented Nov 18, 2018

you should also be adding macros like HZ_PLATFORM_MACOS

@lccatala
Copy link

also, __declspec(dllexport) and __declspec(dllimport) seem to be Windows-exclusive. I've been looking for an alternative way of exporting and importing symbols on Mac but can't seem to find anything. Is this supposed to work without defining anything?

@ghost
Copy link

ghost commented Nov 18, 2018

Mac and Linux, don't use these directives for creating and using shared objects. You can specify them but they will be ignored. Unlike on Windows, you don't need to "export" or "import" symbols.

@S-Marais
Copy link

no the std like alternative is

#define HAZEL_API __attribute__((visibility("default")))

@lccatala
Copy link

lccatala commented Nov 18, 2018 via email

@Ali-Sheharyar-Sheikh
Copy link

No it would be using the built in terminal in Xcode. Just change the setting to launch new terminal on application run in Xcode.

@GabrieleInvernizzi
Copy link
Author

Iccatala, sorry, can you explain me how did you managed to build this project on xCode, I tried but I can’t do it ahah

@lccatala
Copy link

lccatala commented Nov 26, 2018 via email

@GabrieleInvernizzi
Copy link
Author

Thank you very much, I'll try

You have to create a new filter for "system:macosx" using the same configurations as for the Windows one, replacing every "windows" word for "mac", so the code you compile is different for each platform. In Core.h, remove the #error macro (there is no need for __declspec(dllexport) in xcode, since every class and function will be accesible throughout the whole solution by default). Then download and install premake for mac and run it with the parameter xcode4. Let me know if there are any errors remaining, it's possible I've forgotten something. Also, I'll try to build it for cmake so it can be edited from VSCode, which I think is far superior to XCode El lun., 26 nov. 2018 a las 10:16, Gabriele Invernizzi (< notifications@github.com>) escribió:

Iccatala, sorry, can you explain me how did you managed to build this project on xCode, I tried but I can’t do it ahah — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#6 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/Aek9BnURXB1pD3oUfdoDT85Kf3w9gZUOks5uy7FRgaJpZM4Yn84k .

@GabrieleInvernizzi
Copy link
Author

I tried but it doesn't work, perhaps is my fault but can you help me with this?
This is my premake5.lua file (I know that this is a txt but GitHub do not support .lua):
premake5.txt.

I think I did some (if not a lot) mistakes, can you help me?

You have to create a new filter for "system:macosx" using the same configurations as for the Windows one, replacing every "windows" word for "mac", so the code you compile is different for each platform. In Core.h, remove the #error macro (there is no need for __declspec(dllexport) in xcode, since every class and function will be accesible throughout the whole solution by default). Then download and install premake for mac and run it with the parameter xcode4. Let me know if there are any errors remaining, it's possible I've forgotten something. Also, I'll try to build it for cmake so it can be edited from VSCode, which I think is far superior to XCode El lun., 26 nov. 2018 a las 10:16, Gabriele Invernizzi (< notifications@github.com>) escribió:

@cubedtear
Copy link

On PR #27 we have a working build on Linux, which should contain similar changes to those needed for Mac OS X support. You could maybe try those changes (maybe changing all the system:linux with system:macosx) to see if it works.

@Gaztin Gaztin added the OS:MacOS Operating system MacOS label Jun 6, 2019
@thatweirdcoder
Copy link

@GabrieleInvernizzi How about you Use clion (an ide that uses cmake) instead of premake and xcode .. spglog and glfw already use cmake and writing cmake files for glad and imgui wont be hard. I just like that clion is cross platfrom and i can work from my macbook or windows pc. https://www.jetbrains.com/clion/

@StevenSavold
Copy link

@not-a-vegetable you can generate cmake files with premake. If you want to use clion you can do that here's the link to the extension

https://github.com/TurkeyMan/premake-cmake

@mfdorst
Copy link

mfdorst commented Sep 4, 2019

@thatweirdcoder I also enjoy CLion for the same reason. However for those who prefer Xcode, it also supports CMake, so there's no reason you have to switch to a new IDE to use it.

@cxgslegend
Copy link
Contributor

@not-a-vegetable you can generate cmake files with premake. If you want to use clion you can do that here's the link to the extension

https://github.com/TurkeyMan/premake-cmake

Unfortunately, it doesn't work with premake5, and the creator isn't updating the project. Issue from 2015. It seems like there are no cmake action extensions. Even the one listed in the premake docs is dead Premake modules.

@jviney
Copy link

jviney commented Dec 21, 2019

If anyone is interested, I'm doing this series on macOS using VS Code with CMake instead of premake.

I'm currently up to episode 16. Works fine with Xcode if you want to use that.

https://github.com/jviney/hazel

@cxgslegend
Copy link
Contributor

cxgslegend commented Dec 21, 2019

If anyone is interested, I'm doing this series on macOS using VS Code with CMake instead of premake.

I'm currently up to episode 16. Works fine with Xcode if you want to use that.

https://github.com/jviney/hazel

I assume you are talking about a youtube series. You should probably not promote in Hazel issues. This would be more appropriate for the "game engine series" section in discord.

But regardless, you do not have a link on your github project to the series.

@tcaer
Copy link

tcaer commented May 18, 2020

Hi,
I am on MacOS and I have built an engine which is basically Hazel but works on both MacOS and Windows. For Hazel's premake5 file, I added this:

filter "system:macosx"
    defines {
      "CFG_MACOS",
      "__APPLE__"
    }
    kind "SharedLib"

    links {
      "OpenGL.framework",
      "Cocoa.framework",
      "OpenGL.framework",
      "IOKit.framework",
      "CoreFoundation.framework"
    }

configuration to it. I then also added this to the GLFW configuration:

filter "system:macosx"
    systemversion "latest"
    staticruntime "On"
    
    files {
      "src/cocoa_init.m",
      "src/cocoa_joystick.m",
      "src/cocoa_monitor.m",
      "src/cocoa_time.c",
      "src/posix_thread.c",
      "src/cocoa_window.m",
      "src/egl_context.c",
      "src/nsgl_context.m",
      "src/osmesa_context.c"
    }

    defines {
      "_GLFW_COCOA"
    }

My version of the engine does not require any of the DLL_EXPORT/IMPORT stuff in it. But these settings will build GLFW properly for MacOS. Some of the macros are ones which I changed for my engine but I think you get the gist. I am currently using these configurations in aa VS2019 solution (not surprising as Windows already built fine) and with Make on MacOS. I have not tried this with Xcode.

@tcaer
Copy link

tcaer commented May 18, 2020

Furthermore, the "GLFW_INCLUDE_NONE" macro has to be moved to be a windows-only macro. MacOS requires us to use glfwWindowHints to set the proper context version. Also, the engine has to support version 410 as that is the highest version MacOS supports.

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

This code is required in a Mac window to ensure that the core profile and GL version 410 is being used.

@SteveGremory
Copy link

how about just creating a different repo for macOS and linking it in this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS:MacOS Operating system MacOS
Projects
None yet
Development

No branches or pull requests