使用mingw编译ncnn源码时,出现LONG PVOID等未定义
detail | 详细描述 | 詳細な説明
src\cpu.cpp:190:8: error: 'LONG' does not name a type; did you mean 'SING'? static LONG CALLBACK catch_sigill(struct _EXCEPTION_POINTERS* ExceptionInfo) ^~~~ SING C:\Users\DELL\Downloads\ncnn-20240102\src\cpu.cpp: In function 'int detectisa(const void*)': C:\Users\DELL\Downloads\ncnn-20240102\src\cpu.cpp:205:5: error: 'PVOID' was not declared in this scope PVOID eh = AddVectoredExceptionHandler(1, catch_sigill); ^~~~~ C:\Users\DELL\Downloads\ncnn-20240102\src\cpu.cpp:212:36: error: 'eh' was not declared in this scope RemoveVectoredExceptionHandler(eh); ^~ C:\Users\DELL\Downloads\ncnn-20240102\src\cpu.cpp:212:5: error: 'RemoveVectoredExceptionHandler' was not declared in this scope RemoveVectoredExceptionHandler(eh);
cd protobuf-3.4.0\protobuf-3.4.0 F:\protobuf-3.4.0\protobuf-3.4.0\buildMinGW>cmake -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake F:\protobuf-3.4.0\protobuf-3.4.0\buildMinGW>mingw32-make F:\protobuf-3.4.0\protobuf-3.4.0\buildMinGW>mingw32-make install -------------------------------------可以不用opencv,如果使用opencv也需要mingw编译--------------------------------------------------------------- F:>cd ncnn
F:\ncnn>mkdir build
F:\ncnn>cd build
F:\ncnn\build>cmake -G"MinGW Makefiles" -DOpenCV_DIR="D:\Opencv440\buildMinGW\install" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=D:/protobuf-3.4.0/buildMinGW/install/include -DProtobuf_LIBRARIES=D:/protobuf-3.4.0/buildMinGW/install/lib/libprotobuf.a -D Protobuf_PROTOC_EXECUTABLE=D:/protobuf-3.4.0/buildMinGW/install/bin/protoc.exe -D NCNN_VULKAN=OFF -DNCNN_AVX2=OFF -DNCNN_SSE2=OFF .. F:\ncnn\build>mingw32-make install
I try to comment the following code in cpu.cpp (line 190-215) and it works. Though I don't understand why it works.
// static LONG CALLBACK catch_sigill(struct _EXCEPTION_POINTERS* ExceptionInfo)
// {
// if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION)
// {
// g_sigill_caught = 1;
// longjmp(g_jmpbuf, -1);
// }
// return EXCEPTION_CONTINUE_SEARCH;
// }
// static int detectisa(const void* some_inst)
// {
// g_sigill_caught = 0;
// PVOID eh = AddVectoredExceptionHandler(1, catch_sigill);
// if (setjmp(g_jmpbuf) == 0)
// {
// ((void (*)())some_inst)();
// }
// RemoveVectoredExceptionHandler(eh);
// return g_sigill_caught ? 0 : 1;
// }
cmake -G"MinGW Makefiles" -DOpenCV_DIR="D:\opencv\mingw_build\installl" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/install -DProtobuf_INCLUDE_DIR=D:/ncnn20240127/protobuf/mingw_build/install/include -DProtobuf_LIBRARIES=D:/ncnn20240127/protobuf/mingw_build/install/lib/libprotobuf.a -D Protobuf_PROTOC_EXECUTABLE=D:/ncnn20240127/protobuf/mingw_build/install/bin/protoc.exe -D NCNN_VULKAN=OFF -DNCNN_AVX2=OFF -DNCNN_SSE2=OFF -DNCNN_OPENMP=OFF ..