Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple definition of AugLagrangianFunction overload with MinGW #342

Closed
rcurtin opened this issue Dec 29, 2014 · 1 comment
Closed

multiple definition of AugLagrangianFunction overload with MinGW #342

rcurtin opened this issue Dec 29, 2014 · 1 comment

Comments

@rcurtin
Copy link
Member

rcurtin commented Dec 29, 2014

Reported by rcurtin on 9 Mar 44618083 22:05 UTC
From the mailing list, Gilles Barges reports that he has mlpack compiling under MinGW; everything compiles, except the mlpack_test executable:

cd /C/Users/gbg/Desktop/Librairies/mlpack-1.0.9/build-w64/src/mlpack/tests && /c/TDM-GCC-64/bin/g++.exe   -O3    -Wl,--whole-archive CMakeFiles/mlpack_test.dir/objects.a -Wl,--no-whole-archive  -o ../../../mlpack_test.exe -Wl,--out-implib,../../../libmlpack_test.dll.a          
+-Wl,--major-image-version,0,--minor-image-version,0  -L/C/Users/gbg/Desktop/msys/1.0/local/lib  ../../../libmlpack.a /C/Users/gbg/Desktop/msys/1.0/bin/libarmadillo.dll /C/Users/gbg/Desktop/msys/1.0/local/bin/libopenblas.dll                                                      
+/C/Users/gbg/Desktop/msys/1.0/local/lib/libboost_program_options-mgw48-mt-1_55.a /C/Users/gbg/Desktop/msys/1.0/local/lib/libboost_unit_test_framework-mgw48-mt-1_55.a /C/Users/gbg/Desktop/msys/1.0/local/lib/libboost_random-mgw48-mt-1_55.a                                        
+/C/Users/gbg/Desktop/msys/1.0/local/bin/libxml2-2.dll -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32                                                                                                                               

../../../libmlpack.a(lrsdp_function.cpp.obj):lrsdp_function.cpp:(.text+0x6e0): multiple definition of `mlpack::optimization::AugLagrangianFunction<mlpack::optimization::LRSDPFunction>::Evaluate(arma::Mat<double> const&) const'                                                    

../../../libmlpack.a(lrsdp.cpp.obj):lrsdp.cpp:(.text$_ZNK6mlpack12optimization21AugLagrangianFunctionINS0_13LRSDPFunctionEE8EvaluateERKN4arma3MatIdEE[first defined here      

../../../libmlpack.a(lrsdp_function.cpp.obj):lrsdp_function.cpp:(.text+0xf00): multiple definition of `mlpack::optimization::AugLagrangianFunction<mlpack::optimization::LRSDPFunction>::Gradient(arma::Mat<double> const&, arma::Mat<double>&) const'                                

../../../libmlpack.a(lrsdp.cpp.obj):lrsdp.cpp:(.text$_ZNK6mlpack12optimization21AugLagrangianFunctionINS0_13LRSDPFunctionEE8GradientERKN4arma3MatIdEERS6_[_ZNK6mlpack12optimization21AugLagrangianFunctionINS0_13LRSDPFunctionEE8GradientERKN4arma3MatIdEERS6_](_ZNK6mlpack12optimization21AugLagrangianFunctionINS0_13LRSDPFunctionEE8EvaluateERKN4arma3MatIdEE]+0x0):)+0x0): first defined   
+here                                                                                                                                                                                                                                                                                 

CMakeFiles/mlpack_test.dir/objects.a(mlpack_test.cpp.obj):mlpack_test.cpp:(.text+0x3): undefined reference to `__imp__ZTVN5boost9unit_test13test_observerE'                                                                                                                           
CMakeFiles/mlpack_test.dir/objects.a(mlpack_test.cpp.obj):mlpack_test.cpp:(.text+0xc1): undefined reference to `__imp__ZN5boost9unit_test9framework17master_test_suiteEv'                                                                                                             
c:/tdm-gcc-64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/mlpack_test.dir/objects.a(mlpack_test.cpp.obj): bad reloc address 0x0 in section `.pdata$_ZN5boost9unit_test13test_observer10test_startEm'

Here is my best guess:

There is a template specialization of AugLagrangianFunction in lrsdp_function.cpp; however, this specialization is not explicitly declared in any header file. So I would not be surprised if MinGW comes across a compilation unit that does not have lrsdp_function.cpp in it, says "ok, I need to instantiate AugLagrangianFunction" without knowing about the template specializations, and then at linker time there are multiple versions.

Thus the fix is probably to explicitly declare the template specialization in lrsdp_function.hpp, or something like that.

However, I haven't seen this bug on gcc or clang. Before just guessing at the solution, it should be reproduced and tested that this idea fixes the problem. This also doesn't address the second set of errors in that output, which appears to be a failure to link against the Boost Unit Test Framework.

The Windows slaves should be set up at some point to reproduce this type of build and test on MinGW...

Migrated-From: http://trac.research.cc.gatech.edu/fastlab/ticket/360

@rcurtin rcurtin self-assigned this Dec 29, 2014
@rcurtin rcurtin added this to the mlpack 1.1.0 milestone Dec 29, 2014
@rcurtin rcurtin removed their assignment Dec 30, 2014
ShangtongZhang pushed a commit to ShangtongZhang/mlpack that referenced this issue Mar 11, 2015
@rcurtin
Copy link
Member Author

rcurtin commented Dec 15, 2015

We have some number of MinGW users now and I haven't heard anything, so I'm going to resolve this as inactive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant