• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Strange linking problem with Objective-C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange linking problem with Objective-C++


  • Subject: Strange linking problem with Objective-C++
  • From: Wade Williams <email@hidden>
  • Date: Sat, 15 Aug 2009 12:28:16 -0500

I've got a very strange linking problem and I'm really pulling my hair out.

I've got a C++ object based off an abstract base class that calls a C routine in an Objective-C++ file, passing it a reference to itself.  The C routine creates an Obj-C object, passing it the reference to the C++ object.  Finally, the Obj-C class uses the reference to call back to the C++ object.

This has worked fine for things that are inherited from the base class, but anything I've tried to call from the instantiated C++ object is failing to link. 

So, I created a simple C++ object and tried to call back from it to my C++ object.  That fails to link too.

Undefined symbols:
  "test::test(window::wlWindowMac*)", referenced from:
      window::wlWindowMac::start()     in libwindow.a(wlwindowmac.o)
  "wlWindowMac::getLoopingVar()", referenced from:
      test::doLoopTest()      in libwindow.a(test.o)
ld: symbol(s) not found



All indications at this point would be that the routine isn't defined.  However, it's there when I examine the static library into which it's compiled:

xanadu:Debug wwilliam$ nm -A libwindow.a | grep getLoopingVar
libwindow.a:wlwindowmac.o: 00000090 T __ZN6window11wlWindowMac13getLoopingVarEv
libwindow.a:wlwindowmac.o: 00000000 A __ZN6window11wlWindowMac13getLoopingVarEv.eh
libwindow.a:test.o:          U __ZN11wlWindowMac13getLoopingVarEv

So next theory - maybe I'm not linking to the static library I think I am.  So I turned on "-why_load -t" in the linker flags.

But those are both the correct libraries

/Users/wwilliam/Development/project/build/Debug/libwindow.a
/Users/wwilliam/Development/project/build/Debug/libwindow.a(test.o)


Snipped relevant portions of code:

from wlWindow.h

namespace window {

class wlWindow : public luaLibrary
{
   protected:
    bool looping;
    void idle();
};
}

using namespace window;

----------
from wlWindowMac.h

#include wlWindow.h

class wlWindowMac : public wlWindow
{
public:
bool getLoopingVar();
void setLoopingVar(bool isLooping);

};

---------

from wlWindowMac.cpp
#include "test.h"

bool wlWindowMac::start()
{
test *t;


t = new test(this);


t->doLoopTest();
}
---------

test.h

#include "wlwindowmac.h"

class test
{
public:
test(wlWindowMac *ref);
void doLoopTest();
wlWindowMac *myref;
};

----------------
test.cpp

#include "test.h"

test::test(wlWindowMac *ref)
{
myref = ref;
}

void test::doLoopTest()
{
bool isLooping;


isLooping = myref->getLoopingVar();


}

Any thoughts at all appreciated.  I'm losing my mind over this one.


N
d
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Strange linking problem with Objective-C++
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: dyld: "Library not loaded:" Error
  • Next by Date: how do you go back
  • Previous by thread: Re: Xcode, Dyld, External Dynamic Libraries and Setting {DY}LD_LIBRARY_PATH for Running Targets
  • Next by thread: Re: Strange linking problem with Objective-C++
  • Index(es):
    • Date
    • Thread