Skip to content

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

@rafaelspring

Description

@rafaelspring

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions