How to use the fmt library without getting “Undefined symbols for architecture x86_64”

前端 未结 1 481
野性不改
野性不改 2021-01-27 04:59

I\'m trying to use the fmt (https://github.com/fmtlib/fmt) formatting header library in my c++ project.

I\'ve added the path to the core header file at the top of my ma

相关标签:
1条回答
  • 2021-01-27 05:50

    You should link with the fmt library or use the optional header-only mode.

    For example, if you have the file test.cc:

    #include <fmt/core.h>
    
    int main() {
      fmt::print("The answer is {}.", 42);
    }
    

    You can compile and link it with gcc:

    g++ -std=c++11 test.cc -lfmt
    
    0 讨论(0)
提交回复
热议问题