0

I am trying to use FTM for string interpolation in C++ but it is giving me some linker errors when I try to compile.

I have written the following class:

#include <string>
#include "include/fmt/format.h"

class A {
public:
    std::string sayHi(std::string name) {
        return fmt::format("Hello {0}", name);
    }
};

Using this class in my main results in some LNK2001 en LNK2019 errors. Here is a small sample of them: enter image description here I am guessing this is due to incorrect usage of the library. Am I missing some global variable that should be set?

SomeDutchGuy
  • 2,249
  • 4
  • 16
  • 42
  • 1
    You need to *link* against libfmt. – HolyBlackCat Dec 02 '19 at 11:23
  • @HolyBlackCat "link against" does not really give a result searching for it or on the link you mentioned this is a duplicate of. It might make sense in the context of c++ but I am not an experienced c++ programmer. – SomeDutchGuy Dec 02 '19 at 11:31
  • First, you need to [build libfmt with CMake](https://www.google.com/search?q=cmake%20build%20with%20visual%20stdio). It should give you `fmt.lib` or a similarly named file. Then you specify a path to this file [somewhere in your project settings](https://stackoverflow.com/questions/4445418/how-to-add-additional-libraries-to-visual-studio-project). – HolyBlackCat Dec 02 '19 at 11:41
  • @HolyBlackCat thanks. I'll look into that next. – SomeDutchGuy Dec 02 '19 at 11:53

0 Answers0