Bug 486 - MKL linking error: multiple definitions
MKL linking error: multiple definitions
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: General
3.1
All All
: Normal major
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-02 12:28 UTC by Janick Martinez Esturo
Modified: 2012-07-05 13:33 UTC (History)
3 users (show)



Attachments

Description Janick Martinez Esturo 2012-07-02 12:28:50 UTC
Hi!

I'm having a lot of "multiple definitions" errors when linking of object files that are compiled using -DEIGEN_USE_MKL_ALL, e.g. when using two files

//test.cpp
#include <Eigen/QR>

int test();

int main() {
 test();
}

//test2.cpp
#include <Eigen/QR>

int test() {
}

some compute() methods for the mkl operations are defined multiple times, which gives these errors on link time:

/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&)':
test2.cpp:(.text+0x0): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0x0): first defined here
/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<float, -1, -1, 0, -1, -1> const&)':
test2.cpp:(.text+0x350): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<float, -1, -1, 0, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0x350): first defined here
/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<double>, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<std::complex<double>, -1, -1, 0, -1, -1> const&)':
test2.cpp:(.text+0x68a): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<double>, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<std::complex<double>, -1, -1, 0, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0x68a): first defined here
/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<float>, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<std::complex<float>, -1, -1, 0, -1, -1> const&)':
test2.cpp:(.text+0x9da): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<float>, -1, -1, 0, -1, -1> >::compute(Eigen::Matrix<std::complex<float>, -1, -1, 0, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0x9da): first defined here
/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<double, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<double, -1, -1, 1, -1, -1> const&)':
test2.cpp:(.text+0xd14): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<double, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<double, -1, -1, 1, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0xd14): first defined here
/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&)':
test2.cpp:(.text+0x1064): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<float, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<float, -1, -1, 1, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0x1064): first defined here
/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<double>, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<std::complex<double>, -1, -1, 1, -1, -1> const&)':
test2.cpp:(.text+0x139e): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<double>, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<std::complex<double>, -1, -1, 1, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0x139e): first defined here
/tmp/cc8YsEVj.o: In function `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<float>, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<std::complex<float>, -1, -1, 1, -1, -1> const&)':
test2.cpp:(.text+0x16ee): multiple definition of `Eigen::ColPivHouseholderQR<Eigen::Matrix<std::complex<float>, -1, -1, 1, -1, -1> >::compute(Eigen::Matrix<std::complex<float>, -1, -1, 1, -1, -1> const&)'
/tmp/ccz28417.o:test.cpp:(.text+0x16ee): first defined here
collect2: error: ld returned 1 exit status

The same also happens for all other MKL related comptations of the LAPACKE interface. Perhaps this is a known problem, but is should be possible to link two files compiled with EIGEN_USE_MKL_ALL, am I right. Although the method definitions are the same, shouldn't the compiler figure this out by itself?
I'm using gcc-4.7.1, but the same errors occure with clang++-3.1.

Greets Janick
Comment 1 Gael Guennebaud 2012-07-05 13:33:45 UTC
thank you for the report, fixed:

https://bitbucket.org/eigen/eigen/changeset/9b5752951f2d/
changeset:   9b5752951f2d
user:        ggael
date:        2012-07-05 13:32:23
summary:     fix bug 486: template speacialization of member functions must be declared inline to avoid duplicate references

https://bitbucket.org/eigen/eigen/changeset/0950f07f4232/
changeset:   0950f07f4232
branch:      3.1
user:        ggael
date:        2012-07-05 13:32:23
summary:     fix bug 486: template speacialization of member functions must be declared inline to avoid duplicate references
(transplanted from 9b5752951f2dc26f113acad19fdf51b09b01c118)

Note You need to log in before you can comment on or make changes to this bug.