使用g++编译DLL时出现大量错误,寻求解决方案
用g++编译Java项目DLL时出现大量错误
我正在为Java项目构建DLL,使用g++执行编译命令时出现大量错误。执行的命令如下:
g++ -I "C:\Users\my-user\Desktop\jni" # JNI (jni.h, jni_md.h) -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared" # winternl.h依赖头文件 -I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um" # winternl.h所在路径 -shared -o native_lib.dll NativeCall.cpp # 生成目标dll文件
g++提示我的源码、MinGW及winternl.h、winbase.h等Windows头文件存在问题,部分错误信息如下:
NativeCall.cpp:20:39: error: invalid conversion from 'FARPROC' {aka 'int (*)()'} to 'LPVOID' {aka 'void*'} [-fpermissive] 21 | LPVOID lpFuncAddress2 = GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtRaiseHardError"); | ^~~~~~~~~~~~ | | | const wchar_t* c:\mingw\lib\gcc\mingw32\9.2.0\include\c++\bits\istream.tcc:1031:62: error: expected primary-expression before '.' token 1031 | const __ctype_type& __ct = use_facet<__ctype_type>(__in.getloc()); C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um/winbase.h: In function 'long unsigned int InterlockedIncrement(volatile long unsigned int*)': C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um/winbase.h:9326:28: error: '_InterlockedIncrement' was not declared in this scope; did you mean 'InterlockedIncrement'? 9326 | return (unsigned long) _InterlockedIncrement((volatile long*) Addend);
该代码在Visual Studio中可正常运行,请问我哪里操作出错了?
内容的提问来源于stack exchange,提问作者QuanticMeme
相关产品推荐
相关产品推荐

