I have a Java program which makes use of some native function calls to speed up video encoding. It requires a DLL, which I will write in C (I have just a test one right now).
When I compile the DLL with cl /I "java-path/include" /"java-path/include/win32" -DL -ML Main.c -FeTest.dll
it compiles, but I get a 32-bit DLL. After I did some research on the internet, I found out that I would need a 64-bit DLL instead.
After more research, I have found this post which is the only one for C (even C++ was hard to find), but this only works if you are writing/building via Visual Studio 2010. I am using Elipse for the Java, CLion for the C, and compiling via the "Developer Command Prompt." so this does not work for me. How might I recompile as a 64-bit DLL?
EDIT: I am using the cl.exe
that comes with Visual Studio 2017
UPDATE: I found the 64-bit cl.exe
under C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.13.26128\bin\Hostx64\x64\cl.exe
, however when running it, I get an error that the library machine type (x86) conflicts with the target type (x64). How do I change the library machine type?
As I explained at the beginning of [SO]: How to build a DLL version of libjpeg 9b? (@CristiFati's answer) (bullets from 1. Prepare the ground section), there are different ways to deal with building from command line in VStudio.
I'm going to focus on vcvarsall.bat. More details on [MSDN]: Setting the Path and Environment Variables for Command-Line Builds (It's VStudio2015 as VStudio2017 link is broken).
I prepared a dummy example.
code.c:
Build:
Notes: