This is a known misfeature of using the optimizer,  Appendix A of the
User's guide says:

  If you are having problems with undefined symbols at load time, try
  compiling your star with the same level of optimization as the binary
  was built with. We ship pigiRpc and ptcl binaries that have been
  compiled with -O2, so you may want to compile your star with -O2.

More specifically, the missing symbol is the DFPortHole destructor,
and in Ptolemy 0.7.2devel it is defined in libptolemy.a:

cxh@doppler 7% echo _._10DFPortHole | c++filt
DFPortHole::~DFPortHole(void)

cxh@doppler 8% gnm --print-file * | grep _._10DFPortHole
libptolemy.a:DFPortHole.o:00000000 W _._10DFPortHole

libptolemy.a is a static library, so when you are dynamically linking,
I believe that some symbols that are in libptolemy.a, but that were
not pulled into the pigiRpc binary when the binary was linked will not
be available to you 

I otherwords, when the pigiRpc binary is linked, and the DFPortHole
destructor is not used because the source files were compiled with
-02, then the destructor may not be present in the pigiRpc binary.

If I compile stars without -O2, then I can see that the
symbol is undefined.  If I compile with -O2, then the bogus symbol is
not present.  I consider this to be a flaw in the compiler, but
I don't think others share my opinion.  It could be that there
is a appropriate magic setting for the compiler that would not
change what symbols are undefined.

Oddly, for me with Ptolemy 0.7.2devel compiled with gcc-2.95.1 under
Solaris 7, your sample star will load, though I changed Complex.h to
ComplexSubset.h

To add -O2 to the compile options used by shift-L, you should
edit src/pigilib/pigiLoader.cc

This is a bit of a bug in Ptolemy, it should be easier to modify
those settings.  The workaround is to make a makefile present in the
directory that contains the stars, then you can use whatever
compiler settings you would like.



-Christopher

--------

    
    Hi there,
    
    my question is connected to the posting of Werner Hack
    (date: 10/21/99) who is a collegue of mine.
    He had problems building Ptolemy 0.71p1 on SUN Ultra 10 with
    Solaris 7 (SunOS 2.7). Meanwhile we have been able to
    build the whole package, but still cannot link user stars.
    
    Consider the following simple star definition:
    
    ------------------------------------------------------------
    defstar {
      name    { Norm }
      domain  { SDF }
    
      desc {
        output = norm(input).
      }
      hinclude { "Complex.h" }
    
      input {
        name { input }
        type { Complex }
      }
      output {
        name { output }
        type { float }
      }
      go {
        Complex temp = input%0;
        output%0 << norm(temp);
      }
    }
    ------------------------------------------------------------
    
    Compilation and dynamic linking using Shift-L under pigi
    results in the message:
    
    Error: Error linking file/tmp/__ptlink26145_0.so dlopen: ld.so.1:
    /unix/ptolemy-0.7p1/obj.sol2.7/pigiRpc/pigiRpc: fatal:
    relocation error: file /tmp/__ptlink26145_0.so: symbol _._10DFPortHole:
    referenced symbol not found
    
    (The command "nm -C /tmp/__ptlink26145_0.so" shows us that the
     referenced symbol is the destructor of class DFPortHole)
    
    
    One way to get the star dynamically linked is:
      first compile it with the Makefile below;
      then link it under pigi with Shift-L !
    
    The difference here is the "-O2" compiler option
    in the Makefile !!
    
    (pigi uses "g++ -c -fpic -DPT_EGCS" only if we compile
     with Shift-L)
    
    
    ------------------------------------------------------------
    # definitions
    
    PTLANG      = ptlang
    CC  = g++
    CCFLAGS     = -c -fpic -O2 -DPT_EGCS
    LD  = ld
    LDFLAGS     = -r -o
    AR      = ar
    ARFLAGS     = -r
    
    
    SDFNorm.o: SDFNorm.cc
    
    # compilation and parsing
    
    .PRECIOUS: %.c %.cc
    
    %.o: %.c
        $(CC) $(CCFLAGS)\
        -o $@ $<
    
    %.o: %.cc
        $(CC) $(CCFLAGS)\
        -I$(PTOLEMY)/src/domains/sdf/kernel\
        -I$(PTOLEMY)/src/domains/sdf/stars\
        -I$(PTOLEMY)/src/domains/sdf/dsp/stars\
        -I$(PTOLEMY)/src/domains/sdf/image/stars\
        -I$(PTOLEMY)/src/domains/sdf/tcltk/stars\
        -I$(PTOLEMY)/src/domains/sdf/matrix/stars\
        -I$(PTOLEMY)/src/cg/kernel\
        -I$(PTOLEMY)/src/kernel\
        -o $@ $<
    
    %.cc: %.pl
        $(PTLANG) $<
    
    ------------------------------------------------------------
    
    
    My questions are:
    
    Why do we need the optimization being switched on to get
    the star linked ?
    
    How can I tell pigi to use "-O2" as an additional compiler
    option when compiling/linking a user star with Shift-L ?
    (which Makefile, etc... has to be edited?)
    
    
    Any advice would be helpful.
    Many thanx in advance.
    
    Christian Sgraja
    
    
    ---------------------------------------------------------------------------
    Christian Sgraja                [EMAIL PROTECTED]
                                    http://it.e-technik.uni-ulm.de/~sgraja
    
    Universitaet Ulm                Tel.:   +49 (0)731 50-26289
    Abteilung Informationstechnik   Sekr.:  +49 (0)731 50-26251
    Albert-Einstein-Allee 43        Fax:    +49 (0)731 50-26259
    89081 Ulm
    ---------------------------------------------------------------------------
--------

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to