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

Fix MSVC / Windows Build of GTSAM_UNSTABLE #1102

Conversation

mikesheffler
Copy link
Contributor

Per https://github.com/borglab/gtsam/blob/develop/Using-GTSAM-EXPORT.md , classes with no methods defined in a .cpp file shouldn't have the GTSAM_EXPORT or GTSAM_UNSTABLE_EXPORT modifier. This was causing problems with the building of gtsam_unstable on MSVC / Windows.

What I don't like about this PR is that it is reverses several changes @varunagrawal made in #904. I think that the way it is done in this PR is probably correct, but I think @varunagrawal should weigh in, just in case I'm missing something.

This is in service of #1087, but it isn't a resolution, since that issue is about MATLAB. I started this little cul-de-sac as a waypoint on the way to examining the MATLAB build, and I'll take a look at that soon.

Two requests from @dellaert are ignored here:

  1. Silence some / all of the C4834 warnings about ignored returns from [[nodiscard]] functions: Doing this file-by-file with #pragma warning(disable : 4834) resulted in, I think, 85 files with changes. I made a patch of that change just in case we do want it, but I thought that changing that many files was probably a sign it was not the right approach.

  2. Add more actions to the Windows CI: There are six targets in .github/workflows/build-windows.yml:

          cmake --build build -j 4 --config ${{ matrix.build_type }} --target gtsam
          cmake --build build -j 4 --config ${{ matrix.build_type }} --target gtsam_unstable
          cmake --build build -j 4 --config ${{ matrix.build_type }} --target wrap
          cmake --build build -j 4 --config ${{ matrix.build_type }} --target check.base
          cmake --build build -j 4 --config ${{ matrix.build_type }} --target check.base_unstable
          cmake --build build -j 4 --config ${{ matrix.build_type }} --target check.linear

and it turns out that that is all of the the checks that will pass right now. I can modify the list to include more targets, but they will fail. I haven't tried to look at them and see why they're failing.

… , classes with no methods defined in a .cpp file shouldn't have the GTSAM_EXPORT or GTSAM_UNSTABLE_EXPORT modifier. This was causing problems with the building of gtsam_unstable on MSVC / Windows.
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!
@varunagrawal please approve and you merge if you think it's OK. It does follow the guidelines in that markdown file.

@dellaert
Copy link
Member

PS, could you paste the errors for discrete? We can maybe tackle one at a time?

@mikesheffler
Copy link
Contributor Author

Oh, huh. I guess I don't get email for stuff posted here? Anyway, here's the output for building check.discrete

Build started...
1>------ Build started: Project: check_discrete_program, Configuration: Debug x64 ------
1>testAlgebraicDecisionTree.cpp
1>C:\Mike\Work\Source\gtsam-msheffler\gtsam/discrete/AlgebraicDecisionTree.h(130,27): error C2059: syntax error: 'template'
1>C:\Mike\Work\Source\gtsam-msheffler\gtsam\discrete\tests\testAlgebraicDecisionTree.cpp(495): message : see reference to function template instantiation 'gtsam::AlgebraicDecisionTree<gtsam::Key>::AlgebraicDecisionTree<gtsam::Key>(const gtsam::AlgebraicDecisionTree<gtsam::Key> &,const std::map<gtsam::Key,size_t,std::less<boost::ulong_long_type>,std::allocator<std::pair<const gtsam::Key,size_t>>> &)' being compiled
1>C:\Mike\Work\Source\gtsam-msheffler\gtsam\discrete\tests\testAlgebraicDecisionTree.cpp(495): message : see reference to function template instantiation 'gtsam::AlgebraicDecisionTree<gtsam::Key>::AlgebraicDecisionTree<gtsam::Key>(const gtsam::AlgebraicDecisionTree<gtsam::Key> &,const std::map<gtsam::Key,size_t,std::less<boost::ulong_long_type>,std::allocator<std::pair<const gtsam::Key,size_t>>> &)' being compiled
1>Done building project "check_discrete_program.vcxproj" -- FAILED.
2>------ Build started: Project: check.discrete, Configuration: Debug x64 ------
2>Test project C:/Mike/Work/Build/gtsam-msheffler/gtsam/discrete/tests
2>    Start 1: check_discrete_program
2>Could not find executable C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>Looked in the following places:
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe.exe
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/Debug/check_discrete_program.exe
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/Debug/check_discrete_program.exe.exe
2>Debug/C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>Debug/C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe.exe
2>Unable to find executable: C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>1/1 Test #1: check_discrete_program ...........***Not Run   0.00 sec
2>
2>0% tests passed, 1 tests failed out of 1
2>
2>Total Test time (real) =   0.01 sec
2>
2>The following tests FAILED:
2>	  1 - check_discrete_program (Not Run)
2>Errors while running CTest
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\Mike\Work\Build\gtsam-msheffler\CMakeFiles\64503014783bb89b4fb2b45506e598c8\check.discrete.rule' exited with code 8.
2>Done building project "check.discrete.vcxproj" -- FAILED.
========== Build: 0 succeeded, 2 failed, 4 up-to-date, 0 skipped ==========

I can't really parse too much out of that, but here's the offending block:

    /**
     * Convert labels from type M to type L.
     *
     * @param other: The AlgebraicDecisionTree with label type M to convert.
     * @param map: Map from label type M to label type L.
     */
    template <typename M>
    AlgebraicDecisionTree(const AlgebraicDecisionTree<M>& other,
                          const std::map<M, L>& map) {
      // Functor for label conversion so we can use `convertFrom`.
      std::function<L(const M&)> L_of_M = [&map](const M& label) -> L {
        return map.at(label);
      };
      std::function<double(const double&)> op = Ring::id;
      this->root_ = this->template convertFrom(other.root_, L_of_M, op);
    }

I think the specific complaint has to do with this->template, which I'll admit to not understanding either.

@dellaert
Copy link
Member

I think the specific complaint has to do with this->template, which I'll admit to not understanding either.

Ha! A mere compile error :-) Seems compilers disagree. I tried locally with MacOS/clang and the following works as well:

      this->root_ =
          DecisionTree<L, double>::convertFrom(other.root_, L_of_M, op);

Maybe that will make discrete pass on MSVC?

@dellaert
Copy link
Member

Flabbergasted that so many targets fail even in gtsam. Let me know if you get tired of this, but we could play the same game for check.inference and check.inference, which are core to everything else. Maybe they have a (positive) ripple effect...

@mikesheffler
Copy link
Contributor Author

mikesheffler commented Feb 16, 2022

It does make it compile! Unfortunately, that means that there are now link errors, which might not be obvious. I haven't looked to see if these are easy or hard to resolve. If it were just things that had been left out of a list in CMake, I would expect problems on the Linux side as well, so it's probably something more 'fun' related to MSVC, specifically.

Build started...
1>------ Build started: Project: check_discrete_program, Configuration: Debug x64 ------
1>testDiscreteFactorGraph.obj : error LNK2005: "public: virtual void __cdecl DiscreteFactorGraphDotWithNamesTest::run(class TestResult &)" (?run@DiscreteFactorGraphDotWithNamesTest@@UEAAXAEAVTestResult@@@Z) already defined in testDecisionTreeFactor.obj
1>testDiscreteFactorGraph.obj : error LNK2005: "class DiscreteFactorGraphDotWithNamesTest DiscreteFactorGraphDotWithNamesInstance" (?DiscreteFactorGraphDotWithNamesInstance@@3VDiscreteFactorGraphDotWithNamesTest@@A) already defined in testDecisionTreeFactor.obj
1>testAlgebraicDecisionTree.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::DefaultFormatter(unsigned __int64 const &)" (__imp_?DefaultFormatter@?$AlgebraicDecisionTree@_K@gtsam@@CA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEB_K@Z) referenced in function "public: static void __cdecl gtsam::Testable<class gtsam::AlgebraicDecisionTree<unsigned __int64> >::Print(class gtsam::AlgebraicDecisionTree<unsigned __int64> const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Print@?$Testable@V?$AlgebraicDecisionTree@_K@gtsam@@@gtsam@@SAXAEBV?$AlgebraicDecisionTree@_K@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>testDiscreteBayesNet.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::DefaultFormatter(unsigned __int64 const &)" (__imp_?DefaultFormatter@?$AlgebraicDecisionTree@_K@gtsam@@CA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEB_K@Z)
1>testAlgebraicDecisionTree.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(struct std::pair<unsigned __int64,unsigned __int64> const &,double,double)" (__imp_??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBU?$pair@_K_K@std@@NN@Z) referenced in function "public: virtual void __cdecl ADTexample3Test::run(class TestResult &)" (?run@ADTexample3Test@@UEAAXAEAVTestResult@@@Z)
1>testDiscreteLookupDAG.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(struct std::pair<unsigned __int64,unsigned __int64> const &,double,double)" (__imp_??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBU?$pair@_K_K@std@@NN@Z)
1>  Hint on symbols that are defined and could potentially match:
1>    "__declspec(dllimport) public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(class gtsam::AlgebraicDecisionTree<unsigned __int64> &&)" (__imp_??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@$$QEAV01@@Z)
1>    "__declspec(dllimport) public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(class gtsam::AlgebraicDecisionTree<unsigned __int64> const &)" (__imp_??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBV01@@Z)
1>    "__declspec(dllimport) public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(class gtsam::DecisionTree<unsigned __int64,double> const &)" (__imp_??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBV?$DecisionTree@_KN@1@@Z)
1>    "__declspec(dllimport) public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(class std::vector<struct std::pair<unsigned __int64,unsigned __int64>,class std::allocator<struct std::pair<unsigned __int64,unsigned __int64> > > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBV?$vector@U?$pair@_K_K@std@@V?$allocator@U?$pair@_K_K@std@@@2@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@3@@Z)
1>    "__declspec(dllimport) public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(class std::vector<struct std::pair<unsigned __int64,unsigned __int64>,class std::allocator<struct std::pair<unsigned __int64,unsigned __int64> > > const &,class std::vector<double,class std::allocator<double> > const &)" (__imp_??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBV?$vector@U?$pair@_K_K@std@@V?$allocator@U?$pair@_K_K@std@@@2@@std@@AEBV?$vector@NV?$allocator@N@std@@@3@@Z)
1>testAlgebraicDecisionTree.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class gtsam::AlgebraicDecisionTree<unsigned __int64> __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::operator*(class gtsam::AlgebraicDecisionTree<unsigned __int64> const &)const " (__imp_??D?$AlgebraicDecisionTree@_K@gtsam@@QEBA?AV01@AEBV01@@Z) referenced in function "public: virtual void __cdecl ADTexample3Test::run(class TestResult &)" (?run@ADTexample3Test@@UEAAXAEAVTestResult@@@Z)
1>testAlgebraicDecisionTree.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class gtsam::AlgebraicDecisionTree<unsigned __int64> __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::operator/(class gtsam::AlgebraicDecisionTree<unsigned __int64> const &)const " (__imp_??K?$AlgebraicDecisionTree@_K@gtsam@@QEBA?AV01@AEBV01@@Z) referenced in function "public: virtual void __cdecl ADTeliminationTest::run(class TestResult &)" (?run@ADTeliminationTest@@UEAAXAEAVTestResult@@@Z)
1>testAlgebraicDecisionTree.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class gtsam::AlgebraicDecisionTree<unsigned __int64> __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::sum(struct std::pair<unsigned __int64,unsigned __int64> const &)const " (__imp_?sum@?$AlgebraicDecisionTree@_K@gtsam@@QEBA?AV12@AEBU?$pair@_K_K@std@@@Z) referenced in function "public: virtual void __cdecl ADTeliminationTest::run(class TestResult &)" (?run@ADTeliminationTest@@UEAAXAEAVTestResult@@@Z)
1>  Hint on symbols that are defined and could potentially match:
1>    "__declspec(dllimport) public: class boost::shared_ptr<class gtsam::DecisionTreeFactor> __cdecl gtsam::DecisionTreeFactor::sum(unsigned __int64)const " (__imp_?sum@DecisionTreeFactor@gtsam@@QEBA?AV?$shared_ptr@VDecisionTreeFactor@gtsam@@@boost@@_K@Z)
1>testDiscreteBayesNet.obj : error LNK2019: unresolved external symbol "public: void __cdecl gtsam::DiscreteValues::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@DiscreteValues@gtsam@@QEBAXAEBV?$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@4@@Z) referenced in function "public: static void __cdecl gtsam::Testable<class gtsam::DiscreteValues>::Print(class gtsam::DiscreteValues const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?Print@?$Testable@VDiscreteValues@gtsam@@@gtsam@@SAXAEBVDiscreteValues@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>testDiscreteFactorGraph.obj : error LNK2001: unresolved external symbol "public: void __cdecl gtsam::DiscreteValues::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@DiscreteValues@gtsam@@QEBAXAEBV?$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@4@@Z)
1>testDiscreteLookupDAG.obj : error LNK2001: unresolved external symbol "public: void __cdecl gtsam::DiscreteValues::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@DiscreteValues@gtsam@@QEBAXAEBV?$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@4@@Z)
1>testDiscreteBayesNet.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::DiscreteMarginals::DiscreteMarginals(class gtsam::DiscreteFactorGraph const &)" (__imp_??0DiscreteMarginals@gtsam@@QEAA@AEBVDiscreteFactorGraph@1@@Z) referenced in function "public: virtual void __cdecl DiscreteBayesNetbayesNetTest::run(class TestResult &)" (?run@DiscreteBayesNetbayesNetTest@@UEAAXAEAVTestResult@@@Z)
1>testDiscreteMarginals.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::DiscreteMarginals::DiscreteMarginals(class gtsam::DiscreteFactorGraph const &)" (__imp_??0DiscreteMarginals@gtsam@@QEAA@AEBVDiscreteFactorGraph@1@@Z)
1>testDiscreteBayesNet.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::DiscreteMarginals::marginalProbabilities(struct std::pair<unsigned __int64,unsigned __int64> const &)const " (__imp_?marginalProbabilities@DiscreteMarginals@gtsam@@QEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBU?$pair@_K_K@std@@@Z) referenced in function "public: virtual void __cdecl DiscreteBayesNetbayesNetTest::run(class TestResult &)" (?run@DiscreteBayesNetbayesNetTest@@UEAAXAEAVTestResult@@@Z)
1>testDiscreteMarginals.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: class Eigen::Matrix<double,-1,1,0,-1,1> __cdecl gtsam::DiscreteMarginals::marginalProbabilities(struct std::pair<unsigned __int64,unsigned __int64> const &)const " (__imp_?marginalProbabilities@DiscreteMarginals@gtsam@@QEBA?AV?$Matrix@N$0?0$00$0A@$0?0$00@Eigen@@AEBU?$pair@_K_K@std@@@Z)
1>testDiscreteBayesNet.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::DiscreteMarginals::~DiscreteMarginals(void)" (__imp_??1DiscreteMarginals@gtsam@@QEAA@XZ) referenced in function "public: virtual void __cdecl DiscreteBayesNetbayesNetTest::run(class TestResult &)" (?run@DiscreteBayesNetbayesNetTest@@UEAAXAEAVTestResult@@@Z)
1>testDiscreteMarginals.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl gtsam::DiscreteMarginals::~DiscreteMarginals(void)" (__imp_??1DiscreteMarginals@gtsam@@QEAA@XZ)
1>testDiscreteLookupDAG.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl gtsam::DiscreteLookupTable::print(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &)const " (?print@DiscreteLookupTable@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@4@@Z)
1>testDiscreteMarginals.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class boost::shared_ptr<class gtsam::DiscreteFactor> __cdecl gtsam::DiscreteMarginals::operator()(unsigned __int64)const " (__imp_??RDiscreteMarginals@gtsam@@QEBA?AV?$shared_ptr@VDiscreteFactor@gtsam@@@boost@@_K@Z) referenced in function "public: virtual void __cdecl DiscreteMarginalsUGM_smallTest::run(class TestResult &)" (?run@DiscreteMarginalsUGM_smallTest@@UEAAXAEAVTestResult@@@Z)
1>testDiscreteValues.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl gtsam::DiscreteValues::markdown(class std::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &,class std::map<unsigned __int64,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,struct std::less<unsigned __int64>,class std::allocator<struct std::pair<unsigned __int64 const ,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > > > const &)const " (?markdown@DiscreteValues@gtsam@@QEBA?AV?$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@4@AEBV?$map@_KV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@U?$less@_K@2@V?$allocator@U?$pair@$$CB_KV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@std@@@2@@4@@Z) referenced in function "public: virtual void __cdecl DiscreteValuesmarkdownWithValueFormatterTest::run(class TestResult &)" (?run@DiscreteValuesmarkdownWithValueFormatterTest@@UEAAXAEAVTestResult@@@Z)
1>testDiscreteValues.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl gtsam::DiscreteValues::html(class std::function<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl(unsigned __int64)> const &,class std::map<unsigned __int64,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >,struct std::less<unsigned __int64>,class std::allocator<struct std::pair<unsigned __int64 const ,class std::vector<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > > > const &)const " (?html@DiscreteValues@gtsam@@QEBA?AV?$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@4@AEBV?$map@_KV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@U?$less@_K@2@V?$allocator@U?$pair@$$CB_KV?$vector@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@std@@@2@@4@@Z) referenced in function "public: virtual void __cdecl DiscreteValueshtmlWithValueFormatterTest::run(class TestResult &)" (?run@DiscreteValueshtmlWithValueFormatterTest@@UEAAXAEAVTestResult@@@Z)
1>C:\Mike\Work\Build\gtsam-msheffler\bin\Debug\check_discrete_program.exe : fatal error LNK1120: 13 unresolved externals
1>Done building project "check_discrete_program.vcxproj" -- FAILED.
2>------ Build started: Project: check.discrete, Configuration: Debug x64 ------
2>Test project C:/Mike/Work/Build/gtsam-msheffler/gtsam/discrete/tests
2>    Start 1: check_discrete_program
2>Could not find executable C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>Looked in the following places:
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe.exe
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/Debug/check_discrete_program.exe
2>C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/Debug/check_discrete_program.exe.exe
2>Debug/C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>Debug/C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe.exe
2>Unable to find executable: C:/Mike/Work/Build/gtsam-msheffler/bin/Debug/check_discrete_program.exe
2>1/1 Test #1: check_discrete_program ...........***Not Run   0.00 sec
2>
2>0% tests passed, 1 tests failed out of 1
2>
2>Total Test time (real) =   0.01 sec
2>
2>The following tests FAILED:
2>	  1 - check_discrete_program (Not Run)
2>Errors while running CTest
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\Mike\Work\Build\gtsam-msheffler\CMakeFiles\64503014783bb89b4fb2b45506e598c8\check.discrete.rule' exited with code 8.
2>Done building project "check.discrete.vcxproj" -- FAILED.
========== Build: 0 succeeded, 2 failed, 4 up-to-date, 0 skipped ==========

Flabbergasted that so many targets fail even in gtsam. Let me know if you get tired of this, but we could play the same game for check.inference and check.inference, which are core to everything else. Maybe they have a (positive) ripple effect...

I'm game. I'm going to be away from the computer for a little bit, but let me know if anything obvious jumps out at you from the linker problems above. I'll take a look later as well.

In case we do want to chase those other two targets, here are the current errors, just an FYI.

check.inference (this seems to be straight-up the wrong answer, vs. a build issue)

Build started...
1>------ Build started: Project: check_inference_program, Configuration: Debug x64 ------
1>check_inference_program.vcxproj -> C:\Mike\Work\Build\gtsam-msheffler\bin\Debug\check_inference_program.exe
2>------ Build started: Project: check.inference, Configuration: Debug x64 ------
2>Test project C:/Mike/Work/Build/gtsam-msheffler/gtsam/inference/tests
2>    Start 1: check_inference_program
2>1/1 Test #1: check_inference_program ..........***Failed    0.06 sec
2>Not equal:
2>expected:
2>Position 0: 3, 2, 5, 0, 4, 1
2>actual:
2>Position 0: 4, 3, 1, 0, 5, 2
2>C:\Mike\Work\Source\gtsam-msheffler\gtsam\inference\tests\testOrdering.cpp:281: Failure: "assert_equal(expected, actual)"
2>There were 1 failures
2>
2>
2>0% tests passed, 1 tests failed out of 1
2>
2>Total Test time (real) =   0.07 sec
2>
2>The following tests FAILED:
2>	  1 - check_inference_program (Failed)
2>Errors while running CTest
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\Mike\Work\Build\gtsam-msheffler\CMakeFiles\64397e9baedee35eb7c0a984a0891ea0\check.inference.rule' exited with code 8.
2>Done building project "check.inference.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========

check.inference ... wait this one is listed twice

Did you mean check.nonlinear or something along those lines?

@mikesheffler
Copy link
Contributor Author

Okay, this time I'm really leaving, but before that, looking at the first error ...

1>testDiscreteFactorGraph.obj : error LNK2005: "public: virtual void __cdecl DiscreteFactorGraphDotWithNamesTest::run(class TestResult &)" (?run@DiscreteFactorGraphDotWithNamesTest@@UEAAXAEAVTestResult@@@Z) already defined in testDecisionTreeFactor.obj

I think it's actually right to complain? It's in both testDecisionTreeFactor.cpp and testDiscreteFactorGraph.cpp and it's not the same test.

  1. Which one should I strike (the test in testDiscreteFactorGraph.cpp is longer, but is it the right one)?
  2. Why isn't this an issue in the Linux build?

@mikesheffler
Copy link
Contributor Author

mikesheffler commented Feb 16, 2022

A little bird pointed out to me that #91 is probably wrapped in, out, and all around the Windows build issues I'm seeing.

We should probably ...

  1. Address @cntaylor's original question (GTSAM_SINGLE_TEST_EXE option causes compile errors #91 ) of 'Why is GTSAM_SINGLE_TEST_EXE -- which seems to be the source of many of these problems -- enabled by default in Windows and not in Linux? Does it need to be?'

  2. @varunagrawal identified a path forward for GTSAM_SINGLE_TEST_EXE option causes compile errors #91 that involved creating a bunch of namespaces and running a bunch of tests. If someone puts together a 'prototype' for what the solution looks like and how we need to test it, I can probably repeat that to lots of the other misbehaving tests.

  3. Figure out an appropriate home for this issue. Is it here? Unable to Build 4.1.1 On Windows #1087? New issue?

@dellaert
Copy link
Member

Mike, as I was looking into this it was straightforward (though still some work) to fix it myself. Added you as reviewer on #1107

@dellaert
Copy link
Member

As far as this PR goes, still waiting on @varunagrawal to weigh in.

@varunagrawal
Copy link
Collaborator

  1. Address @cntaylor's original question (GTSAM_SINGLE_TEST_EXE option causes compile errors #91 ) of 'Why is GTSAM_SINGLE_TEST_EXE -- which seems to be the source of many of these problems -- enabled by default in Windows and not in Linux? Does it need to be?'

This is interesting, I didn't even realize it was happening. Great find @mikesheffler!

Copy link
Collaborator

@varunagrawal varunagrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweeeet. Thanks for fixing all my stupid mistakes @mikesheffler! Having a second pair of eyes really helped me understand the core of this issue. 😄

@varunagrawal
Copy link
Collaborator

I'm going ahead and merging this (since I am waiting on CI for other things). We can tackle the rest of the targets in a new PR that builds on this and #1107.

@varunagrawal varunagrawal merged commit 07a7802 into borglab:develop Feb 17, 2022
@mikesheffler
Copy link
Contributor Author

Having a second pair of eyes really helped me understand the core of this issue. 😄

Third set! Someone else put it together and prodded me to point it out. 🙂

gchenfc added a commit to gchenfc/gtsam that referenced this pull request Apr 21, 2022
borglab#1102 correctly removed "GTSAM_EXPORT" from NoiseModelFactorX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants