[sword-devel] Latest SWORD trunk /Linkingerror/Missingsymbol:sword::InstallMgr::userDisclaimerConfirmed

Tobias Klein contact at tklein.info
Sun Sep 27 10:38:21 EDT 2020


Hi Troy,

Thanks!

_MSC_VER should be automatically defined when using a Microsoft compiler. https://docs.microsoft.com/de-de/cpp/preprocessor/predefined-macros?view=vs-2019

SWMAKINGDLL is defined by the CMake build system if MSVC is also defined (automatically the case for Microsoft compilers).

SWUSINGDLL has not been defined in node-sword-interface before. I just added that definition and that seems to solve my linking issues on Windows! Yay!
Before I had issues both with sword::SWBuf::nullStr and with InstallMgr::userDisclaimerConfirmed. They’re both resolved now!

Is this documented anywhere? 😊 I had no idea that I needed to provide this definition on Windows when linking against the DLL.

Best regards,
Tobias

From: Troy A. Griffitts
Sent: Sonntag, 27. September 2020 12:41
To: sword-devel at crosswire.org
Subject: Re: [sword-devel] Latest SWORD trunk /Linkingerror/Missingsymbol:sword::InstallMgr::userDisclaimerConfirmed

Dear Tobias,
I have looked and looked at this and don't have any idea why there would be linking issues.  I could guess what is causing it.  The method setUserDisclaimerConfirmed is implemented inline in the header file, so it will be outside the DLL and in your client code and it is trying to reference a static member of the InstallMgr class.  But we already declare class InstallMgr _declspec(dllimport).  You can see this in defs.h:
...
// _declspec works in BC++ 5 and later, as well as VC++
#if defined(_MSC_VER)

#  ifdef SWMAKINGDLL
#    define SWDLLEXPORT _declspec( dllexport )
Note a couple things: we use a single underscore.  Looking this up, it seems a single underscore is the older way to do this now that newer versions of the C++ spec reserve double underscores for things like this, but it still works.  Also, you might check that _MSC_VER is defined and that SWMAKINGDLL is defined in your build system when you build the DLL and that SWUSINGDLL is defined in your build system when you link your client to the DLL. -- from looking at defs.h lines 62ff.
BUT HAVING SAID ALL THIS, I have no idea why you would be able to link to ANY methods in the DLL if this wasn't all correct.  I don't see anything different with the static bool InstallMgr::userDisclaimerConfirmed compared to any of the other methods or statics.  Can you access any other static member of a class?  How about trying to link with a reference to:
InstallMgr::MODSTAT_OLDER;
And then maybe try a static from another class:
SWMgr::MODTYPE_BIBLES;

Thanks for any more info you might provide on this.
Troy

On 9/22/20 11:57 AM, Tobias Klein wrote:
I’ve gone for an alternative implementation as a work-around. Before, I was calling InstallMgr::setUserDisclaimerConfirmed. That caused the linking issue on Windows. I’ve now switched to inheriting InstallMgr with a custom method “isUserDisclaimerConfirmed”.
 
Best regards,
Tobias
 
From: Tobias Klein
Sent: Montag, 21. September 2020 21:58
To: SWORD Developers' Collaboration Forum
Subject: Re: [sword-devel] Latest SWORD trunk / Linkingerror/Missingsymbol:sword::InstallMgr::userDisclaimerConfirmed
 
I tried to fix this by setting the CMake variable  CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE
https://cmake.org/cmake/help/v3.4/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html
 
But that didn’t help! I still get the same linker issue.
 
However, in the above linked Cmake help it says: For global data symbols, __declspec(dllimport) must still be used when compiling against the code in the .dll. All other function symbols will be automatically exported and imported by callers.
 
Aren’t we dealing with a „global data symbol“ in this case?
 
See also:
https://docs.microsoft.com/de-de/cpp/build/importing-into-an-application-using-declspec-dllimport?view=vs-2019
 
Best regards,
Tobias
 
From: Tobias Klein
Sent: Montag, 21. September 2020 11:29
To: SWORD Developers' Collaboration Forum
Subject: Re: [sword-devel] Latest SWORD trunk / Linking error/Missingsymbol:sword::InstallMgr::userDisclaimerConfirmed
 
I’m still having the same issue with the latest SWORD trunk when linking on Windows.
 
Since this wasn’t an issue with SWORD trunk from May (SVN Rev. 3747), is there a way to fix this in SWORD?
 
Best regards,
Tobias
 
From: Tobias Klein
Sent: Samstag, 29. August 2020 10:22
To: SWORD Developers' Collaboration Forum
Subject: Re: [sword-devel] Latest SWORD trunk / Linking error /Missingsymbol:sword::InstallMgr::userDisclaimerConfirmed
 
This occurred to me when building automatically via GitHub actions and that is always a full-rebuild.
 
I had this problem also in the past with manual Windows builds and the work-around was to “re-declare” the respective symbol in the software that links against Sword. I already had this issue before with sword::SWBuf::nullStr:
 
#if defined(_WIN32)
// For some reason this symbol is missing in the sword.dll on Windows, hence we include it here.
char * sword::SWBuf::nullStr = (char *)"";
#endif
 
Best regards,
Tobias
 
 
 
From: Troy A. Griffitts
Sent: Samstag, 29. August 2020 09:52
To: SWORD Developers' Collaboration Forum
Subject: Re: [sword-devel] Latest SWORD trunk / Linking error / Missingsymbol:sword::InstallMgr::userDisclaimerConfirmed
 
Hi Tobias,
This did receive a bit of a reorganization, but the symbol is declared in include/installmgr.h:97 and is initialized with the other statics in installmgr.cpp:75.
Have you tried a full rebuild?
Is anyone else having linking troubles?
Troy
 
On 8/29/20 9:20 AM, Tobias Klein wrote:
Hi Troy,
 
Any feedback regarding this one?
 
Thanks!
 
Best regards,
Tobias
 
From: Tobias Klein
Sent: Sonntag, 16. August 2020 11:10
To: SWORD Developers' Collaboration Forum
Subject: [sword-devel] Latest SWORD trunk / Linking error / Missing symbol:sword::InstallMgr::userDisclaimerConfirmed
 
Hi,
 
With the latest SWORD trunk I’m getting the following linking error:
 
Creating library D:\a\ezra-project\ezra-project\node_modules\node-sword-interface\build\Release\node_sword_interface.lib and object D:\a\ezra-project\ezra-project\node_modules\node-sword-interface\build\Release\node_sword_interface.exp
repository_interface.obj : error LNK2001: unresolved external symbol "public: static bool sword::InstallMgr::userDisclaimerConfirmed" (?userDisclaimerConfirmed at InstallMgr@sword@@2_NA) [D:\a\ezra-project\ezra-project\node_modules\node-sword-interface\build\node_sword_interface.vcxproj]
 
The symbol sword::InstallMgr::userDisclaimerConfirmed is missing in the generated SWORD dll. Did something recently change regarding this symbol or how it is included in the build (based on CMake and Visual Studio 2019)?
 
Best regards,
Tobias
_______________________________________________
sword-devel mailing list: sword-devel at crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
 
 
_______________________________________________
sword-devel mailing list: sword-devel at crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page
 
 
 
 


_______________________________________________
sword-devel mailing list: sword-devel at crosswire.org
http://crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://crosswire.org/pipermail/sword-devel/attachments/20200927/fd4e1f18/attachment-0001.html>


More information about the sword-devel mailing list