Problem 361

Summary: Compilation warnings and linking error when importing CAD systems
Product: Geant4 Reporter: jm.perez
Component: geometryAssignee: Gabriele Cosmo <Gabriele.Cosmo>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.1   
Hardware: PC   
OS: Linux   

Description jm.perez 2002-03-04 06:50:16 CET
I am trying to modify a working G4 example in order to import the geometry from
a STEP compliant CAD file.

The following warnings are received when I include the file G4AssembyCreator.hh
in the geometry.cc file at src/ directory :

/home/jmperez/GEANT4/geant4.3.1/source/geometry/solids/STEP/include/SdaiCONFIG_CONTROL_DESIGN.h:21568:5:
warning: pasting "SDAI" and "::" does not give a valid preprocessing token
/home/jmperez/GEANT4/geant4.3.1/source/geometry/solids/STEP/include/SdaiCONFIG_CONTROL_DESIGN.h:21570:5:
warning: pasting "::" and "DAObject__set_var" does not give a valid
preprocessing token
In file included from
/home/jmperez/GEANT4/geant4.3.1/source/geometry/solids/STEPinterface/include/G4GeometryCreator.hh:27,
                 from
/home/jmperez/GEANT4/geant4.3.1/source/geometry/solids/STEPinterface/include/G4AssemblyCreator.hh:29,
                 from src/geometria.cc:21:
/home/jmperez/GEANT4/geant4.3.1/source/geometry/solids/STEP/include/schema.h:46:1:
warning: pasting "::" and "Model_contents_ptr" does not give a valid
preprocessing token
/home/jmperez/GEANT4/geant4.3.1/source/geometry/solids/STEP/include/schema.h:46:1:
warning: pasting "SDAI" and "::" does not give a valid preprocessing token
Creating/replacing object files in ./tmp/Linux-g++/main/libmain.a
Using global libraries.

The next linking error is received when the line

G4AssemblyCreator MyAC("nachito.step");

is included in the Geometry.cc file at src/ directory:

Linking main ...
/home/jmperez/GEANT4/geant4.3.1/lib/Linux-g++/libG4geometry.a(G4GeometryTable.o)(.bss+0xc0):
multiple definition of `dir'
./tmp/Linux-g++/main/libmain.a(generador.o)(.bss+0x98): first defined here
/usr/bin/ld: Warning: size of symbol `dir' changed from 24 to 8 in
G4GeometryTable.o
collect2: ld returned 1 exit status
gmake: *** [bin/Linux-g++/main] Error 1


Question: Could you provide a working example using these classes?
Comment 1 Gabriele Cosmo 2002-03-04 09:23:59 CET
From the errors layout it looks like the user is compiling using a g++ compiler
version not supported for release 3.1. The supported compiler for Geant4 3.1 is
egcs-1.1.2. The user should upgrade to release 4.0 (and related patches) to
build successfully on gcc-2.95.2 or higher.
The relevant part of an example on how to import a STEP AP203 file from a CAD
system is given in the User Manual for Application Developers. A real example
will be anyhow provided in future.
On Linux, to avoid incompatibilities with ANSI standard treatment of strings,
the code must be compiled in non-ANSI mode. Therefore, I would suggest if the
following lines are added to the GNUmakefile (or in the build setup) of the
user application using the STEP-reader libraries:

ifneq(,$(findstring Linux-g++,$(G4SYSTEM)))
  ansi_options = -Wall -ansi -pedantic
  NCXX = $(filter-out $(ansi_options),$(CXXFLAGS))
  NCPP = $(CPPFLAGS)
  CXXFLAGS := $(NCXX)
  CPPFLAGS := $(NCPP) -w
endif