小编caf*_*ine的帖子

如何在Qt Creator上使用libCURL和MSVC2012作为编译器

我已经在我的系统上安装了qt-windows-opensource-5.1.1-msvc2012-x86_64-offline

一切正常,但我不能在我的Qt项目中使用libCurl.

我已经下载了这个版本的libcurl:http: //curl.haxx.se/download/libcurl-7.19.3-win32-ssl-msvc.zip

MSVC metalink   7.19.3  devel   SSL         Frederic Elbin  4.04 MB
Run Code Online (Sandbox Code Playgroud)

我已将包含文件夹从存档移动到VC包含文件夹,并且我已将其包含在#include的程序中并且运行良好.

现在在lib文件夹上还有另外两个名字的文件夹:Debug和Release,两者都有一些文件.

在我的.pro文件中,我添加了:

win32: LIBS += -L$$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/ -llibcurl_imp

INCLUDEPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc
DEPENDPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/release/ -lcurllib
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/debug/ -lcurllib

INCLUDEPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/Debug
DEPENDPATH += $$PWD/../../../../../libcurl-7.19.3-win32-ssl-msvc/lib/Debug
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试运行一个简单的程序时,我得到了:

mainwindow.obj:-1: error: LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function "private: void __cdecl MainWindow::on_pushButton_clicked(void)" (?on_pushButton_clicked@MainWindow@@AEAAXXZ)
Run Code Online (Sandbox Code Playgroud)

在下载的存档上还有更多其他文件:http://img13.imageshack.us/img13/1416/reh8.png

可能我现在包括libs很好(内部/外部或动态/静态),我不知道要包含哪一个以及如何包含.并且还有一些.dll文件,我不知道该怎么做.

有人在Qt项目上成功使用了libcurl吗?我是Qt的初学者,对我来说很难......

谢谢.

c++ qt curl libcurl

6
推荐指数
1
解决办法
2560
查看次数

访问C++类中的C风格回调

PiGPIO库提供以下C风格的API函数:

typedef void (*gpioAlertFuncEx_t)(int, int, uint32_t, void *);  // assumed  
int gpioSetAlertFuncEx(unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata)
Run Code Online (Sandbox Code Playgroud)

基本上它允许您通过回调函数处理引脚状态更改.

到现在为止还挺好.问题是将此回调包装到c ++类中.

我的方法如下:

class Pin
{
public:
    Pin(_GpioPin)
    {
        gpioSetAlertFuncEx(_GpioPin, &PushButton::internal_gpio_callback, this );
    }

    void internal_callback_func(int pin, int level, uint32_t tick)
    {
        cout << "New level: " << pin << " " << level;
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是回调函数类型不同(因为它是非静态的).并且提示错误:

 error: cannot convert 'void (Pin::*)(int, int, uint32_t, void*) {aka void (Pin::*)(int, int, unsigned int, void*)}' to 'gpioAlertFuncEx_t {aka void (*)(int, int, unsigned int, void*)}' for …
Run Code Online (Sandbox Code Playgroud)

c c++ pointers member-function-pointers callback

0
推荐指数
1
解决办法
133
查看次数

使用MinGW或VS2012编译器在Qt上启用C++ 11支持

我刚刚安装了QtSDK,我有一些问题,我正在尝试使用正则表达式函数.

编译程序时出现此错误:

#error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This supports currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
Run Code Online (Sandbox Code Playgroud)

我试图在我的项目文件中添加它:

QMAKE_CXXFLAGS += -std=c++0x
Run Code Online (Sandbox Code Playgroud)

QMAKE_CXXFLAGS += -std=gnu++0x
Run Code Online (Sandbox Code Playgroud)

但我得到更多其他错误.在Code :: Blocks正则表达式工作正常,也使用MinGW.那么如何在QtSDK上使用C++ 11工具呢?

c++ regex qt c++11

-1
推荐指数
1
解决办法
2684
查看次数

标签 统计

c++ ×3

qt ×2

c ×1

c++11 ×1

callback ×1

curl ×1

libcurl ×1

member-function-pointers ×1

pointers ×1

regex ×1