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

cmake vs2015编译报错 #283

Closed
batchsize opened this issue Mar 5, 2018 · 10 comments
Closed

cmake vs2015编译报错 #283

batchsize opened this issue Mar 5, 2018 · 10 comments

Comments

@batchsize
Copy link

batchsize commented Mar 5, 2018

我参照https://github.com/Tencent/ncnn/wiki/cmake-VS2017-%E7%BC%96%E8%AF%91 用vs2015编译时,在nmake 命令后benchmark处出现错误,有人遇到吗?下面是错误代码:

[  1%] Building CXX object src/CMakeFiles/ncnn.dir/benchmark.cpp.obj
benchmark.cpp
d:\workspace\fld\ncnn-master\src\mat.h(333): warning C4267: “初始化”: 从“size_t”转换到“int”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xlocale(150): error C3861: “_InterlockedIncrement”: 找 不到标识符
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xlocale(155): error C3861: “_InterlockedDecrement”: 找 不到标识符
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(50): error C2079: “tp”使用未定义的 struct“ncnn::get_current_time::timeval”
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(52): error C2228: “.tv_sec”的左边必须有类/结构/联合
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(52): note: 类型是“int”
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(53): error C2228: “.tv_usec”的左边必须有类/结构/联合
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(53): note: 类型是“int”
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(55): error C2065: “tv”: 未声明的标识符
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(55): error C2228: “.tv_sec”的左边必须有类/结构/联合
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(55): note: 类型是“unknown-type”
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(55): error C2228: “.tv_usec”的左边必须有类/结构/联合
D:\workspace\FLD\ncnn-master\src\benchmark.cpp(55): note: 类型是“unknown-type”
NMAKE : fatal error U1077: “C:\PROGRA~2\MICROS~4.0\VC\bin\amd64\cl.exe”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"”: 返回代码“0x2”
Stop.
@egg53231323
Copy link

benchmark.cpp 的windows实现似乎有些问题。timeval未定义,几个变量似乎应该用的tp但写的tv。用vs2015编译应该是想用model转换工具吧。把benchmark.cpp整个文件暂时注释掉其实就行了,我这么编译过了。完整的修改等作者修改吧。。。。。。。。

@nihui
Copy link
Member

nihui commented Mar 5, 2018

5f0fa95

更新验证下...

@batchsize
Copy link
Author

更新代码还是没有编译过

@nihui
Copy link
Member

nihui commented Mar 6, 2018

emmmm,还有问题...

@nihui
Copy link
Member

nihui commented Mar 6, 2018

5e484a4

第二次...
麻烦验证下

@batchsize
Copy link
Author

batchsize commented Mar 6, 2018

非常感谢@nihui,@egg532 。
第二次更新后解决了“tp未定义的问题”,还出现了这个错误:

[  2%] Building CXX object src/CMakeFiles/ncnn.dir/benchmark.cpp.obj
benchmark.cpp
d:\workspace\fld\ncnn-master\src\mat.h(333): warning C4267: “初始化”: 从“size_t”转换到“int”,可能丢失数据
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xlocale(150): error C3861: “_InterlockedIncrement”: 找 不到标识符
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xlocale(155): error C3861: “_InterlockedDecrement”: 找 不到标识符
NMAKE : fatal error U1077: “C:\PROGRA~2\MICROS~4.0\VC\bin\amd64\cl.exe”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"”: 返回代码“0x2”
Stop.
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"”: 返回代码“0x2”
Stop.

我参照https://msdn.microsoft.com/en-us/library/windows/desktop/ms683614(v=vs.85).aspx 在benchmark.h 添加了 #include<Windows.h> ,编译通过。 不知道这是不是解决办法

@liandaoacc
Copy link

benchmark.cpp做如下修改可以编译通过

原来的

#include "benchmark.h"

#if NCNN_BENCHMARK
#include <stdio.h>
#include "layer/convolution.h"
#endif // NCNN_BENCHMARK

#ifdef _WIN32

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdint.h> // portable: uint64_t   MSVC: __int64
#else // _WIN32
#include <sys/time.h>
#endif // _WIN32

修改后

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdint.h> // portable: uint64_t   MSVC: __int64
#else // _WIN32
#include <sys/time.h>
#endif // _WIN32

#include "benchmark.h"

#if NCNN_BENCHMARK
#include <stdio.h>
#include "layer/convolution.h"
#endif // NCNN_BENCHMARK

@HeiSir2014
Copy link

HeiSir2014 commented Mar 14, 2018

我验证了下,和 #include<string> #include "mat.h"的顺序有关,索性我就把 string 加到mat.h 里面就可以解决了。具体不知道啥原因。

File:mat.h

#ifndef NCNN_MAT_H
#define NCNN_MAT_H
#include <stdlib.h>
#include <string>
//#include <string.h>
#if __ARM_NEON
#include <arm_neon.h>
#endif

@nihui
Copy link
Member

nihui commented Apr 7, 2018

fixed in 3977d32

@nihui nihui closed this as completed Apr 7, 2018
@zeyuanlicbpm
Copy link

编译通过,但是使用ncnn.lib的过程中还是报相同的错误!

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

6 participants