Posted By: Aku_Aku
Creating the sample dll based on documentation - 12/14/23 11:12
Hi!
Finally I started to learn/work with dlls related to acknex.
Based on the Part: Plugin SDK in the Chapter: Gamestudio SDK of the documentation I created a solution/project in Visual Studio 2022.
I set the configuration to Release/x86 and the project type is DLL with exports. I named the project to: Ack_Prob_1. The VS created some skeleton files for me.
The dllmain.cpp looked like this:
Based on the documentation I changed to this:
I added the adll.lib to the Additional Library property.
I didn't touch the Ack_Prob_1.cpp and built the project. I have got these messages:
I seems to me OK, so I created a Gamestudio source like this and put into the directory the dll file:
When I run the program I got this message:
After i clicked on the OK button the printf sent this output: x: 0.
What is wrong with these above?
How should fix?
Thanks in advance.
Finally I started to learn/work with dlls related to acknex.
Based on the Part: Plugin SDK in the Chapter: Gamestudio SDK of the documentation I created a solution/project in Visual Studio 2022.
I set the configuration to Release/x86 and the project type is DLL with exports. I named the project to: Ack_Prob_1. The VS created some skeleton files for me.
The dllmain.cpp looked like this:
Code
// dllmain.cpp : Defines the entry point for the DLL application. #include "pch.h" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
Based on the documentation I changed to this:
Code
// dllmain.cpp : Defines the entry point for the DLL application. #include "pch.h" #include < math.h > #define DLL_USE #include "var.h" (only when var class is used) #include "adll.h" BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } engine_bind(); return TRUE; } // returns the value of x * 2n DLLFUNC var ldexpc(var x, var n) { return (_VAR(_FLOAT(x) * pow(2.0, _FLOAT(n)))); }
I added the adll.lib to the Additional Library property.
I didn't touch the Ack_Prob_1.cpp and built the project. I have got these messages:
Quote
Build started at 11:51 AM...
1>------ Build started: Project: Ack_Prob_1, Configuration: Release Win32 ------
1>pch.cpp
1>Ack_Prob_1.cpp
1>dllmain.cpp
1>C:\Users\user\source\repos\Ack_Prob_1\dllmain.cpp(5,10): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>(compiling source file '/dllmain.cpp')
1> Creating library C:\Users\user\source\repos\Ack_Prob_1\Release\AckProb1.lib and object C:\Users\user\source\repos\Ack_Prob_1\Release\AckProb1.exp
1>Previous IPDB not found, fall back to full compilation.
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Generating code
1>All 12 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
1>Finished generating code
1>Ack_Prob_1.vcxproj -> C:\Users\user\source\repos\Ack_Prob_1\Release\AckProb1.dll
1>Done building project "Ack_Prob_1.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 11:51 AM and took 06.455 seconds ==========
1>------ Build started: Project: Ack_Prob_1, Configuration: Release Win32 ------
1>pch.cpp
1>Ack_Prob_1.cpp
1>dllmain.cpp
1>C:\Users\user\source\repos\Ack_Prob_1\dllmain.cpp(5,10): warning C4067: unexpected tokens following preprocessor directive - expected a newline
1>(compiling source file '/dllmain.cpp')
1> Creating library C:\Users\user\source\repos\Ack_Prob_1\Release\AckProb1.lib and object C:\Users\user\source\repos\Ack_Prob_1\Release\AckProb1.exp
1>Previous IPDB not found, fall back to full compilation.
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>Generating code
1>All 12 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
1>Finished generating code
1>Ack_Prob_1.vcxproj -> C:\Users\user\source\repos\Ack_Prob_1\Release\AckProb1.dll
1>Done building project "Ack_Prob_1.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 11:51 AM and took 06.455 seconds ==========
I seems to me OK, so I created a Gamestudio source like this and put into the directory the dll file:
Code
function ldexpc(x,n); // declaration of a DLL function in lite-C function main() { int x; x = ldexpc(10,2); // calculates x = y * 2n printf("x: %d",x); }
When I run the program I got this message:
Quote
empty function called in main
After i clicked on the OK button the printf sent this output: x: 0.
What is wrong with these above?
How should fix?
Thanks in advance.