This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 486

Summary: MKL linking error: multiple definitions
Product: Eigen Reporter: Janick Martinez Esturo <ph03>
Component: GeneralAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: major CC: gael.guennebaud, jacob.benoit.1, ph03
Priority: Normal    
Version: 3.1   
Hardware: All   
OS: All   
Whiteboard:

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)
Comment 2 Nobody 2019-12-04 11:46:17 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/486.