Bugs


The following are known bugs, installation problem, known incompatibilities ... detected for Xmipp

Multiple defined symbols

Multiple defined symbols

During the link of Xmipp programs you might experience some annoying messages telling you that there are symbols that are defined several times. The problem arises when there are functions defined in the header of the library. This is a common practise in C++, if the function is very short then it is defined as an inline function in the header, otherwise it will be implemented outside in a different module (.cc). This module will be precompiled for you in a library (.a), that is what you include when linking. This allows you to save time in the call to those short functions, at the same time that you don't have to recompile the library modules each time you want to compile something. As a disadvantage, all the precompiled modules using the header with the inline functions have a copy of the inline functions defined as "weak". Depending on the configuration of your compiler you may be warned about the existence of these weak copies.

Consider the following modules and program which show you a very simple example where this effect occurs. The example is using the STL library, concisely the complex module.

   mod1.cc
      #include <complex>

      float_complex sum1() {
         float_complex a(0,-1);
         float_complex b(0,-2);
         return a+b;
      }

   mod2.cc:
      #include <complex>

      float_complex sum2() {
         float_complex a(0,1);
         float_complex b(0,2);
         return a+b;
      }

   main.cc
      #include <complex>

      extern float_complex sum1();
      extern float_complex sum2();
      void main() {
         float_complex c;
         c=sum1()+sum2();
      }
And now suppose the following compilation sequence:
      g++ -c mod1.cc
      g++ -c mod2.cc
      g++ -o main main.cc mod1.o mod2.o
The result is
ld: WARNING 131: Multiply defined weak symbol:(complex<float> operator/<float>(complex<float> const &, float)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(complex<double> operator/<double>(complex<double> const &, double)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(complex<long double> operator/<long double>(complex<long double> const &, long double)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(complex<float> operator+<float>(complex<float> const &, complex<float> const &)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(long double imag<long double>(complex<long double> const &)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(long double real<long double>(complex<long double> const &)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(double imag<double>(complex<double> const &)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(double real<double>(complex<double> const &)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(float imag<float>(complex<float> const &)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(float real<float>(complex<float> const &)) in /var/tmp/cca004dl1.o and mod1.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(complex<float> operator/<float>(complex<float> const &, float)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(complex<double> operator/<double>(complex<double> const &, double)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(complex<long double> operator/<long double>(complex<long double> const &, long double)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(complex<float> operator+<float>(complex<float> const &, complex<float> const &)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(long double imag<long double>(complex<long double> const &)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(long double real<long double>(complex<long double> const &)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(double imag<double>(complex<double> const &)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(double real<double>(complex<double> const &)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(float imag<float>(complex<float> const &)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
ld: WARNING 131: Multiply defined weak symbol:(float real<float>(complex<float> const &)) in /var/tmp/cca004dl1.o and mod2.o (2nd definition ignored).
The explanation is that the inline functions inside <complex> are included in the precompiled modules mod1.o and mod2.o. So, the content of the modules is
   mod1.o:
      sum1()
      and all inline functions from <complex>
      
   mod2.o:
      sum2()
      and all inline functions from <complex>
When linking the two modules together with the main program, all inline functions are repeated twice but as weak symbols, the linker warns of this redeclaration of symbols.

SOLUTIONS:

1) There cannot be inline functions within a header file. What is very inefficient as it forces all functions to be called as true functions instead as macros.

2) Never do objects of files containing the same modules. What is rather impossible.

3) Link with the -w option which inhibits all warnings

      g++ -w -o main main.cc mod1.o mod2.o
So the solution adopted in Xmipp has been to ignore these messages.
 Back to beginning of file

xmipp_logo.gif (4792 bytes)