[mlpack-svn] [MLPACK] #360: multiple definition of AugLagrangianFunction overload with MinGW
MLPACK Trac
trac at coffeetalk-1.cc.gatech.edu
Wed Aug 13 12:49:02 EDT 2014
#360: multiple definition of AugLagrangianFunction overload with MinGW
---------------------+------------------------------------------------------
Reporter: rcurtin | Owner:
Type: defect | Status: new
Priority: minor | Milestone: mlpack 1.1.0
Component: mlpack | Keywords: lrsdp, auglagrangian, template specialization, mingw, msys
Blocking: | Blocked By:
---------------------+------------------------------------------------------
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[_ZNK6mlpack12optimization21AugLagrangianFunctionINS0_13LRSDPFunctionEE8EvaluateERKN4arma3MatIdEE]+0x0):
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_]+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<LRSDPFunction>
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<LRSDPFunction>"
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...
--
Ticket URL: <http://trac.research.cc.gatech.edu/fastlab/ticket/360>
MLPACK <www.fast-lab.org>
MLPACK is an intuitive, fast, and scalable C++ machine learning library developed at Georgia Tech.
More information about the mlpack-svn
mailing list