Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 744 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Creating the sample dll based on documentation #487985
12/14/23 11:12
12/14/23 11:12
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 993
Budapest
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:
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 ==========


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.


Last edited by Aku_Aku; 12/14/23 13:14. Reason: adll.lib
Re: Creating the sample dll based on documentation [Re: Aku_Aku] #487986
12/14/23 13:38
12/14/23 13:38
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hey.

Make sure .dll was loaded, you can see that in your acklog.txt.
Another thing I've noticed in your code above is that you should insert // before your comment in line 5.
Quote
#include "var.h" (only when var class is used)
should be
Quote
#include "var.h" // (only when var class is used)


Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Creating the sample dll based on documentation [Re: Aku_Aku] #487987
12/14/23 22:07
12/14/23 22:07
Joined: Sep 2009
Posts: 993
Budapest
Aku_Aku Offline OP
User
Aku_Aku  Offline OP
User

Joined: Sep 2009
Posts: 993
Budapest
Hey, thanks for your reply.

Of course earlier I fixed that include line and commented out the text, it just remained somehow here.

There is a more interesting thing.
If I commented out the entire include line of var.h the dll is loaded but the result of the ldexpc(10,2) is 40. Maybe I checked that wrong way.
Here is the code:
Code
    var z;
    z = ldexpc(10,2); // calculates x = y * n2
    printf("z: %7.0f",(double)z);


Update: i checked and the result is OK.

But, if the include is not commented out I got still this message: "empty function called in main".

One more thing. The began to work when I created a new project and the type was DLL and not DLL with export.

So, my problem is this: how should use the var.h? or should not?
What is wrong with var.h in my project?

Last edited by Aku_Aku; 12/15/23 12:14.
Re: Creating the sample dll based on documentation [Re: Aku_Aku] #487990
12/16/23 18:52
12/16/23 18:52
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
This is really strange... Usually 'empty function called in main' means that .dll isn't loaded, but we need to find the reason why.
Isn't there a .dll example ready to be compiled in the sdk folder in acknex root folder? Maybe give it a try to find out if it works or not?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1