Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9050119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:34:34+00:00 2026-06-16T12:34:34+00:00

I am trying to make an objective-c++ wrapper (.mm) between a pure c++ class

  • 0

I am trying to make an objective-c++ wrapper (.mm) between a pure c++ class (.cpp) and pure objective-c object (.m). A good working example can be found on github. I can build and run this without a problem.

However I need to access static member functions in the c++ class. I have modified the github example by removing all existing functions and introducing a static member function:

//  ==================
//  DummyModel.h
//  ==================

class DummyModel
{
    public:
        static int test ();

};

//  ==================
//  DummyModel.cpp
//  ==================

#include "DummyModel.h"


static int test ()
{
    int x = 1;
    return x;
}


//  ==================
//  DummyModelWrapper.h
//  ==================

#import <Foundation/Foundation.h>

@interface DummyModelWrapper : NSObject

- (int) test;

@end

//  ==================
//  DummyModelWrapper.mm
//  ==================

#import "DummyModelWrapper.h"
#import "DummyModel.h"

@implementation DummyModelWrapper

- (int) test
{
    int result;
    result = DummyModel::test();
    return result;
}

@end

This yields the following error:

Undefined symbols for architecture i386:
  "DummyModel::test()", referenced from:
      -[DummyModelWrapper test] in DummyModelWrapper.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It is this reference to test in DummyModelWrapper.mm that is invoking the error:

   result = DummyModel::test();

The test project is adapted from the github project, which compiles and runs fine in it’s unedited form (it instantiates DummyModel and invokes member functions on the instance). The error occurs as soon as I attempt to add a static member and access it from the wrapper object.

I have read everything i can find on stackoverflow and elsewhere, but can only find examples involving non-static member functions.

references
http://www.philjordan.eu/article/mixing-objective-c-c++-and-objective-c++
http://robnapier.net/blog/wrapping-cppfinal-edition-759
http://www.boralapps.com/an-objective-c-project-that-uses-c/294/

environment
xcode 4.5.2/osx8.2 (targeting ios5+)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:34:35+00:00Added an answer on June 16, 2026 at 12:34 pm

    Inside DummyModel.cpp, replace

    static int test ()
    {
        ...
    }
    

    By

    int DummyModel::test ()
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a good block-based initializer for an objective-c class. I'm declaring
I'm learning Objective-C, and I'm currently trying to make transitions between view controllers works
I am trying to make a wrapper in Objective-C so I don't have to
I'm using Twython (Python wrapper for Twitter API, found here .) Objective: I'm trying
So I am trying to make a Circle class in Objective-C. I know Java
I'm learning Objective-C and trying to make a very simple command line calculator. 'S'
I'm a .NET developer trying to make the leap into objective-c iPhone programming. I
Possible Duplicate: how to make phone call by using objective c? I am trying
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
So I'm trying to make the horrible leap from VB.NET to objective-C. My only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.