# Trouble Compiling Session Manager from C++ Guide Example

**URL:** <https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442>\
**Category:** Local Setup\
**Tags:** getting-started, sdk-cpp\
**Created:** [March 15, 2021, 1:51am UTC](https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442 "2021-03-15T01:51:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mehoo462](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Mehoo462](https://forum.heroiclabs.com/u/Mehoo462)\
**Post date:** [March 15, 2021, 1:51am UTC](https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442/1 "2021-03-15T01:51:11Z")

</div>

I’m just getting my C++ Dev environment set up. I copied the code from the [C++ Client Guide](https://heroiclabs.com/docs/cpp-client-guide/). Then I tried to create an instance of NakamaSessionManager in my Main function. And I’m getting a bunch of build errors. Can anybody help? I thought I followed the instructions.

"mismatch detected for ‘\_ITERATOR\_DEBUG\_LEVEL’: value ‘0’ doesn’t match value ‘2’

```
#include <iostream>
#include "nakama-cpp/Nakama.h"

using namespace Nakama;
using namespace std;

class NakamaSessionManager
{
public:
    NakamaSessionManager()
    {
        NClientParameters parameters;

        _client = createDefaultClient(parameters);
    }

    void start(const string& deviceId)
    {
        // to do: read session token from your storage
        string sessionToken;

        if (!sessionToken.empty())
        {
            // Lets check if we can restore a cached session.
            auto session = restoreSession(sessionToken);

            if (!session->isExpired())
            {
                // Session was valid and is restored now.
                _session = session;
                return;
            }
        }

        auto successCallback = [this](NSessionPtr session)
        {
            _session = session;

            // to do: save session token in your storage
            std::cout << "session token: " << session->getAuthToken() << std::endl;
        };

        auto errorCallback = [](const NError& error)
        {
        };

        _client->authenticateDevice(deviceId, opt::nullopt, opt::nullopt, {}, successCallback, errorCallback);
    }

protected:
    NClientPtr _client;
    NSessionPtr _session;
};

int main()
{

    NakamaSessionManager MyClient; //calling the class exactly as in the example and failing in construction

    std::cout << "Hello World!\n";
}

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/1X/a7a09d46e9634c923f1291ea23e1c10340af4cd3.png)

---

<div class="post-metadata">

**Author:** ![lugehorsam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/lugehorsam/32/314_2.png) [@lugehorsam](https://forum.heroiclabs.com/u/lugehorsam)\
**Post date:** [March 15, 2021, 2:00am UTC](https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442/2 "2021-03-15T02:00:28Z")

</div>

Hey @Mehoo462 👋

I think this happens when you link against a release library with a debug project in some Visual Studio projects.

Could you add `_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH` to your C++ preprocessor definitions in your editor?

---

<div class="post-metadata">

**Author:** ![Mehoo462](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Mehoo462](https://forum.heroiclabs.com/u/Mehoo462)\
**Post date:** [March 15, 2021, 2:24am UTC](https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442/3 "2021-03-15T02:24:41Z")

</div>

Hi! Thanks for the prompt reply. That’s encouraging. 🙂  
I think followed your suggestion. But I’m still getting the same errors. I made the change and restarted VS2019 just to make sure.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/1X/cd269cb1e558e110d79b6d76d21d39b9fa7fd0bd.png)

---

<div class="post-metadata">

**Author:** ![Mehoo462](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Mehoo462](https://forum.heroiclabs.com/u/Mehoo462)\
**Post date:** [March 16, 2021, 3:15am UTC](https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442/4 "2021-03-16T03:15:14Z")

</div>

Okay… the problem occurs in Step 3 of the “Setup for Visual Studio projects” of the C++ guide.

It says:

1. Add all `.lib` files located in libs folder in `Linker > Input > Additional Dependencies`

You don’t want to add all ‘.lib’ files to the Additional dependencies. You want to add all the .lib files in the debug folder to Additional Dependencies for your Debug Configuration. And all the files in the Release folder to Additional dependencies for your Release configuration.

If you load both the release and debug libraries at once, you wind up with contradictory Debug Levels, and VS2019 is unhappy about that.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/heroiclabs/original/1X/da8c625b01629c6d424b4bcf900389e5b29aa8ff.png)

---

<div class="post-metadata">

**Author:** ![lugehorsam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/lugehorsam/32/314_2.png) [@lugehorsam](https://forum.heroiclabs.com/u/lugehorsam)\
**Post date:** [March 16, 2021, 9:55pm UTC](https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442/5 "2021-03-16T21:55:17Z")

</div>

@Mehoo462 brilliant find. I am going to update the readme with these new instructions.

---

<div class="post-metadata">

**Author:** ![Mehoo462](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@Mehoo462](https://forum.heroiclabs.com/u/Mehoo462)\
**Post date:** [March 17, 2021, 4:05am UTC](https://forum.heroiclabs.com/t/trouble-compiling-session-manager-from-c-guide-example/1442/6 "2021-03-17T04:05:58Z")

</div>

Thanks. I’m concerned there still might be an issue with the Readme though. I think I followed the directions properly, but I’m still not able to build successfully.

Once I corrected the issue with the Additional Dependencies I ran into a problem with Unresolved External Symbol Errors. Do you have any thoughts that problem?

[https://forum.heroiclabs.com/t/unresolved-external-symbol-errors/1447](https://forum.heroiclabs.com/t/unresolved-external-symbol-errors/1447)
