Message: Re: G4 Makefiles and static libraries Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: G4 Makefiles and static libraries 

Forum: Installation and Configuration
Re: Question G4 Makefiles and static libraries (Lucas Clemente)
Re: More Re: G4 Makefiles and static libraries (Gabriele Cosmo)
Re: Ok Re: G4 Makefiles and static libraries (Lucas Clemente)
Re: None Re: G4 Makefiles and static libraries (David Krapohl)
Date: 13 Jan, 2010
From: Lucas Clemente <Lucas Clemente>

Hi David,

i solved the problem of linking a static G4 library into my software with a few hacks ;)

First, I built my own static libGeant4.a. This is quite simple, I used the bash command

 find . -name *.o |xargs ar rcs libGeant4.a

in the Geant4 build directory (it just packs all the object files into a static library that you can link against).

You can then take the created libGeant4.a and put it in some nice directory. The step of including this lib from CMake is pretty simple, you baiscally just need these lines (i built geant4 with the option of putting all headers in one directory):

 INCLUDE_DIRECTORIES(/path/to/geant/include)
 INCLUDE_DIRECTORIES(/path/to/CLHEP/install/include)
 LINK_DIRECTORIES(/path/to/CLHEP/install/lib)
 LINK_DIRECTORIES(/path/to/your/created/library)
 LINK_LIBRARIES(Geant4 CLHEP)

 ADD_LIBRARY(myLibrary STATIC sourceFile1.cpp, sourceFile2.cpp ...)

This worked fine for me, let me know if you encounter any problems.

Greetings, Lucas

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: G4 Makefiles and static libraries   (David Krapohl - 13 Jan, 2010)
 Add Message Add Message
to: "Re: G4 Makefiles and static libraries"

 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 ]