Qt + iperf3 = lconv 尚未声明

Posted

技术标签:

【中文标题】Qt + iperf3 = lconv 尚未声明【英文标题】:Qt + iperf3 = lconv has not been declared 【发布时间】:2014-01-22 09:04:18 【问题描述】:

对不起我的英语。

我尝试将 iperf3(如静态链接库)添加到我的 Qt 项目(Qt 版本 4.8.5,OpenSuse 13.1)中,但出现了几个错误:

g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I../lperftest -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I../lperf/include -I. -I../lperftest -I. -o main.o ../lperftest/main.cpp
In file included from /usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:41:0,
from /usr/include/c++/4.8/bits/localefwd.h:40,
from /usr/include/c++/4.8/string:43,
from /usr/include/QtCore/qstring.h:54,
from /usr/include/QtCore/qobject.h:48,
from /usr/include/QtCore/QObject:1,
from ../lperftest/main.cpp:9:
/usr/include/c++/4.8/clocale:53:11: error: '::lconv' has not been declared
using ::lconv;
^
/usr/include/c++/4.8/clocale:54:11: error: '::setlocale' has not been declared
using ::setlocale;
^
/usr/include/c++/4.8/clocale:55:11: error: '::localeconv' has not been declared
using ::localeconv;
^
In file included from /usr/include/c++/4.8/bits/localefwd.h:40:0,
from /usr/include/c++/4.8/string:43,
from /usr/include/QtCore/qstring.h:54,
from /usr/include/QtCore/qobject.h:48,
from /usr/include/QtCore/QObject:1,
from ../lperftest/main.cpp:9:
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:52:23: error: 'uselocale' was not declared in this scope
extern "C" __typeof(uselocale) __uselocale;
^
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:52:45: error: invalid type in declaration before ';' token
extern "C" __typeof(uselocale) __uselocale;
^
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h: In function 'int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)':
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:75:53: error: '__gnu_cxx::__uselocale' cannot be used as a function
__c_locale __old = __gnu_cxx::__uselocale(__cloc);
^
/usr/include/c++/4.8/x86_64-suse-linux/bits/c++locale.h:100:33: error: '__gnu_cxx::__uselocale' cannot be used as a function
__gnu_cxx::__uselocale(__old);
^
../lperftest/main.cpp: At global scope:
../lperftest/main.cpp:11:5: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char *argv[])
^
../lperftest/main.cpp:11:5: warning: unused parameter 'argv' [-Wunused-parameter]
make: *** [main.o] Error 1

当我尝试将 iperf3 添加到唯一的 C++ 项目时,一切都很好。此错误仅存在于 Qt 项目中。有什么想法吗?

【问题讨论】:

这似乎是问题所在:***.com/a/17040165/1518921 但是你不能确定你是否不发布代码。 【参考方案1】:

我对 iperf3 和 Qt 有同样的问题。基本上,您似乎必须对 iperf3 库和您的项目(gcc 或 g++)使用类似的编译。

让我们知道进展如何。或者如果已经完成,请分享您的解决方案。

-- 编辑-- 或对 iperf_api.h 执行以下操作

extern "C" 
#include <iperf_api.h>

【讨论】:

以上是关于Qt + iperf3 = lconv 尚未声明的主要内容,如果未能解决你的问题,请参考以下文章

Qt 不承认声明的类

朋友声明声明了一个非模板函数[重复]

Qt 在线程中使用QCamera以及ffmpeg进行视频流推送出现(尚未调用 CoInitialize) 解决办法

安装iperf3

iperf3

iperf3