Search code examples
c++macosmacos-carbon

How to link to the carbon with gcc in mac?


I develope an application in mac that uses carbon.

My IDE is Code::Blocks (GCC compiler). My code compiles successfully but does not link.

#include <iostream>
#include <Carbon/Carbon.h>

using namespace std;

int main()
{
    //CGEventFlags flags = CGEventSourceFlagsState(1);

    while(true)
    {
        CGEventSourceStateID eventSource = kCGEventSourceStateCombinedSessionState;
        bool b = CGEventSourceKeyState(eventSource, kVK_Command) && CGEventSourceKeyState(eventSource, kVK_ANSI_Period);
        if(b)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    cout << "Hello world!" << endl;
    return 0;
}

How to link to the carbon with gcc in mac?


Solution

  • A simple -framework Carbon flag for gcc should do the trick, according to various sources around the internet.

    Cannot verify this, though.

    This question seems slightly similar.