So, I'm trying to build a DLL for a Java project I'm working on and when I'm trying to tell g++ to build a DLL, it spits out a bunch of errors.
This is the command I tried
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" # Headers for winternl.h
-I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um" # Location of winternl.h
-shared -o native_lib.dll NativeCall.cpp # This should create a dll?
g++ tells me that somehow something is wrong in my source code, in MinGw and windows header files like winternl.h and winbase.h. Here are a few errors g++ outputted in the command prompt:
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);
I tested my code in Visual Studio and it worked just fine. The entire error
Anybody got an idea what I'm doing wrong?