This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 486 - MKL linking error: multiple definitions
Summary: MKL linking error: multiple definitions
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: General (show other bugs)
Version: 3.1
Hardware: All All
: Normal major
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-02 12:28 UTC by Janick Martinez Esturo
Modified: 2019-12-04 11:46 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)
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.

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