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

Linker error, probably related to usage of GTSAM_EXPORT macro #22

Open
rafaelspring opened this issue Aug 25, 2024 · 1 comment
Open

Comments

@rafaelspring
Copy link

When building gtsam_points I get plenty of linker errors like this one:

isam2_ext.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl
gtsam_points::UpdateImpl::LogStartingUpdate(class gtsam::NonlinearFactorGraph const &,class gtsam_points::ISAM2Ext const &)"
(_imp?LogStartingUpdate@UpdateImpl@gtsam_points@@SAXAEBVNonlinearFactorGraph@gtsam@@AEBVISAM2Ext@2@@z) referenced in function "public: virtual struct gtsam_points::ISAM2ResultExt __cdecl gtsam_points::ISAM2Ext::update(class gtsam::NonlinearFactorGraph const &,class gtsam::Values const &,struct gtsam::ISAM2UpdateParams const &)" (?update@ISAM2Ext@gtsam_points@@UEAA?AUISAM2ResultExt@2@AEBVNonlinearFactorGraph@gtsam@@AEBVValues@5@AEBUISAM2UpdateParams@5@@z)

The errors go away when using add_definitions(-DGTSAM_EXPORTS) in CMakeLists.txt to set the GTSAM_EXPORT macro to __declspec(dllexport).

However, the problem is that gtsam_points depends on GTSAM and when its headers are included they as well have the GTSAM_EXPORTS macro active and therefore treat GTSAM's symbols as exported symbols! This causes other problems in the build.
So including GTSAM headers should be done under a regime of __declspec(dllimport) (not export!), as we're just using GTSAM as a library, not building it.

Therefore I think gtsam_points should have its own dllexport.h header file and use the definition GTSAM_POINTS_EXPORTS and macro name GTSAM_POINTS_EXPORT to avoid the confusion with the GTSAM macros.

I am building on Windows 10, x64.

@koide3
Copy link
Owner

koide3 commented Aug 27, 2024

Thanks for reporting the issue.
I agree with that we should have our own EXPORT macros. While I've been occupied with some works in next a few weeks, l try to add these macros to support build on windows in next month.

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

No branches or pull requests

2 participants