1

How do I implement a function to load a dll(aka framework) on Mac OS using C++?
void LoadFramework(const char* frameworkPath) { //frameworkPath is the absolute path of the framework }

Edit:
When I google searched for this problem, I mostly ended up with dlopen solution to load the framework. What I am instead looking for is to use CFBundleCreate to load the framework. It seems to me that there are a bunch of methods needed to be called to construct an URL from const char * path. I found the needed code in pieces, and could not write one comprehensive solution.

Rakesh Agarwal
  • 3,009
  • 9
  • 33
  • 40
  • 1
    A Google search for "load shared library mac" brings up a link to developer.apple.com that discussed that particular topic, and specifically mentions the library function that does this. Have you tried doing some research on this by doing a Google search? What did you find, and which part of the documentation do you have specific questions about? – Sam Varshavchik Nov 17 '19 at 16:43
  • Based on the above comment by @Sam, I will edit my question now to be more specific. Thanks! – Rakesh Agarwal Nov 18 '19 at 06:32

2 Answers2

1

It typically is just a few lines of straightforward code to open a framework in Mac, something along the lines of :

bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
    CFSTR("/System/Library/Frameworks/<your_framework_name.framework>"),
    kCFURLPOSIXPathStyle, true);

bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL);
assert(bundle != NULL);

and pretty much everything in that snippet is well documented. I would suggest adding more detail in the question, as to the specifics of what exactly is not working for you.

jester
  • 3,491
  • 19
  • 30
  • yeah, this code is what I finally ended up writing last week. Thanks! I tend to disagree that everything in this snippet is well documented. It was not quite that easy for me. – Rakesh Agarwal Nov 27 '19 at 13:32
0

Why not do this?

using DLL_Namespace;

This should give you access to the DLL.

  • Welcome to Stackoverflow! Can you expand on your answer a bit? How is this line used in the context of the question? Can you provide an example for how this would work? – Kevin Nov 26 '19 at 23:33