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

Visual Studio 2019 C++预测库编译问题 #3532

Closed
before31 opened this issue Aug 4, 2021 · 3 comments
Closed

Visual Studio 2019 C++预测库编译问题 #3532

before31 opened this issue Aug 4, 2021 · 3 comments
Assignees

Comments

@before31
Copy link
Contributor

before31 commented Aug 4, 2021

可能是由于 #3418 已经close,我在那里留言没有人理会, 所以单独发一个issue。
在该issue中, @Phymin 提了两个问题:
1、dirent.h文件找不到的问题
2、deploy\cpp_infer\src\config.cpp 24、27行报“表达式的计算结果不是常数”的问题
#3422 更新中只解决了问题1,未提及问题2。对于问题2,我尝试修改如下,不知是否稳妥:
`
int strlen = str.length() + 1;
char *strs = new char[strlen];
std::strcpy(strs, str.c_str());

int delimlen = delim.length() + 1;
char *d = new char[delimlen];
std::strcpy(d, delim.c_str());
`

按上述代码进行修改以后,问题2已解决。但又出现另外一个错误(问题3):
deploy\cpp_infer\src\utility.cpp 70行: “lstat”: 找不到标识符
我的解决方案是把lstat改成stat(去掉l),编译不再报错。

但会有72个链接错误,主要是LNK2038 和 LNK2001(问题4)。查了一些资料并且读了一下CMakeLists.txt文件,发现应该还需要修改CMAKE_BUILD_TYPE参数为Release才可以(默认是Debug)。
以上。

@before31
Copy link
Contributor Author

before31 commented Aug 4, 2021

抱歉,刚更新了代码,发现config.cpp已经在7月9号修复了问题2。
所以麻烦只确认一下问题3和问题4。

@MissPenguin
Copy link
Collaborator

MissPenguin commented Aug 5, 2021

您好,问题2你补充的代码中需要释放new创建的变量,可参考此pr:https://github.com/PaddlePaddle/PaddleOCR/pull/3553/files。
问题3已经修复了;
问题4在编译的时候需要设置Release模式。

@before31
Copy link
Contributor Author

before31 commented Aug 7, 2021

感谢回复。
对于问题4,如果我需要在vs中调试代码呢?应该如何设置?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants