borglab / gtsam

GTSAM is a library of C++ classes that implement smoothing and mapping (SAM) in robotics and vision, using factor graphs and Bayes networks as the underlying computing paradigm rather than sparse matrices.
http://gtsam.org
Other
2.63k stars 769 forks source link

Cannot build matlab toolbox on Windows due to to unresolved external symbol error #496

Open fpczk opened 4 years ago

fpczk commented 4 years ago

Description

On Windows 10 / Visual Studio 2015, I cannot build the matlab toolbox. It always fails with the following errors:

ShonanAveragingCLI.obj : error LNK2019: unresolved external symbol "public: __cdecl gtsam::ShonanAveraging2::ShonanAveraging2(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct gtsam::ShonanAveragingParameters<2> const &)" (??0ShonanAveraging2@gtsam@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBU?$ShonanAveragingParameters@$01@1@@Z) referenced in function main
ShonanAveragingCLI.obj : error LNK2019: unresolved external symbol "public: __cdecl gtsam::ShonanAveraging3::ShonanAveraging3(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct gtsam::ShonanAveragingParameters<3> const &)" (??0ShonanAveraging3@gtsam@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBU?$ShonanAveragingParameters@$02@1@@Z) referenced in function main
...
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "public: class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::SO<-1>::vec(class gtsam::OptionalJacobian<-1,-1>)const " (?vec@?$SO@$0?0@gtsam@@QEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@V?$OptionalJacobian@$0?0$0?0@2@@Z) referenced in function "void __cdecl gtsamSOn_vec_303(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamSOn_vec_303@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl gtsam::ShonanAveraging2::ShonanAveraging2(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct gtsam::ShonanAveragingParameters<2> const &)" (??0ShonanAveraging2@gtsam@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBU?$ShonanAveragingParameters@$01@1@@Z) referenced in function "void __cdecl gtsamShonanAveraging2_constructor_2009(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamShonanAveraging2_constructor_2009@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl gtsam::ShonanAveraging3::ShonanAveraging3(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct gtsam::ShonanAveragingParameters<3> const &)" (??0ShonanAveraging3@gtsam@@QEAA@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBU?$ShonanAveragingParameters@$02@1@@Z) referenced in function "void __cdecl gtsamShonanAveraging3_constructor_2036(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamShonanAveraging3_constructor_2036@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl gtsam::ShonanAveraging3::ShonanAveraging3(class std::vector<class boost::shared_ptr<class gtsam::BetweenFactor<class gtsam::Pose3> >,class std::allocator<class boost::shared_ptr<class gtsam::BetweenFactor<class gtsam::Pose3> > > > const &,struct gtsam::ShonanAveragingParameters<3> const &)" (??0ShonanAveraging3@gtsam@@QEAA@AEBV?$vector@V?$shared_ptr@V?$BetweenFactor@VPose3@gtsam@@@gtsam@@@boost@@V?$allocator@V?$shared_ptr@V?$BetweenFactor@VPose3@gtsam@@@gtsam@@@boost@@@std@@@std@@AEBU?$ShonanAveragingParameters@$02@1@@Z) referenced in function "void __cdecl gtsamShonanAveraging3_constructor_2038(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamShonanAveraging3_constructor_2038@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(void)" (__imp_??0?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEAA@XZ) referenced in function "public: __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::BetweenFactor<class gtsam::SO<4> >(void)" (??0?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@QEAA@XZ)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(class boost::shared_ptr<class gtsam::noiseModel::Base> const &,unsigned __int64,unsigned __int64)" (__imp_??0?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEAA@AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@_K1@Z) referenced in function "void __cdecl gtsamBetweenFactorSO4_constructor_1729(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamBetweenFactorSO4_constructor_1729@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::~NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(void)" (__imp_??1?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@UEAA@XZ) referenced in function "public: virtual __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::~BetweenFactor<class gtsam::SO<4> >(void)" (??1?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEAA@XZ)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned __int64 __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::key1(void)const " (__imp_?key1@?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEBA_KXZ) referenced in function "public: virtual void __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned __int64 __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::key2(void)const " (__imp_?key2@?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEBA_KXZ) referenced in function "public: virtual void __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(class gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> > const &)" (__imp_??0?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEAA@AEBV01@@Z) referenced in function "public: __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::BetweenFactor<class gtsam::SO<4> >(class gtsam::BetweenFactor<class gtsam::SO<4> > const &)" (??0?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@QEAA@AEBV01@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::FrobeniusFactor<class gtsam::SO<3> >::FrobeniusFactor<class gtsam::SO<3> >(unsigned __int64,unsigned __int64,class boost::shared_ptr<class gtsam::noiseModel::Base> const &)" (__imp_??0?$FrobeniusFactor@V?$SO@$02@gtsam@@@gtsam@@QEAA@_K0AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@@Z) referenced in function "void __cdecl gtsamFrobeniusFactorSO3_constructor_1950(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamFrobeniusFactorSO3_constructor_1950@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::FrobeniusFactor<class gtsam::SO<3> >::~FrobeniusFactor<class gtsam::SO<3> >(void)" (__imp_??1?$FrobeniusFactor@V?$SO@$02@gtsam@@@gtsam@@UEAA@XZ) referenced in function "public: virtual void * __cdecl gtsam::FrobeniusFactor<class gtsam::SO<3> >::`scalar deleting destructor'(unsigned int)" (??_G?$FrobeniusFactor@V?$SO@$02@gtsam@@@gtsam@@UEAAPEAXI@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::FrobeniusFactor<class gtsam::SO<4> >::FrobeniusFactor<class gtsam::SO<4> >(unsigned __int64,unsigned __int64,class boost::shared_ptr<class gtsam::noiseModel::Base> const &)" (__imp_??0?$FrobeniusFactor@V?$SO@$03@gtsam@@@gtsam@@QEAA@_K0AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@@Z) referenced in function "void __cdecl gtsamFrobeniusFactorSO4_constructor_1956(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamFrobeniusFactorSO4_constructor_1956@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::FrobeniusFactor<class gtsam::SO<4> >::~FrobeniusFactor<class gtsam::SO<4> >(void)" (__imp_??1?$FrobeniusFactor@V?$SO@$03@gtsam@@@gtsam@@UEAA@XZ) referenced in function "public: virtual void * __cdecl gtsam::FrobeniusFactor<class gtsam::SO<4> >::`scalar deleting destructor'(unsigned int)" (??_G?$FrobeniusFactor@V?$SO@$03@gtsam@@@gtsam@@UEAAPEAXI@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::FrobeniusBetweenFactor<class gtsam::SO<4> >(unsigned __int64,unsigned __int64,class gtsam::SO<4> const &,class boost::shared_ptr<class gtsam::noiseModel::Base> const &)" (__imp_??0?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@QEAA@_K0AEBV?$SO@$03@1@AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@@Z) referenced in function "void __cdecl gtsamFrobeniusBetweenFactorSO4_constructor_1968(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamFrobeniusBetweenFactorSO4_constructor_1968@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::~FrobeniusBetweenFactor<class gtsam::SO<4> >(void)" (__imp_??1?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEAA@XZ) referenced in function "public: virtual void * __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::`scalar deleting destructor'(unsigned int)" (??_G?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEAAPEAXI@Z)
gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::equals(class gtsam::NonlinearFactor const &,double)const " (?equals@?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBA_NAEBVNonlinearFactor@2@N@Z)
gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::evaluateError(class gtsam::SO<4> const &,class gtsam::SO<4> const &,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>)const " (?evaluateError@?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBV?$SO@$03@2@0V?$optional@AEAV?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@boost@@1@Z)
gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::FrobeniusFactor<class gtsam::SO<3> >::evaluateError(class gtsam::SO<3> const &,class gtsam::SO<3> const &,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>)const " (?evaluateError@?$FrobeniusFactor@V?$SO@$02@gtsam@@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBV?$SO@$02@2@0V?$optional@AEAV?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@boost@@1@Z)
63>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::FrobeniusFactor<class gtsam::SO<4> >::evaluateError(class gtsam::SO<4> const &,class gtsam::SO<4> const &,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>)const " (?evaluateError@?$FrobeniusFactor@V?$SO@$03@gtsam@@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBV?$SO@$03@2@0V?$optional@AEAV?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@boost@@1@Z)
gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::unwhitenedError(class gtsam::Values const &,class boost::optional<class std::vector<class Eigen::Matrix<double,-1,-1,0,-1,-1>,class std::allocator<class Eigen::Matrix<double,-1,-1,0,-1,-1> > > &>)const " (?unwhitenedError@?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBVValues@2@V?$optional@AEAV?$vector@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@V?$allocator@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@std@@@std@@@boost@@@Z)
C:\Users\XYZ\working\gtsam\gtsam\build\gtsam\wrap\gtsam_mex\Release\gtsam_wrapper.mexw64 : fatal error LNK1120: 22 unresolved externals

Steps to reproduce

  1. Install cmake and pyparsing via Anaconda:
    • conda install cmake pyparsing
  2. Install boost:
    • Download and extract boost_1_73_0.7z from https://www.boost.org/users/history/version_1_73_0.html
    • cd into boost root
    • bootstrap.bat
    • b2 -j8 toolset=msvc-14.0 address-model=64 link=static threading=multi runtime-link=shared --build-type=complete stage
    • copy lib files from stage\lib to lib\x64
  3. Try to build gtsam:
    • git clone https://github.com/borglab/gtsam.git; cd gtsam
    • mkdir build; cd build
    • Add line to CMakelists.txt in gtsam root folder: set(BOOST_ROOT C:/Users/XYZ/Downloads/boost_1_73_0)
    • cmake .. -G "Visual Studio 14 Win64" -T host=x64 -DCMAKE_INSTALL_PREFIX:PATH=C:/Users/XYZ/working/gtsam/gtsam_install -DGTSAM_TOOLBOX_INSTALL_PATH:PATH=C:/Users/XYZ/working/gtsam/gtsam_toolbox_install -DGTSAM_INSTALL_MATLAB_TOOLBOX:OPTION=ON -DCMAKE_BUILD_TYPE=Release -DMEX_COMMAND:PATH="C:/Program Files/MATLAB/R2019b/bin/mex"
    • Open GTSAM.sln in VS 2015, and build the INSTALL project in Release, x64

Expected behavior

GTSAM and the Matlba toolbox should get built without error and I should find the toolbox in C:/Users/XYZ/working/gtsam/gtsam_toolbox_install.

Environment

commit 39aeae657e31848d4b546f3f4c95469427508cbe (HEAD -> develop, origin/develop, origin/HEAD)
Merge: 144db8e11 8c6082eb6
Author: Frank Dellaert <dellaert@users.noreply.github.com>
Date:   Tue Aug 25 15:23:30 2020 -0400

    Merge pull request #494 from borglab/fix/linting

    Linting and getAnchor wrap

Here is my Conda package list, including cmake and pyparsing:

(gtsam) C:\Users\XYZ\working\gtsam\gtsam\build>conda list
# packages in environment at C:\Users\XYZ\miniconda3\envs\gtsam:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl    anaconda
boost                     1.67.0                   py36_4    anaconda
boost-cpp                 1.67.0               hfa6e2cd_4    anaconda
certifi                   2020.6.20                py36_0    anaconda
cmake                     3.18.0               h33f27b4_0    conda-forge
intel-openmp              2020.1                      216    anaconda
libboost                  1.67.0               hfd51bdf_4    anaconda
mkl                       2019.4                      245    anaconda
mkl-service               2.3.0            py36hb782905_0    anaconda
mkl_fft                   1.1.0            py36h45dec08_0    anaconda
mkl_random                1.1.0            py36h675688f_0    anaconda
numpy                     1.19.1           py36h5510c5b_0    anaconda
numpy-base                1.19.1           py36ha3acd2a_0    anaconda
pip                       20.2.2                   py36_0    anaconda
py-boost                  1.67.0           py36h8300f20_4    anaconda
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
python                    3.6.10               h9f7ef89_2    anaconda
setuptools                49.6.0                   py36_0    anaconda
six                       1.15.0                     py_0    anaconda
sqlite                    3.33.0               h2a8f88b_0    anaconda
vc                        14.1                 h0510ff6_4    anaconda
vs2015_runtime            14.16.27012          hf0eaf9b_3    anaconda
wheel                     0.34.2                   py36_0    anaconda
wincertstore              0.2              py36h7fe50ca_0    anaconda
xz                        5.2.5                h62dcd97_0    anaconda
zlib                      1.2.11           vc14h1cdd9ab_1  [vc14]  anaconda

Additional information

Here are the full build logs from CMake and Visual Studio:

fpczk commented 4 years ago

The following change apparently solves the first 2 errors, while the other ones remain:

diff --git a/gtsam/sfm/ShonanAveraging.h b/gtsam/sfm/ShonanAveraging.h
index edd9f33a2..8f52b920b 100644
--- a/gtsam/sfm/ShonanAveraging.h
+++ b/gtsam/sfm/ShonanAveraging.h
@@ -350,7 +350,7 @@ class GTSAM_EXPORT ShonanAveraging {
 // Subclasses for d=2 and d=3 that explicitly instantiate, as well as provide a
 // convenience interface with file access.

-class ShonanAveraging2 : public ShonanAveraging<2> {
+class GTSAM_EXPORT ShonanAveraging2 : public ShonanAveraging<2> {
  public:
   ShonanAveraging2(const Measurements &measurements,
                    const Parameters &parameters = Parameters());
@@ -358,7 +358,7 @@ class ShonanAveraging2 : public ShonanAveraging<2> {
                             const Parameters &parameters = Parameters());
 };

-class ShonanAveraging3 : public ShonanAveraging<3> {
+class GTSAM_EXPORT ShonanAveraging3 : public ShonanAveraging<3> {
  public:
   ShonanAveraging3(const Measurements &measurements,
                    const Parameters &parameters = Parameters());

Build log: https://pastebin.com/raw/AqgCZaT6

I also noticed that I still hat boost installed in Anaconda, additionally. I removed it, but the build still fails before.

dellaert commented 4 years ago

Thanks! I'm not a windows user, but I created a branch fix/windows_warnings just now. Hoping the export in SOn.h fixes the other errors. Give it a try and share build log? Alternatively - if it does not work yet - maybe you could fork and add a few more GTSAM_EXPORT directives to try and fix? Adding @mikesheffler to this thread as he has more insight into this, usually :-)

dellaert commented 4 years ago

As an aside: if you don't need Shonan or new python wrapper, you can check out our stable release 4.0.3 instead. Develop is a bit bleeding edge now.

fpczk commented 4 years ago

Thank you for your reply! Unfortunately, those changes caused new errors that look like the following:

4>C:\Users\XYZ\working\gtsam\gtsam\gtsam/geometry/SOn.h(362): error C2908: explicit specialization; 'gtsam::SO<-1> gtsam::LieGroup<gtsam::SO<-1>,-1>::compose(const Class &,gtsam::OptionalJacobian<-1,-1>,gtsam::OptionalJacobian<-1,-1>) const' has already been instantiated
4>          with
4>          [
4>              Class=gtsam::SO<-1>
4>          ] (compiling source file C:\Users\XYZ\working\gtsam\gtsam\gtsam\geometry\CalibratedCamera.cpp)

Here is the full log: https://pastebin.com/raw/zfhABibg

As for stable release 4.0.3: I was able to compile it on Windows, but I'm particularly interested in the IMUKittiExampleGPS for Matlab, and that doesn't work in release 4.0.3 due to a type mismatch error (at least on Windows, I couldn't test it yet under Linux). On linux, I was able to compile the current develop branch, and the Matlab example worked, so I assume that the type mismatch bug was fixed after release 4.0.3, though technically I cannot rule out the possibility that the bug could still exist and is just Windows-specific. Eventually I'll need to run the code on Windows.

mikesheffler commented 4 years ago

Thanks! I'm not a windows user, but I created a branch fix/windows_warnings just now. Hoping the export in SOn.h fixes the other errors. Give it a try and share build log? Alternatively - if it does not work yet - maybe you could fork and add a few more GTSAM_EXPORT directives to try and fix? Adding @mikesheffler to this thread as he has more insight into this, usually :-)

I haven't tried to build develop since the release candidate; I'll try to build it today and see what sort of fireworks I encounter.

ProfFan commented 4 years ago

@fpapi83 If you are talking about the MATLAB example in unstable, yes I fixed it in develop.

xdtl commented 4 years ago

I cannot build matlab toolbox on Windows either. I got all the interfaces files and "gtsam_unstable_wrapper.mexw64", but cannot generate "gtsam_wrapper.mexw64". I am on Windows 10, Visual Studio Professional 2019, CMake 3.17 and Boost 1.73.0. Thanks!


70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >(void)" (__imp_??0?$NoiseModelFactor2@V?$SO@$02@gtsam@@V12@@gtsam@@QEAA@XZ) referenced in function "void __cdecl gtsamBetweenFactorSO3_string_deserialize_2283(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamBetweenFactorSO3_string_deserialize_2283@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >(class boost::shared_ptr<class gtsam::noiseModel::Base> const &,unsigned __int64,unsigned __int64)" (__imp_??0?$NoiseModelFactor2@V?$SO@$02@gtsam@@V12@@gtsam@@QEAA@AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@_K1@Z) referenced in function "public: __cdecl gtsam::FrobeniusFactor<class gtsam::SO<3> >::FrobeniusFactor<class gtsam::SO<3> >(unsigned __int64,unsigned __int64,class boost::shared_ptr<class gtsam::noiseModel::Base> const &)" (??0?$FrobeniusFactor@V?$SO@$02@gtsam@@@gtsam@@QEAA@_K0AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >::~NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >(void)" (__imp_??1?$NoiseModelFactor2@V?$SO@$02@gtsam@@V12@@gtsam@@UEAA@XZ) referenced in function "public: virtual __cdecl gtsam::BetweenFactor<class gtsam::SO<3> >::~BetweenFactor<class gtsam::SO<3> >(void)" (??1?$BetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEAA@XZ)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned __int64 __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >::key1(void)const " (__imp_?key1@?$NoiseModelFactor2@V?$SO@$02@gtsam@@V12@@gtsam@@QEBA_KXZ) referenced in function "public: virtual void __cdecl gtsam::BetweenFactor<class gtsam::SO<3> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$BetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned __int64 __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >::key2(void)const " (__imp_?key2@?$NoiseModelFactor2@V?$SO@$02@gtsam@@V12@@gtsam@@QEBA_KXZ) referenced in function "public: virtual void __cdecl gtsam::BetweenFactor<class gtsam::SO<3> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$BetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >(class gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> > const &)" (__imp_??0?$NoiseModelFactor2@V?$SO@$02@gtsam@@V12@@gtsam@@QEAA@AEBV01@@Z) referenced in function "public: virtual class boost::shared_ptr<class gtsam::NonlinearFactor> __cdecl gtsam::BetweenFactor<class gtsam::SO<3> >::clone(void)const " (?clone@?$BetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEBA?AV?$shared_ptr@VNonlinearFactor@gtsam@@@boost@@XZ)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(void)" (__imp_??0?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEAA@XZ) referenced in function "public: __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::BetweenFactor<class gtsam::SO<4> >(void)" (??0?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@QEAA@XZ)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(class boost::shared_ptr<class gtsam::noiseModel::Base> const &,unsigned __int64,unsigned __int64)" (__imp_??0?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEAA@AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@_K1@Z) referenced in function "public: __cdecl gtsam::FrobeniusFactor<class gtsam::SO<4> >::FrobeniusFactor<class gtsam::SO<4> >(unsigned __int64,unsigned __int64,class boost::shared_ptr<class gtsam::noiseModel::Base> const &)" (??0?$FrobeniusFactor@V?$SO@$03@gtsam@@@gtsam@@QEAA@_K0AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::~NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(void)" (__imp_??1?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@UEAA@XZ) referenced in function "public: virtual __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::~BetweenFactor<class gtsam::SO<4> >(void)" (??1?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEAA@XZ)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned __int64 __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::key1(void)const " (__imp_?key1@?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEBA_KXZ) referenced in function "public: virtual void __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned __int64 __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::key2(void)const " (__imp_?key2@?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEBA_KXZ) referenced in function "public: virtual void __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >(class gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> > const &)" (__imp_??0?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@QEAA@AEBV01@@Z) referenced in function "public: virtual class boost::shared_ptr<class gtsam::NonlinearFactor> __cdecl gtsam::BetweenFactor<class gtsam::SO<4> >::clone(void)const " (?clone@?$BetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBA?AV?$shared_ptr@VNonlinearFactor@gtsam@@@boost@@XZ)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<3> >::FrobeniusBetweenFactor<class gtsam::SO<3> >(unsigned __int64,unsigned __int64,class gtsam::SO<3> const &,class boost::shared_ptr<class gtsam::noiseModel::Base> const &)" (__imp_??0?$FrobeniusBetweenFactor@V?$SO@$02@gtsam@@@gtsam@@QEAA@_K0AEBV?$SO@$02@1@AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@@Z) referenced in function "void __cdecl gtsamFrobeniusBetweenFactorSO3_constructor_2905(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamFrobeniusBetweenFactorSO3_constructor_2905@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<3> >::~FrobeniusBetweenFactor<class gtsam::SO<3> >(void)" (__imp_??1?$FrobeniusBetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEAA@XZ) referenced in function "public: virtual void * __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<3> >::`scalar deleting destructor'(unsigned int)" (??_G?$FrobeniusBetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEAAPEAXI@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::FrobeniusBetweenFactor<class gtsam::SO<4> >(unsigned __int64,unsigned __int64,class gtsam::SO<4> const &,class boost::shared_ptr<class gtsam::noiseModel::Base> const &)" (__imp_??0?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@QEAA@_K0AEBV?$SO@$03@1@AEBV?$shared_ptr@VBase@noiseModel@gtsam@@@boost@@@Z) referenced in function "void __cdecl gtsamFrobeniusBetweenFactorSO4_constructor_2924(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamFrobeniusBetweenFactorSO4_constructor_2924@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)
70>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::~FrobeniusBetweenFactor<class gtsam::SO<4> >(void)" (__imp_??1?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEAA@XZ) referenced in function "public: virtual void * __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::`scalar deleting destructor'(unsigned int)" (??_G?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEAAPEAXI@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<3> >::equals(class gtsam::NonlinearFactor const &,double)const " (?equals@?$FrobeniusBetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEBA_NAEBVNonlinearFactor@2@N@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::equals(class gtsam::NonlinearFactor const &,double)const " (?equals@?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBA_NAEBVNonlinearFactor@2@N@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<3> >::evaluateError(class gtsam::SO<3> const &,class gtsam::SO<3> const &,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>)const " (?evaluateError@?$FrobeniusBetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBV?$SO@$02@2@0V?$optional@AEAV?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@boost@@1@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::evaluateError(class gtsam::SO<4> const &,class gtsam::SO<4> const &,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>,class boost::optional<class Eigen::Matrix<double,-1,-1,0,-1,-1> &>)const " (?evaluateError@?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBV?$SO@$03@2@0V?$optional@AEAV?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@boost@@1@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<3> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$FrobeniusBetweenFactor@V?$SO@$02@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl gtsam::FrobeniusBetweenFactor<class gtsam::SO<4> >::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@?$FrobeniusBetweenFactor@V?$SO@$03@gtsam@@@gtsam@@UEBAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV?$function@$$A6A?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@_K@Z@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<3>,class gtsam::SO<3> >::unwhitenedError(class gtsam::Values const &,class boost::optional<class std::vector<class Eigen::Matrix<double,-1,-1,0,-1,-1>,class std::allocator<class Eigen::Matrix<double,-1,-1,0,-1,-1> > > &>)const " (?unwhitenedError@?$NoiseModelFactor2@V?$SO@$02@gtsam@@V12@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBVValues@2@V?$optional@AEAV?$vector@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@V?$allocator@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@std@@@std@@@boost@@@Z)
70>gtsam_wrapper.obj : error LNK2001: unresolved external symbol "public: virtual class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::NoiseModelFactor2<class gtsam::SO<4>,class gtsam::SO<4> >::unwhitenedError(class gtsam::Values const &,class boost::optional<class std::vector<class Eigen::Matrix<double,-1,-1,0,-1,-1>,class std::allocator<class Eigen::Matrix<double,-1,-1,0,-1,-1> > > &>)const " (?unwhitenedError@?$NoiseModelFactor2@V?$SO@$03@gtsam@@V12@@gtsam@@UEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBVValues@2@V?$optional@AEAV?$vector@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@V?$allocator@V?$Matrix@N$0?0$0?0$0A@$0?0$0?0@Eigen@@@std@@@std@@@boost@@@Z)
70>...\gtsam\build\gtsam\wrap\gtsam_mex\Release\gtsam_wrapper.mexw64 : fatal error LNK1120: 24 unresolved externals
70>Done building project "gtsam_matlab_wrapper.vcxproj" -- FAILED.
'''
mikesheffler commented 4 years ago

Hmm. Poaching the two GTSAM_EXPORT changes, I get slightly different errors than @fpczk , but I'd wager they're of the same root. My first error is

1>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "public: class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::SO<-1>::vec(class gtsam::OptionalJacobian<-1,-1>)const " (?vec@?$SO@$0?0@gtsam@@QEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@V?$OptionalJacobian@$0?0$0?0@2@@Z) referenced in function "void __cdecl gtsamSOn_vec_303(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamSOn_vec_303@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)

On my line 281

using LieGroup<SO<N>, internal::DimensionSO(N)>::inverse;

there is a LINT notice, invalid base class detected during instantiation of class "gtsam::SO<N> [with N=-1]" at line 144, which is

return SO(SO<Eigen::Dynamic>::Random(rng, N).matrix());

BUT, that's part of this block:

  /// Random SO(N) element (no big claims about uniformity)
  template <int N_ = N, typename = IsFixed<N_>>
  static SO Random(std::mt19937& rng) {
    // By default, use dynamic implementation above. Specialized for SO(3).
    return SO(SO<Eigen::Dynamic>::Random(rng, N).matrix());
  }

looking at the definition for IsFixed, I don't think that code should be evaluated when N is equal to -1. I don't know exactly where the LINT message is coming from, but the error in my build at the top also seems to suggest that MSVC is attempting to instantiate an instance of the class with size -1 and not finding the definition.

If I had to guess, I would say that something about finding the dynamic constructor (maybe even as simple as identifying static vs. dynamic) is not working correctly in MSVC. Why that is ... I don't know. In testSOn.cpp, I see some construction tests, but not with N equal to -1. Is the wrap the only place that is happening (i.e. can Windows not currently handle the SOn code, and we're only noticing when compiling the wrap, or is the wrap generating code to be compiled that doesn't make sense)?

dellaert commented 4 years ago

Hmm. What happens if you explicitly say, to force the compiler's hand?

    return SO<N>(SO<Eigen::Dynamic>::Random(rng, N).matrix());
mikesheffler commented 4 years ago
1>gtsam_wrapper.obj : error LNK2019: unresolved external symbol "public: class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::SO<-1>::vec(class gtsam::OptionalJacobian<-1,-1>)const " (?vec@?$SO@$0?0@gtsam@@QEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@V?$OptionalJacobian@$0?0$0?0@2@@Z) referenced in function "void __cdecl gtsamSOn_vec_303(int,struct mxArray_tag * * const,int,struct mxArray_tag const * * const)" (?gtsamSOn_vec_303@@YAXHQEAPEAUmxArray_tag@@HQEAPEBU1@@Z)

I think it's the same error 🤕