CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2017
    Posts
    5

    [RESOLVED] Error while statically linking Libsodium

    It appears that I'm linking libsodium correctly, but I'm getting linker errors for _sodium_init, I'm using Visual Studio 2015, and the libsodium.lib (prebuilt) for msvc 140 (for vs2015). The project is c++.

    This is how my setting look for linker: http://prntscr.com/ixv042

    For additional includes, my settings look like this: http://prntscr.com/ixv0mg

    The folder that the project resides in looks like this: http://prntscr.com/ixv0vw

    I'm including sodium.h as so: http://prntscr.com/ixv1go


    and of course, in main() I'm doing
    Code:
    sodium_init()

    I'm not sure why I would be getting linker errors, does anyone spot anything wrong with the code?

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: Error while statically linking Libsodium

    What linker errors are you getting?

    Have you followed the instructions re defining the required macro?

    Note for Visual Studio

    Projects willing to statically link Sodium must define a macro named SODIUM_STATIC. This will prevent symbol definitions from being referenced with __dllexport.
    ...
    For static linking, Visual Studio users should define SODIUM_STATIC=1 and SODIUM_EXPORT=. This is not required on other platforms.
    See https://download.libsodium.org/doc/installation/
    https://download.libsodium.org/doc/usage/
    Last edited by 2kaud; March 29th, 2018 at 04:36 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #3
    Join Date
    Oct 2017
    Posts
    5

    Re: Error while statically linking Libsodium

    Yes, I followed the instructions, but I also figured out what the issue was.

    It was actually quite a foolish error on my part, I tried to link the x64 static library when the project was x86.

    Thank you for your effort 2kaud!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured