Is it possible to link macfuse to a C++ static library?

I have successfully used MacFUSE in the C programming language on OS X 10.6.8 and it works great. At some point I need to start making functions calls to a C++ static library (libSomething.a). From this question people are saying the only way this is possible is modify the c++ source code to make it callable from C (i.e. prepend extern "C" before function name and return type). Unfortunately, I do not have access to the source code, just a static C++ library *.a file.

Is there some way I can convert MacFUSE into a C++ or Objective-C program to allow for invoking C++ functions inside a static library?

I would appreciate the C/C++/Objective-C experts in the community to weigh in on this.

I'm using Xcode 4.3


You could provide a wrapper, exposing the C++ class as a C-API:


class Something {
    int x;
    Something() { x = 0; }
    void setX(int newX) { x = newX; }
    int getX() const { return x; }


#pragma once
typedef void *SOMETHING;

#ifdef __cplusplus
extern "C" {

SOMETHING createSomething();
void destroySomething(SOMETHING something);
void setSomethingX(SOMETHING something, int x);
int getSomethingX(SOMETHING something);

#ifdef __cplusplus
}    // extern "C"


#include <Something.h>
#include "wrapper.h"

SOMETHING createSomething() {
    return static_cast<SOMETHING>(new Something());

void destroySomething(SOMETHING something) {
    delete static_cast<Something *>(something);

void setSomethingX(SOMETHING something, int x) {
    static_cast<Something *>(something)->setX(x);

int getSomethingX(SOMETHING something) {
    return static_cast<Something *>(something)->getX();

Need Your Help

Circular variable dependency in C++

c++ variables dependencies circular systemc

I'm using SystemC library to build some modules for a simulation. SystemC makes simulations, so it is necessary to set a timestep (in my case 1ms each). The problem is that I have a circular depend...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.