p-ranav / tabulate

Table Maker for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

locale::facet::_S_create_c_locale name not valid

krishna116 opened this issue · comments

I don't know if this project support MinGW64, but I tried a minimal code, it is failed.

My test environment:
MSYS2/mingw64, (https://www.msys2.org/)
g++.exe (Rev5, Built by MSYS2 project) 10.3.0
p-ranav/tabulate-master,2021/08/15

//My test code:
#include "tabulate/table.hpp"
#include
int main()
{
tabulate::Table table;
table.add_row({"001", "Jack", "is", "a good man"});
std::cout << table << std::endl;
return 0;
}

//My cmake code:
set(APP_NAME "test_make_table")
add_executable(${APP_NAME}
main.cpp
)
target_include_directories(${APP_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/party3/tabulate-master/include
)
target_compile_features(${APP_NAME}
PUBLIC
cxx_std_17
)

I build it with command "cmake --build build", it build pass.
but when I run my app, error happened as follow:
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid

That's because the locate-setting of your building host. Just export LANG=C export LC_ALL=C and build it again.

That's because the locate-setting of your building host. Just export LANG=C export LC_ALL=C and build it again.

My default environment is "LANG=en_US.UTF-8", I think it is the default setting for most applications.
I don't know why should I change this, nevertheless, I did what you said and it works, thanks a lot.

(By the way, if I switch back to "LANG=en_US.UTF-8", my application will fail again.)

Small addition: you can use table.format().locale("C");
For me, works fine (Windows 10 MinGW64)