Message: Need help with static linkage to developed libreries Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Need help with static linkage to developed libreries 

Forum: User Requirements
Date: 05 Apr, 2011
From: Miguel Couceiro <Miguel Couceiro>

Hi all,

First, I apologizes if this is the wrong forum section for my question, but it seemed to me that, of all the forum sections, this one was the most appropriate.

I am developing a GEANT4 program to simulate a PET system (not based in crystal detectors, so I can not use GATE).

As the size of the program grew up, I decided to separate some classes, which encapsulate similar functionalities, into independent and self-contained libraries. Among them are the Physics ans Phantom classes. Both use several messengers to set parameters at run time.

Physics classes runs ok with static linkage to the program, but Phantom classes does not, and originate a memory corruption in the program. However, Phantom classes run without problems, and as expected, if used as part of the code, rather than in a static library.

Phantom class is composed of a singleton PhantomFactory (with an associated messenger), that manages the creation and storage of individual phantoms, all derived from a base abstract class (VPhantom). Each individual Phantom has a messengers to set its own parameters. The problem is precisely in these messengers, namely in the creation of the messenger command tree. During the creation of the command strings a memory corruption occurs:

G4String sPhtName = m_pPhantom->GetPhantomName(); G4String sBaseDir = "/Phantoms/" + sPhtName;

m_pPhtDir = new G4UIdirectory(G4String(sBaseDir + "/"));

I think the error occurs in the creation of the G4UIdirectory, during the assignment of the string parameter passed as argument, to a G4String in the constructor of G4UIcommand. This error is traceable to libc, during the assignment.

Can anyone give me a hint on how to solve this problem, in order for me to use the Phantom classes in a separate library?

By the way, the system I am running the code in is Kubuntu 10.04 64 bit, upgraded to Kubuntu 10.10, with gcc version 4.4.3 (4ubuntu5), and GEANT4 v9.2-p04

Thanks in advance, Miguel Couceiro

PS1: I have also attached all the files to this message, just in case someone wants to test them.

PS2: To use the class, the singleton PhantomFactory object has to be created first, for instance, at the beginning of main(). Other phantoms will be added, but for now only 3 are implemented.

 Add Message Add Message
to: "Need help with static linkage to developed libreries"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]