VC++编译报错
wanghuan9909 发布于2018-08 浏览:1408 回复:1
0
收藏
快速回复

    下载的是文字识别的aip-cpp-sdk-0.6.0,VC++2012新建了一个测试工程,在工程中也添加了相关的头文件包含路径和库的包含路径,以及依赖的库json_vc71_libmtd.lib和
libcurld.lib,然后按照官网公布的,先加入以下几行代码:

#include "ocr.h"

// 设置APPID/AK/SK
std::string app_id = "你的 App ID";
std::string api_key = "你的 Api key";
std::string secret_key = "你的 Secret Key";

aip::Ocr client(app_id, api_key, secret_key);

     编译,发现报错,具体如下:

1>------ Build started: Project: generalOCR, Configuration: Debug x64 ------
1> generalOCRDlg.cpp
1>F:\AI\baidu\aip-cpp-sdk-0.6.0\ocr.h : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(37): error C2864: 'aip::HttpClient::debug' : only static const integral data members can be initialized within a class
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(38): error C2864: 'aip::HttpClient::connect_timeout' : only static const integral data members can be initialized within a class
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(39): error C2864: 'aip::HttpClient::socket_timeout' : only static const integral data members can be initialized within a class
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(93): error C2065: 'default' : undeclared identifier
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(93): error C2253: 'HttpClient' : pure specifier or abstract override specifier only allowed on virtual function
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(95): error C2059: syntax error : ';'
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(95): error C2238: unexpected token(s) preceding ';'
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(96): error C2059: syntax error : ';'
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\http.h(96): error C2238: unexpected token(s) preceding ';'
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\base64.h(100): warning C4267: '=' : conversion from 'size_t' to 'unsigned char', possible loss of data
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\base64.h(117): warning C4267: '=' : conversion from 'size_t' to 'unsigned char', possible loss of data
1>f:\ai\baidu\aip-cpp-sdk-0.6.0\base\utils.h(21): fatal error C1083: Cannot open include file: 'openssl/evp.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

      看了一下http.h中的确有以下代码:

......

class HttpClient
{
private:
bool debug = false;
int connect_timeout = 10000;
int socket_timeout = 10000;

......

     按照我对C++的语法,这里的确是有问题的,可是这个http.h是百度官网公布的sdk里面的头文件,照理是不会错的,请问大家怎么解释这个编译错误呀?是因为我的工程设置哪里出问题了吗?该怎么改?

收藏
点赞
0
个赞
共1条回复 最后由用户已被禁言回复于2022-04
#312121212h266回复于2018-08

请问你的好使了吗

0
TOP
切换版块