Skip to content
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 vformat #795

Closed
k0zmo opened this issue Jun 30, 2018 · 4 comments
Closed

Undefined reference to vformat #795

k0zmo opened this issue Jun 30, 2018 · 4 comments

Comments

@k0zmo
Copy link

k0zmo commented Jun 30, 2018

Following program fails in linker stage with an undefined reference to vformat. It happens with GCC 7.3 (MSYS2) and MSVC 14.1 but only in release-flavour configurations (all three of them). I suspect the inline keyword on vformat() definition in format.h can be a culprit here (in debug configuration compiler does not optimize aggressively inline functions).

It doesn't exhibit any problems if I change include fmt/format.h instead of fmt/core.h.

cmake_minimum_required(VERSION 3.0)
project(fmt-test)

add_subdirectory(fmt)

add_executable(fmt-test main.cpp)
target_link_libraries(fmt-test PRIVATE fmt::fmt)
#include <fmt/core.h>

int main(int argc, char* argv[])
{
    fmt::format("{}", argc);
}
@vitaut
Copy link
Contributor

vitaut commented Jul 4, 2018

Could you post the output of nm libfmt.a (or dumpbin fmt.lib)?

@vitaut
Copy link
Contributor

vitaut commented Jul 4, 2018

323b92b is a tentative fix, although I wasn't able to repro the issue on my version of gcc. Please let me know if it works for you and I'll merge into master.

@k0zmo
Copy link
Author

k0zmo commented Jul 4, 2018

This fixes it in both GCC and MSVC.

Here's the output from nm | c++filt | grep vformat:
nm.after.log
nm.before.log

and objdump /SYMBOLS | grep vformat:
dumpbin.after.log
dumpbin.before.log

@vitaut
Copy link
Contributor

vitaut commented Jul 4, 2018

Merged the fix into master, thanks for reporting and confirming that it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants