How to remove symbol definition from a Library

Discussion in 'Mac Programming' started by squater, Jun 16, 2007.

  1. squater macrumors newbie

    Joined:
    Jun 16, 2007
    #1
    I'm trying to compile C++ source that requires a number of libraries. Unfortuantly two libraries contain definitions for the same symbol and results in an error. Is there a way to specify which library take preference in the symbol definition?

    I know this is not strictly exclusively a Mac orientated question, but I am compiling on OS X so thought here might be a good place to start. Thanks for any help. Below is a printout of the error I receive:

    Input:
    /usr/local/mpich-1.2.7/bin/mpicxx -g -O2 -o mpifxcorr mpifxcorr.o fxmanager.o core.o datastream.o visibility.o configuration.o uvw.o mode.o mk5.o polyco.o -Wl,-bind_at_load -L/Library/Frameworks/Intel_IPP.framework/Versions/Current/lib/ -L/Library/Frameworks/Intel_IPP.framework/Versions/Current/lib -L/Users/andrewwoods/corr/rpfits/ -L/Users/andrewwoods/corr/vlba_utils/ -lipps -lguide -lippvm -lvlba_utils -lrpfits -lg2c -lm

    Output
    /usr/bin/ld: multiple definitions of symbol ___divdi3
    /usr/local/lib/libg2c.dylib(_divdi3.o) definition of ___divdi3
    /usr/lib/gcc/i686-apple-darwin8/4.0.1/../../../libgcc_s.10.4.dylib(_divdi3_s.o) definition of ___divdi3
    collect2: ld returned 1 exit status
     
  2. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    Can you get the source for one of the libraries and change it?
     
  3. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    Take a look at the strip command.

    From man strip:

    strip removes or modifies the symbol table attached to the output of
    the assembler and link editor. This is useful to save space after a
    program has been debugged and to limit dynamically bound symbols.

    It might be possible to use this to remove the symbol from one of the libraries...
     
  4. brkirch macrumors regular

    Joined:
    Oct 18, 2001
    #4
    Yes, first attempt to compile again except with the -v option added to the compile command. This will give you the command that is being sent to the linker ld in the output. You then need to add the -m option to the linker command to allow for multiply defined symbols. Here's a description of what the -m option for the linker does:
    Of course you should still try to if possible edit the source of what you are compiling to resolve the conflict, but this may work if editing the source isn't an option.
     
  5. squater thread starter macrumors newbie

    Joined:
    Jun 16, 2007
    #5
    Thanks for that, resolved the double symbol definition problem.

    Unfortunately I don't have access to the library source, just the binaries. Although I am using the gfortan library from sourceforge so I'm sure it should be available.
     

Share This Page