Message: Why is CXXFLAG -fPIC not used with MT? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Why is CXXFLAG -fPIC not used with MT? 

Forum: Multithreading
Date: 10 Jan, 2014
From: Jan Christoph Terasa <Jan Christoph Terasa>

Hello,

I compiled and installed the final version of GEANT4 10.0.0 as a shared build with MT, and tried to build one of the examples (basic/B1). Upon compilation I encountered the following error message:

/usr/bin/ld: B1ActionInitialization.o: relocation R_X86_64_32S against `_ZTV22B1ActionInitialization' can not be used when making a shared object; recompile with -fPIC B1ActionInitialization.o: error adding symbols: Bad value

Then I added -fPIC to my CXXFLAGS in my makefile, and compiled the example successfully.

After further investigation I found the following block in share/Geant4-10.0.0/geant4make/config/sys/Linux-g++.gmk:

ifdef G4LIB_BUILD_SHARED
    ifndef G4MULTITHREADED
      CXXFLAGS  += -fPIC
      FCFLAGS   += -fPIC
      CCFLAGS   += -fPIC
    endif
  endif

This of course disables -fPIC option with a shared build and MT. What is the reason to disable that option in MT mode? What is the intended way to avoid that problem?

kind regards, Christoph

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

1 Warning: Re: Why is CXXFLAG -fPIC not used with MT?   (Andrea Dotti - 10 Jan, 2014)
1 Ok: Re: Why is CXXFLAG -fPIC not used with MT?   (Christoph Terasa - 10 Jan, 2014)
(_ Note: Re: Why is CXXFLAG -fPIC not used with MT?   (Andrea Dotti - 14 Jan, 2014)
2 News: Re: Why is CXXFLAG -fPIC not used with MT?   (Andrea Dotti - 28 Feb, 2014)
 Add Message Add Message
to: "Why is CXXFLAG -fPIC not used with MT?"

 Subscribe Subscribe

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