This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Error in GCC from Eigen in managing caching size

Tags: None
(comma "," separated)
mehrdadh
Registered Member
Posts
26
Karma
0
Hi

I have a set of c++ files that use Eigen. I am trying to make a DLL for Excel. I have been able to compile it successfully using Visual Studio C++. I had a definition file in Visual Studio that basically export the functions for DLL.

However, I tried to use g++ to compile this DLL since I thought I will get better optimization. For that, I put __declspec(dllexport) at the beginning of my functions.

There are three cpp files that I used with g++ to compile and then link them together. The compilation is successful but there is an error in the linkage:

Code: Select all
duplicate section `.data$_ZZN5Eigen8internal20manage_caching_sizes ENS_6ActionEPiS2_E13m_l1CacheSize[Eigen::internal::manage_caching_sizes(Eigen::Action, int*, int*)::m_l1CacheSize]' has different size


this is the g++ command for linking that I use:

Code: Select all
g++ -shared -s -static-libgcc -o Silver.dll  Rand.o reductions.o multistage.o fastCalc.o -Wl,--add-stdcall-alias


I don't know why this is happening. Maybe something to do with the fact that I have both dynamic Eigen objects and static ones ? i.e. VetorXd and VectorX4 ?

Have you experienced such a linkage error and could help me out ? Let me know if there is any other information that I should mention.

THANKS so much in advance.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
which Eigen version? I guess g++ is referring to mingw? which version?

Also, do you compile all files with the exact same flags?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
A quick search suggests a mingw issue that can be workaround with -Os.
mehrdadh
Registered Member
Posts
26
Karma
0
It is gcc 4.6.3

I have to mention that for each of these files, previously, I had been compiling them with the same g++ version to have a DLL for 'R' - the statistical package - successfully (I had to include RcppEigen, etc. on top, but that's irrelevant).
Now, on the other hand, I want a DLL for VBA, so I don't need 'R' related stuff. I have however more functionality in these new files (one of them involves having static dimensions for some vectors - of size 4). Otherwise it's basically the same files. And I guess if there are any header related problem (i.e. not including headers the same way as before), I would have gotten errors. So headers should be correctly there.


Here is the exact g++ commands that I am executing:

Code: Select all
g++  -DEIGEN_NO_DEBUG -DNDEBUG -s -I"C:/Eigen" -fomit-frame-pointer -fno-operator-names -O3 -mfpmath=sse -Wall -mtune=core2 -msse2 -c reductions.cpp -o reductions.o

g++  -DEIGEN_NO_DEBUG -DNDEBUG -s -I"C:/Eigen" -fomit-frame-pointer -fno-operator-names -O3 -mfpmath=sse -Wall -mtune=core2 -msse2 -c multistage.cpp -o multistage.o

g++  -DEIGEN_NO_DEBUG -DNDEBUG -s -I"C:/Eigen" -fomit-frame-pointer -fno-operator-names -O3 -mfpmath=sse -Wall -mtune=core2 -msse2 -c fastCalc.cpp -o fastCalc.o

g++  -DEIGEN_NO_DEBUG -DNDEBUG -s -I"C:/Eigen" -fomit-frame-pointer -fno-operator-names -O3 -mfpmath=sse -Wall -mtune=core2 -msse2 -c Rand.cpp -o Rand.o


g++ -shared -s -static-libgcc -o Silver.dll  Rand.o reductions.o multistage.o fastCalc.o -Wl,--add-stdcall-alias



I tried the -Os in both compiling or linking part, but I still got the same error message.
mehrdadh
Registered Member
Posts
26
Karma
0
Well, I ended up using #include to include all my cpp files in one of them, so that I have only one single cpp file to compile, not multiple.

Then I ended up compiling that one single cpp file and it worked. I haven't tested the DLL yet, but if the test works, I will consider the problem solved.

I guess the reason had something to do with multiple cpp files (maybe multiple inclusions of Eigen? don't know).
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
yes, it seems mingw do not generate the same binary code for the same template code, and so the linker cannot do its job in gluing all .o files.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]