From edd at debian.org  Wed Oct  2 17:52:22 2013
From: edd at debian.org (Dirk Eddelbuettel)
Date: Wed, 2 Oct 2013 10:52:22 -0500
Subject: [Rd] C++ debugging help needed
In-Reply-To: <1380728746.1581.6.camel@braque.iarc.fr>
References: <524C32CF.2060307@gmail.com> <524C362F.1040108@gmail.com>
	<1380728746.1581.6.camel@braque.iarc.fr>
Message-ID: <21068.16694.347218.948671@max.nulle.part>


On 2 October 2013 at 15:45, Martyn Plummer wrote:
| In C++, everything goes in the global namespace unless the programmer
| explicitly creates one. So when you dynamically load two dynamic shared
| libraries with a "Shape" object they clash.
| 
| The solution here is to put 
| 
| namespace rgl {
| ...
| }
| 
| around your class definitions in the rglm package, and 
| 
| using rgl::Shape

Exactly.
 
| at the top of any source file that refers to rgl Shape. Likewise, the
| igraph package should declare shape in the "igraph" namespace.

And as I wrote to Duncan off-list, igraph doesn't, even though it otherwise
uses an igraph namespace:

   /** Shape.h
    */
   
   #ifndef SHAPE_H
   #define SHAPE_H
   
   #include <string>
   #include "Color.h"
   #include "Ray.h"
   #include "Point.h"
   
   class Shape
   [....]   

So the clash is due to two packages simulatenously failing to make use of
namespaces.  

And at that point the linker appears to pick in search (link ?) order.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



[Rd] C++ debugging help needed
Dirk Eddelbuettel