• 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
Re: Strange linking problem with Objective-C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange linking problem with Objective-C++


  • Subject: Re: Strange linking problem with Objective-C++
  • From: Ken Thomases <email@hidden>
  • Date: Sat, 15 Aug 2009 19:00:10 -0500

On Aug 15, 2009, at 12:28 PM, Wade Williams wrote:

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

No, it's not there. In test.o, __ZN11wlWindowMac13getLoopingVarEv (wlWindowMac::getLoopingVar()) is undefined (U). In wlwindowmac.o, __ZN6window11wlWindowMac13getLoopingVarEv (window::wlWindowMac::getLoopingVar()) is defined. As you can see just by looking at them, these symbols do not match. In particular, they differ by the presence of the "window" namespace qualifier.


It seems that in some compilation units, wlWindowMac is declared to be within the window namespace, but in other compilation units it is not. The source clipping you provided is not sufficient to see why that's so. I recommend that you preprocess test.cpp and wlWindowMac.app and compare them for inconsistent namespace scoping of the declarations of wlWindowMac in each case.

By the way, it's generally considered bad style to put a "using namespace" statement in a header file. It somewhat defeats the purpose of putting stuff into separate namespaces. It can also hide problems like you're having. I recommend that you develop a version of your code that never does "using namespace" and instead always uses fully qualified names, to help you find your inconsistencies.

Regards,
Ken

_______________________________________________
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: Wade Williams <email@hidden>
References: 
 >Strange linking problem with Objective-C++ (From: Wade Williams <email@hidden>)

  • Prev by Date: ld errors when Cocoa app linking C++ via intermediate ObjC++ library
  • Next by Date: Recommendations for strip(1)? Was: gdb: "No line number info...."
  • Previous by thread: Strange linking problem with Objective-C++
  • Next by thread: Re: Strange linking problem with Objective-C++
  • Index(es):
    • Date
    • Thread