p-ranav / tabulate

Table Maker for Modern C++
MIT License
1.94k stars 138 forks source link

locale::facet::_S_create_c_locale name not valid #75

Closed krishna116 closed 3 years ago

krishna116 commented 3 years ago

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

Jun-Amane commented 3 years ago

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

krishna116 commented 3 years ago

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.)

potat-dev commented 2 years ago

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