ld: symbol(s) not found for architecture arm64

I'm attempting to determine whether there is a currently logged on user via the SCDynamicStoreCopyConsoleUser function.

My code look something along the lines of:

#include <SystemConfiguration/SystemConfiguration.h>

bool isUserLoggedOn()
{
    CFStringRef name = SCDynamicStoreCopyConsoleUser(NULL, NULL, NULL);
    if (name != NULL)
    {
        CFRelease(name);
        return true;
    }
    return false;
}

I am getting the following error output on compilation:

Undefined symbols for architecture arm64:
    "_CFRelease", referenced from:
        isUserLoggedOn() in UserInfo.cpp.o
    "_SCDynamicStoreCopyConsoleUser", referenced from:
        isUserLoggedOn() in UserInfo.cpp.o
ld: symbol(s) not found for architecture arm64
Answered by DTS Engineer in 797230022

You're likely missing a reference to the SystemConfiguration framework in the Link Binary with Libraries build phase.

— Ed Ford,  DTS Engineer

You're likely missing a reference to the SystemConfiguration framework in the Link Binary with Libraries build phase.

— Ed Ford,  DTS Engineer

Assuming you get your linking issue sorted out (thanks Ed!), I’d like to get a better idea of what you’re doing with SCDynamicStoreCopyConsoleUser. It’s a tricky API because:

  • There can be zero or more logged in GUI users.

  • They can be a mixture of local (via Fast User Switching) and remote (via Screen Sharing) users.

Many folks I see trying to use this routine don’t understand these subtleties, and thus write code that breaks when it encounter some the first time.

So, what are you expecting to do with SCDynamicStoreCopyConsoleUser?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

ld: symbol(s) not found for architecture arm64
 
 
Q