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

在ubuntu16上安装后,./sqladvisor --help执行结果是[ERROR] setlocale 有错 #70

Open
MingJunDuan opened this issue Jun 13, 2018 · 2 comments

Comments

@MingJunDuan
Copy link

MingJunDuan commented Jun 13, 2018

`root@ubuntu:/opt/sqlAdvisor/SQLAdvisor/sqladvisor# make
Scanning dependencies of target sqladvisor
[ 50%] Building CXX object CMakeFiles/sqladvisor.dir/main.cc.o
In file included from /usr/local/sqlparser/include/sql/item.h:2470:0,
from /usr/local/sqlparser/include/sql/sql_class.h:39,
from /opt/sqlAdvisor/SQLAdvisor/sqladvisor/main.cc:7:
/usr/local/sqlparser/include/sql/item_timefunc.h: In member function 'virtual longlong Item_time_func::val_int()':
/usr/local/sqlparser/include/sql/item_timefunc.h:533:12: warning: converting to non-pointer type 'longlong {aka long long int}' from NULL [-Wconversion-null]
return NULL;
^
/opt/sqlAdvisor/SQLAdvisor/sqladvisor/main.cc: In function 'void final_table_drived()':
/opt/sqlAdvisor/SQLAdvisor/sqladvisor/main.cc:333:37: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::set<TABLE_LIST*>::size_type {aka long unsigned int}' [-Wformat=]
TABLE_DRIVERD.size());
^
/opt/sqlAdvisor/SQLAdvisor/sqladvisor/main.cc:353:126: warning: format '%d' expects argument of type 'int', but argument 3 has type 'std::set<TABLE_LIST*>::size_type {aka long unsigned int}' [-Wformat=]
sql_print_information("第%d步:侯选驱动表个数:%d,但无法确定驱动表 \n", STEP_CNT++,TABLE_DRIVERD.size());
^
/opt/sqlAdvisor/SQLAdvisor/sqladvisor/main.cc: In function 'int mysql_sql_parse_field_cardinality_new(Item_field*, const char*)':
/opt/sqlAdvisor/SQLAdvisor/sqladvisor/main.cc:604:76: warning: format '%d' expects argument of type 'int', but argument 4 has type 'ulonglong {aka long long unsigned int}' [-Wformat=]
tablename, table_count, rand_rows, field_print, cardinality);
^
[100%] Linking CXX executable sqladvisor
[100%] Built target sqladvisor
root@ubuntu:/opt/sqlAdvisor/SQLAdvisor/sqladvisor# ./sqladvisor
2018-06-13 18:45:10 5781 [ERROR] setlocale 有错

root@ubuntu:/opt/sqlAdvisor/SQLAdvisor/sqladvisor# ./sqladvisor --help
2018-06-13 18:46:11 5783 [ERROR] setlocale 有错`

到最后一步,make后,生成了可以执行的sqladvisor,

执行 ./sqladvisor --help的结果提示错误,如上面所示。

SQLAdvisor/sqladvisor/CMakeList.txt的内容如下:

`root@ubuntu:/opt/sqlAdvisor/SQLAdvisor/sqladvisor# more CMakeLists.txt
cmake_minimum_required (VERSION 2.6)
project(sqladvisor)

include_directories("/usr/local/sqlparser/include")
include_directories("/usr/local/sqlparser/include/regex")
include_directories("/usr/lib/x86_64-linux-gnu/glib-2.0/include")
include_directories("/usr/include/glib-2.0")
link_directories("/usr/local/sqlparser/lib")
link_directories("/usr/lib64")

set(TEST_SRC main.cc)
add_executable(sqladvisor ${TEST_SRC})

target_link_libraries(sqladvisor sqlparser-debug)
target_link_libraries(sqladvisor perconaserverclient_r)
target_link_libraries(sqladvisor glib-2.0)
`

@MingJunDuan
Copy link
Author

root@ubuntu:/opt/sqlAdvisor/SQLAdvisor/sqladvisor# uname -a
Linux ubuntu 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

@IMhirohale
Copy link

楼上问题解决办法: export LC_ALL=en_US.UTF-8
看一下linux的个人家目录下的.bash_profile文件,是否存在问题, LC_ALL,是设置编码显示而已。已经安装成功了。

和这个sqladvisor文件在同一个目录下的main.cc文件的以下代码报的错。
把.bash_profile 中的LC_ALL这个注释掉就可以啦。
总之和这个有关系:LC_ALL

lc = setlocale(LC_ALL, "");
if (NULL == lc) {
sql_print_error("setlocale 有错 \n");
if(sqlparse_path) free(sqlparse_path);
return -1;
}

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