Registered Member
|
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:
this is the g++ command for linking that I use:
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. |
Moderator
|
which Eigen version? I guess g++ is referring to mingw? which version?
Also, do you compile all files with the exact same flags? |
Moderator
|
A quick search suggests a mingw issue that can be workaround with -Os.
|
Registered Member
|
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:
I tried the -Os in both compiling or linking part, but I still got the same error message. |
Registered Member
|
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). |
Moderator
|
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.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]