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

Windows Tests #1109

Merged
merged 18 commits into from
Feb 22, 2022
Merged

Windows Tests #1109

merged 18 commits into from
Feb 22, 2022

Conversation

varunagrawal
Copy link
Collaborator

Thanks to the awesome work by @mikesheffler, I was finally able to figure out what was the issue behind all the "undefined" errors.

This PR adds/removes all the necessary GTSAM_EXPORT declarations and updates the CI to run all GTSAM test targets. Unfortunately some targets have test failures due to bugs creeping in over time and the CI not being enabled for them, but those can be tackled later.

I am leaving GTSAM_UNSTABLE test targets for another day.

@varunagrawal varunagrawal added bugfix Fixes an issue or bug ci Related to the Continuous Integration pipeline labels Feb 17, 2022
@varunagrawal varunagrawal self-assigned this Feb 17, 2022
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.

Awesome (if windows CI actually passes :-))

} // namespace gtsam
Copy link
Member

Choose a reason for hiding this comment

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

Why ?

@@ -146,7 +146,30 @@ class Line3 {
*/
Line3 transformTo(const Pose3 &wTc, const Line3 &wL,
OptionalJacobian<4, 6> Dpose = boost::none,
OptionalJacobian<4, 4> Dline = boost::none);
OptionalJacobian<4, 4> Dline = boost::none) {
Copy link
Member

Choose a reason for hiding this comment

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

I had trouble with definitions in headers. Should be inline? But I don't understand why we can't just export here and leave definition in .cpp?

@@ -39,6 +39,9 @@ BOOST_CLASS_EXPORT_GUID(noiseModel::Unit, "gtsam_noiseModel_Unit")
BOOST_CLASS_EXPORT_GUID(noiseModel::Isotropic, "gtsam_noiseModel_Isotropic")
BOOST_CLASS_EXPORT_GUID(SharedNoiseModel, "gtsam_SharedNoiseModel")
BOOST_CLASS_EXPORT_GUID(SharedDiagonal, "gtsam_SharedDiagonal")
BOOST_CLASS_EXPORT_GUID(PreintegratedImuMeasurements, "gtsam_PreintegratedImuMeasurements")
Copy link
Member

Choose a reason for hiding this comment

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

should be gtsam::PreintegratedImuMeasurements I think, not _.
We should really standardize (different issue, different PR, different contributor)

@varunagrawal
Copy link
Collaborator Author

I forgot to comment out the gtsam_unstable test build. Windows CI will fail for that reason.

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.

Changing to "request changes" as I think that function should not be moved out of cpp, unless you can tell me the reason :-)

@varunagrawal
Copy link
Collaborator Author

The linker seems to confuse the transformTo method for Line3 with the expressions version, this throwing a linker error. Another solution would be to rename the expression version to transformTo_ but that would be API breaking?

@dellaert
Copy link
Member

The linker seems to confuse the transformTo method for Line3 with the expressions version, this throwing a linker error. Another solution would be to rename the expression version to transformTo_ but that would be API breaking?

That is very weird. Error message? CI seems to pass, so is it check.geometry that does not pass?

@mikesheffler
Copy link
Contributor

Just as a datapoint, I currently have (for fix/windows-tests, and without attempting any gtsam_unstable stuff):

Pass

check.base
check.basis
check.inference
check.navigation
check.sfm
check.symbolic

Fail

check.discrete
check.geometry
check.nonlinear
check.partition
check.sam
check.slam
check.tests

I thought check.discrete was supposed to be in the 'Pass' category, so I'll print what I have on my side. I should be able to look at this later tonight.

Possibly relevant warning:

EXPECT(adds = 54);

results in

Assignment '=' used when equality '==' probably intended

at testAlgebraicDecisionTree.cpp line 321.

check.discrete Build Errors

Looks like multiply-defined symbols:

