Login Page - Create Account

Support Board


Date/Time: Sun, 29 Dec 2024 14:52:48 +0000



How to Call DllMain() from an Additional Object File

View Count: 901

[2016-04-30 16:05:47]
Pinger - Posts: 33
Hi

I'm building a custom study with an additional object file 'myfunctions.o' by including it as an Additional Compiler Parameter. The study appears to build OK. However 'myfunctions.o' contains a DllMain function which doesn't appear to be called when the study is loaded. I have decorated DllMain with __declspec(dllexport) in 'myfunctions.o', and doing an 'objdump -x' of my study DLL lists DllMain as an exported function, but DllMain appears not to be being called. Any suggestions help would be appreciated.
[2016-04-30 18:15:05]
Sierra Chart Engineering - Posts: 104368
To our knowledge there can only be one DLL Main function that the entire DLL itself has.

This is something that you will have to understand and solve on your own.

We recommend using another compiler like Visual C++ and accomplishing what you want if it is possible.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2016-05-02 16:39:19
[2016-04-30 19:19:20]
Sierra Chart Engineering - Posts: 104368
Also, when adding additional libraries we think you need to use a library file (.lib) and not an object file.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2016-05-02 14:05:47]
Pinger - Posts: 33
Thanks for your swift replies.

I have decided to create a DLL file containing my additional functions and use the LoadLibrary()/GetProcAddress() to load it into my study and call my functions. This appears to work well, my DllMain function is called successfully. This is quite a neat solution, although I now need to copy both my study and additional functions DLL's to my VPS (this is what I was initially hoping to avoid).

A follow up question...

My study loads my DLL and works well on my local machine, but when I transfer them to my VPS my functions cause CPU exceptions. Do I need to use the same compiler flags when compiling my DLL that SierraChart uses when compiling my study? I'm guessing the answer to this is, yes.

Cheers
[2016-05-02 16:41:11]
Sierra Chart Engineering - Posts: 104368
Do I need to use the same compiler flags when compiling my DLL that SierraChart uses when compiling my study?
Not necessarily. Also, are you using different compilers? This is not clear.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2016-05-02 17:30:18]
Pinger - Posts: 33
Hi

Thanks for your reply.

I'm using a separate installation of MinGW to compile my additional functions DLL which is written in C.

I have added the "-march=i686", "-mtune=i686" and "-static-libgcc" compiler options to my Makefile and everything is working fine on both my local machine and VPS. I have put my DLL in /C/SierraChart/Data. (My VPS doesn't have a compiler installed).

I take it all 3 compiler options mentioned above are required? Any further suggestions?

Cheers
[2016-05-02 18:17:21]
Sierra Chart Engineering - Posts: 104368
We would recommend exactly the same compiler settings in this case.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account