Confusion about make file on Mac

Hey, so I got my project set up for Windows with VS Code and I made a Makefile that creates the .exe fine. I did this by typing the path to the lib folder and the include folder from the SDL Windows release I downloaded.
My confusion is that I also want to work on my project on Mac, so I tried following the same process but the dmg I downloaded contains a file called SDL2.framework and I’m not sure where to find the lib and include inside of it, so I don’t know how to Make the project on Mac.
I’d like to figure this out regardless, but I’ve also read that it’s easier to set this up using CMake? I don’t fully understand how that would work though. Thanks.

The nice thing about Mac frameworks is that the library and headers are included in the framework, and you don’t need to dig inside to link to them directly.

To link to a framework on macOS, instead of cc mysource.c -o myprogram -lsomelibrary you would do cc mysource.c -o myprogram -framework SomeFramework. The compiler will automatically link to the library binary inside the framework, and automatically put the Headers folder inside it in your include path.

It’s the equivalent of doing cc mysource.c -o myprogram -L/path/to/SomeFramework.framework -lSomeFramework -I/path/to/SomeFramework.framework/Headers but a lot less grody.

macOS frameworks are just a folder with a special internal layout, and you can just pass the whole framework around without messing with the files inside.
The layout for a hypothetical framework named SomeFramework would be

/SomeFramework.framework
    /Versions
        /A
            <the usual macOS bundle layout:>
            /Frameworks <frameworks can bundle other frameworks>
            /Headers <the framework's header files are in here>
            /Resources <bundle resources go here: Info.plist, and any other files the framework needs like images, etc.>
            SomeFramework <the actual library binary>
            _CodeSignature <the code signing information>
        /Current <symlink to /Versions/A>
    /Headers <symlink to /Versions/Current/Headers>
    /Resources <symlink to /Versions/Current/Resources>
    SomeFramework <symlink to /Versions/Current/SomeFramework>
2 Likes

@sjr man, you are too helpful in the forum. Thank you for spend time on helping others.

2 Likes