CGRectMake: symbol not found when using dlopen/dlsym

The following program demonstrates the issue. It prints:

y = 2.000000
CGRectMake symbol not found

What would cause the symbol not to be found when using the dlopen/dlsym functions?

#import <CoreGraphics/CoreGraphics.h>
#import <dlfcn.h>

int main(int argc, const char * argv[])
{
    CGRect rect = CGRectMake(1.0, 2.0, 3.0, 4.0);
    printf("y = %f\n", rect.origin.y);

    void * handle = dlopen("/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics", RTLD_LAZY);
    if (handle == NULL) {
        printf("handle == NULL\n");
    }
    else if (dlsym(handle, "CGRectMake") == NULL) {
        printf("CGRectMake symbol not found\n");
    }

    return 0;
}

I am observing this issue with other symbols as well. What is special about them?

Answered by DTS Engineer in 789673022

If you look in the <CoreGraphics/CGGeometry.h> header you'll see that CGRectMake is always inlined, which means it doesn’t need an implementation in the CG framework.

Share and Enjoy

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

Accepted Answer

If you look in the <CoreGraphics/CGGeometry.h> header you'll see that CGRectMake is always inlined, which means it doesn’t need an implementation in the CG framework.

Share and Enjoy

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

CGRectMake: symbol not found when using dlopen/dlsym
 
 
Q