critical error with my_element.dll

https://www.dacm-logiciels.fr/tracewin
Francesmorard
Beginner
Beginner
Posts: 6
Joined: Fri 6 Mar 2026 13:47
Country:
France (fr)
France

critical error with my_element.dll

Post by Francesmorard »

Dear Didier,

When running my project with my own element in the file my_element.dll, it works only the first try when TraceWin is starting. If I run it a few times because I changed some parameters or something I end up with an error message saying there is a critical error and TraceWin is becoming unstable, then it crash.

I encounter this problem since I'm using Windows, I didn't have this problem with this file under linux format '.so'.

Thanks in advance for your help.
Sophie
Attachments
MEBT.dat
(1.2 KiB) Downloaded 70 times
output_RFQ.dst
(3.84 MiB) Downloaded 68 times
my_elements.dll
(123.14 KiB) Downloaded 64 times
MEBT.ini
(43.77 KiB) Downloaded 63 times
MEBT.cal
(315 Bytes) Downloaded 73 times
User avatar
FranceDidier
Administrator
Administrator
Posts: 1274
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by FranceDidier »

Dear Sophie,

I’ve made some improvements to the DLL format validation in Windows, and using your example, with the new version of TraceWin I now get the message “Is not a valid Win32 application.”
This probably means that the DLL has been built incorrectly or that it calls on 32-bit DLLs when it should be compiled as 64-bit. I can’t say for sure at this stage, but what is certain is that the DLL I provided as an example with the code works. So if you could send me the code for your DLL, I’ll try compiling it myself and perhaps I’ll be able to figure out the problem.

In first time upgrade TraceWin to check, if you have the same message.

Regards,

Didier
Francesmorard
Beginner
Beginner
Posts: 6
Joined: Fri 6 Mar 2026 13:47
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by Francesmorard »

Dear Didier,

I don't have any new update available on TraceWin, so I can't test.
I don't remember how I compile the DLL first time so I did it again in 64-bits for sure. You can find the new version attached to this message.

Best regards,
Sophie
Attachments
my_elements.dll
(378.37 KiB) Downloaded 77 times
User avatar
FranceDidier
Administrator
Administrator
Posts: 1274
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by FranceDidier »

Dear Sophie,

I’ve further improved the detection of issues when loading Windows DLLs by adding dependency detection and checks to ensure they’re present. So, with the latest version of TraceWin (I’ve actually updated it on the website this time), I get the following message when using your DLL:

Code: Select all

Following error occurred :

'[my_elements.dll]

The specified module cannot be found.

libwinpthread-1.dll : Missing dll

From->[ELEMENTS] : My element envelope:Element :16
From->[Calc] : Ref particle transport'
One dll is missing': "libwinpthread-1.dll"
How did you compile it? Which compiler and which options did you use? Could you tell me your command line?
Francesmorard
Beginner
Beginner
Posts: 6
Joined: Fri 6 Mar 2026 13:47
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by Francesmorard »

Dear Didier,

I used mingw64 to compile the file with these commands :

Code: Select all

g++ -m64 -Wall -c MAGNET_ELECTRO_BEND.cxx
g++ -m64 -Wall -c FENTE.cpp
g++ -m64 -shared -static-libgcc -static-libstdc++ -Wl,--export-all-symbols -o my_elements.dll MAGNET_ELECTRO_BEND.o FENTE.o
User avatar
FranceDidier
Administrator
Administrator
Posts: 1274
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by FranceDidier »

Dear Sophie,

I think it depends on your version of moingw64, and I suggest you try these two solutions:
- Add "-static" to the last line of your command
- Find "libwinpthread-1.dll" file and place it alongside your DLL

Regards,

Didier
Francesmorard
Beginner
Beginner
Posts: 6
Joined: Fri 6 Mar 2026 13:47
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by Francesmorard »

Dear Didier,

I use the 15-2-0 version of mingw64.
I tried both solutions and it still doesn't seem to fully work, the critical error still appears randomly.

Regards,
Sophie
User avatar
FranceDidier
Administrator
Administrator
Posts: 1274
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by FranceDidier »

Dear Sophie,

As for me, I haven't encountered any critical errors !
Have you tried the latest version of TraceWin?
Could you send me you cpp file, I'll check that

Regards,

Didier
User avatar
FranceDidier
Administrator
Administrator
Posts: 1274
Joined: Wed 26 Aug 2020 14:40
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by FranceDidier »

Dear Sophie,

Please try my own dll file

Regards,

Didier
my_elements.dll
(2.76 MiB) Downloaded 350 times
Francesmorard
Beginner
Beginner
Posts: 6
Joined: Fri 6 Mar 2026 13:47
Country:
France (fr)
France

Re: critical error with my_element.dll

Post by Francesmorard »

Dear Didier,

Thank you for your file.
Indeed, I don't encounter an error with this one. Which version of MinGW do you use ?

Regards,
Sophie
Post Reply