[cctbxbb] Using cctbx::uctbx::unit_cell in c++ code / boosted to Python

Graeme.Winter at diamond.ac.uk Graeme.Winter at diamond.ac.uk
Fri Jan 25 06:25:36 PST 2013


Hi Luc,

Funny. On my OS X system solution #1 appeared to work well!

I looked at some other SConscripts on how to do this & copied.

Thanks for the description though - this hybrid programming stuff takes a little getting used to...

Cheerio,

Graeme

From: cctbxbb-bounces at phenix-online.org [mailto:cctbxbb-bounces at phenix-online.org] On Behalf Of Luc Bourhis
Sent: 25 January 2013 14:21
To: cctbx mailing list
Subject: Re: [cctbxbb] Using cctbx::uctbx::unit_cell in c++ code / boosted to Python


On 25 Jan 2013, at 14:46, Graeme.Winter at Diamond.ac.uk<mailto:Graeme.Winter at Diamond.ac.uk> wrote:


Equally I could just leave the additional clutter there but it feels like I should not need it...


You have a function "generate_unit_cell" written in C++ whose body creates a new unit_cell object and that is exposed to Python with Boost Python inside a module x2tbx. When Python loads that module, the linker of your OS is asked to resolve all symbols in your x2tbx.so. It finds a constructor
            cctbx::uctbx::unit_cell::unit_cell(scitbx::af::tiny<double, 6ul> const&)
but it does not know what code it shall run for it. That's because that code is in cctbx/uctbx/uctbx.cpp that has been compiled and linked into a library libcctbx. Thus you have 2 solutions here: (1) either you link that library with your x2tbx.so (modify the SConscript for that), or (2) just import a Boost Python wrapper that has been linked with that library. The line "import cctbx.uctbx" belongs to solution (2) because the uctbx Python module loads the Boost Python uctbx wrappers that is linked with libcctbx. As for solution (1), beware Dragons here! It will reliably work only if all libraries are dynamic. Currently, libcctbx is a static library on MacOS and you will run into troubles on that platform with that solution (1). As it has been discussed in the past on this very forum, there is no good reason that we keep using static libs on MacOS but until somebody spends time to fix that, you are stuck with solution (2).

Best wishes,

Luc






-- 

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.

Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 

Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.

Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom

 







-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://phenix-online.org/pipermail/cctbxbb/attachments/20130125/4a4ae7a1/attachment-0001.htm>


More information about the cctbxbb mailing list