-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined reference to `fmt::v7::detail::vformat[abi:cxx11](fmt::v7::basic_string_view<char>, fmt::v7::format_args) #2157
Comments
Nevermind I figured it out... |
Oh, I missed the last entry in the features section of the README. 😅 For anybody else who encounters this error: You need to insert |
Wow, what a pain in the butt! If you do not include the define like this: #define FMT_HEADER_ONLY
#include <fmt/format.h> ...then what's the solution? UPDATE 4 May 2022: here's the answer: #2157 (comment). In short: run cmake, make, and make install, then build with |
To enable the header-only mode you should define |
@vitaut , thanks. How does one use the not header-only mode? I mean: what's the other way to build and use the lib if we choose to use the mode which is not header only? |
Please see https://fmt.dev/latest/usage.html. |
@vitaut , thank you very much for responding so quickly! What I really needed, unfortunately, wasn't to be found in that documentation link, but I just figured out the following. Perhaps you can update the documentation at that link with this additional information? I had already followed those instructions to make and install the library prior to my first comment here: #2157 (comment). I had already run: git clone https://github.com/fmtlib/fmt.git
cd fmt
mkdir -p build
cd build
time cmake .. # takes ~2 sec
time make # takes ~3~5 minutes
time sudo make install # takes ~7 sec Then I tried to build and run with: time g++ -Wall -Wextra -Werror -O3 -std=c++17 fmt_lib_demo.cpp -o bin/a && bin/a and I got this error:
When I ran
So, I linked to that Here are the 2 solutions to link to the # Option 1: add `-lfmt`
time g++ -Wall -Wextra -Werror -O3 -std=c++17 fmt_lib_demo.cpp -o bin/a -lfmt && bin/a
# OR: Option 2: add `"/usr/local/lib/libfmt.a"`
time g++ -Wall -Wextra -Werror -O3 -std=c++17 fmt_lib_demo.cpp "/usr/local/lib/libfmt.a" -o bin/a && bin/a Thanks! I'm now also enforcing compile-time error checks by adding the Here is my final build and run command: time g++ -Wall -Wextra -Werror -O3 -std=c++17 -DFMT_ENFORCE_COMPILE_STRING fmt_lib_demo.cpp -o bin/a -lfmt && bin/a This will be going into my eRCaGuy_hello_world demonstration code in this file here: eRCaGuy_hello_world/cpp/fmt_lib_demo.cpp. |
I added my instructions here: C++ |
I have been running into a compiling issue with GCC 10.2.0. Where I tried to compile my code in MVSC with the header "fmt\format.h" and it would tell me that vformat is undefined. I'm very new to programming and still learning. I need this header for the book I'm reading and I don't really want to skip anything.
`#include
#include "fmt/format.h"
int main()
{
std::cout << fmt::format("Hello your number is {}", 42) << std::endl;
return 0;`
}`
undefined reference to `fmt::v7::detail::vformat[abi:cxx11](fmt::v7::basic_string_view, fmt::v7::format_args)'
collect2.exe: error: ld returned 1 exit status
The text was updated successfully, but these errors were encountered: