0

I know it was discussed in length many times already, but my case has some particular condition I don't know how to address properly.

Library with /MDd solution builds OK. But it is not what the application needs as it requires /MT(d) version.

Now, I've changed the compiler options to /MTd, resolved some of the external projects dependencies, but still getting this:

Error   LNK2019 unresolved external symbol "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ) referenced in function "public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)" (??1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@XZ)  vcruntime140    ..\vcruntime140 ..\vcruntime140\log.obj

log.h is just this:

#ifndef LOG_H
#define LOG_H

#include <string>

namespace hooks {

/** Prints message to the file only if debug mode setting is  enabled. */
void logDebug(const std::string& logFile, const std::string& message);

/** Prints message to the file. */
void logError(const std::string& logFile, const std::string&  message);

} // namespace hooks

#endif // LOG_H

log.cpp

#include "log.h"
#include <chrono>
#include <ctime>
#include <fstream>
#include <iomanip>

namespace hooks {

static void logAction(const std::string& logFile, const   std::string& message)
{
using namespace std::chrono;

std::ofstream file(logFile.c_str(), std::ios_base::app);
const std::time_t time{std::time(nullptr)};
const std::tm tm = *std::localtime(&time);

file << "[" << std::put_time(&tm, "%c") << "] " << message << "\n";
}

void logDebug(const std::string& logFile, const std::string& message)
{
    logAction(logFile, message);
}

void logError(const std::string& logFile, const std::string& message)
{
logAction(logFile, message);
}

} // namespace hooks

hooks.h

#ifndef HOOKS_H
#define HOOKS_H

#include <string>
#include <utility>
#include <vector>


namespace hooks {

using HookInfo = std::pair<void**, void*>;
using Hooks = std::vector<HookInfo>;

/** Returns array of hooks to setup. */
Hooks getHooks();
Hooks getVftableHooks();

} // namespace hooks

#endif // HOOKS_H

hooks.cpp

#include "hooks.h"


namespace hooks {

Hooks getHooks()
{
Hooks hooks;  
return hooks;
}

Hooks getVftableHooks()
{
Hooks hooks;
return hooks;
}

} // namespace hooks

Any idea of how to resolve it?

Irbis77
  • 163
  • 1
  • 8

1 Answers1

0

Found solution, the only remaining issue is actually unrelated to the above. The above errors are resolved in the following way:

Adding MSVCPRTD.LIB to the additional libraries link seem to elliminate the problems with LINK2019.

The problem was happening since some of the standard library functions defined in that lib were not loaded. I've realised it by checking the error message and googling of which function definitions are missing and which library they belong to.

But now there is a problem with MSVCPRTD.LIB as it is a dynamic and not a static library according to Microsoft docs: https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-160

The problem with MSVCPRTD.LIB can be addressed by loading libcmtd.lib instead, which is the /MTd version of the same librari(es).

Irbis77
  • 163
  • 1
  • 8