Build started...
1>------ Build started: Project: check_discrete_program, Configuration: Debug x64 ------
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "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 &)" (?DefaultFormatter@?$AlgebraicDecisionTree@_K@gtsam@@CA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEB_K@Z) already defined in testAlgebraicDecisionTree.obj
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "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 &)" (??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) already defined in testAlgebraicDecisionTree.obj
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "public: void __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::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@?$AlgebraicDecisionTree@_K@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) already defined in testAlgebraicDecisionTree.obj
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "public: bool __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::equals(class gtsam::AlgebraicDecisionTree<unsigned __int64> const &,double)const " (?equals@?$AlgebraicDecisionTree@_K@gtsam@@QEBA_NAEBV12@N@Z) already defined in testAlgebraicDecisionTree.obj
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "public: virtual __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::~AlgebraicDecisionTree<unsigned __int64>(void)" (??1?$AlgebraicDecisionTree@_K@gtsam@@UEAA@XZ) already defined in testAlgebraicDecisionTree.obj
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(class gtsam::AlgebraicDecisionTree<unsigned __int64> const &)" (??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBV01@@Z) already defined in testAlgebraicDecisionTree.obj
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "public: __cdecl gtsam::AlgebraicDecisionTree<unsigned __int64>::AlgebraicDecisionTree<unsigned __int64>(struct std::pair<unsigned __int64,unsigned __int64> const &,double,double)" (??0?$AlgebraicDecisionTree@_K@gtsam@@QEAA@AEBU?$pair@_K_K@std@@NN@Z) already defined in testAlgebraicDecisionTree.obj
1>gtsamDebug.lib(gtsamDebug.dll) : error LNK2005: "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 &)" (??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) already defined in testAlgebraicDecisionTree.obj
1>C:\Mike\Work\Build\gtsam\bin\Debug\check_discrete_program.exe : fatal error LNK1169: one or more multiply defined symbols found
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/gtsam/discrete/tests
2>    Start 1: check_discrete_program
2>Could not find executable C:/Mike/Work/Build/gtsam/bin/Debug/check_discrete_program.exe
2>Looked in the following places:
2>C:/Mike/Work/Build/gtsam/bin/Debug/check_discrete_program.exe
2>C:/Mike/Work/Build/gtsam/bin/Debug/check_discrete_program.exe.exe
2>C:/Mike/Work/Build/gtsam/bin/Debug/Debug/check_discrete_program.exe
2>C:/Mike/Work/Build/gtsam/bin/Debug/Debug/check_discrete_program.exe.exe
2>Debug/C:/Mike/Work/Build/gtsam/bin/Debug/check_discrete_program.exe
2>Debug/C:/Mike/Work/Build/gtsam/bin/Debug/check_discrete_program.exe.exe
2>Unable to find executable: C:/Mike/Work/Build/gtsam/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

@dellaert
Copy link
Member

Definitely should be ==

About ADT: could be template instantiation.

@mikesheffler
Copy link
Contributor

About ADT: could be template instantiation.

I think so? As the code says, it (ADT) mostly exists to specialize one template argument to DecisionTree as double.

I tried sprinkling inline here and there in the ADT header on the methods that were complaining about already being defined, but it didn't seem to do anything. Between the static methods, the inlines and the inheritance, I can't seem to follow it all at once.

Basically, as soon as you have two ADT instances in testAlgebraicDecisionTree.cpp, you'll get the whole raft of errors, so it's probably something about the whole class. Dunno. 😦

@varunagrawal
Copy link
Collaborator Author

varunagrawal commented Feb 18, 2022

@dellaert I am going to park responding to this issue until at least the 24th (RAL+IROS deadline). Don't want you to think I'm being unresponsive. :)

@dellaert
Copy link
Member

Actually, @mikesheffler , I think the == should be replaced with LONGS_EQUAL(54, adds), and 54 should be changed to the right value ;-)

I think the solution to the ADT linking problem might be to re-add the export, and add a .cpp file with an explicit instantiation on Key. That should create one set of symbols exported to the DLL.

…d of EQUAL -- Please review

* Added GTSAM_EXPORT back to to AlgebraicDecisionTree.h and added a .cpp file to accompany the .h. The only contents of the file are the specialization AlgebraicDecisionTree<Key>. This seems to make the linker happy enough to include the symbols that allow the above test to run.
@mikesheffler
Copy link
Contributor

mikesheffler commented Feb 21, 2022

tl;dr: check.discrete passes now (in Windows).


I think the == should be replaced with LONGS_EQUAL(54, adds), and 54 should be changed to the right value ;-)

I made the change to LONGS_EQUAL and it looks like the value that the test wants is 49, so I changed it to 49. I haven't made the slightest attempt to understand what's actually going on in the test, so please take a look and decide if that is sensible.

the ADT linking problem might be to re-add the export, and add a .cpp file with an explicit instantiation on Key.

I added back GTSAM_EXPORT and then made the .cpp with just

namespace gtsam {

  template class AlgebraicDecisionTree<Key>;

}  // namespace gtsam

which seems to convince the linker to export the symbols, and just once to boot. I don't have a tight handle on the linker's decision making process here, so it's worth taking a look.

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.

Nice!
@mikesheffler, @varunagrawal, I propose to approve this PR and we can address different modules in a different PR? After waiting for @mikesheffler confirmation that he does not have outstanding changes on this PR, I propose @varunagrawal merges.

@mikesheffler
Copy link
Contributor

I do not have outstanding changes. I think the idea to chop up the effort makes sense, or this will be unmerged for a while.

@dellaert
Copy link
Member

Cool. @varunagrawal merge when you're ready

@varunagrawal varunagrawal merged commit 267a4ae into develop Feb 22, 2022
@varunagrawal varunagrawal deleted the fix/windows-tests branch February 22, 2022 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes an issue or bug ci Related to the Continuous Integration pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants