RealTimeChris / DiscordCoreAPI

A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
https://discordcoreapi.com
MIT License
153 stars 17 forks source link

Exe build does not starts correctly #35

Open muratulashozturk opened 1 year ago

muratulashozturk commented 1 year ago

Hello, I've compiled an exe version for the bot and I've moved the files to my Windows 2019 server, I run, and after that, I got the The application was unable to start correctly (0xc0000142) error.

I already installed vc++ redistributable 2022, what else should I install to run the exe build?

Note: the exe works on my main computer which I had the build on.

Bot.exe
Bot.pdb
discordcoreapi.dll
libcrypto-3-x64.dll
libsodium.dll
libssl-3-x64.dll
opus.dll
RealTimeChris commented 1 year ago

Did you copy the .dll files to whichever folder you are running the .exe from?

muratulashozturk commented 1 year ago

Did you copy the .dll files to whichever folder you are running the .exe from?

Well, I mean I got the export and I copied files to the server. What files else do I need to copy?

RealTimeChris commented 1 year ago

This list of .dll files


Bot.exe
Bot.pdb
discordcoreapi.dll
libcrypto-3-x64.dll
libsodium.dll
libssl-3-x64.dll
opus.dll```
muratulashozturk commented 1 year ago

This list of .dll files

Bot.exe
Bot.pdb
discordcoreapi.dll
libcrypto-3-x64.dll
libsodium.dll
libssl-3-x64.dll
opus.dll```

Yes, they are in the directory with the exe.

RealTimeChris commented 1 year ago

Have you tried any of these fixes? https://helpdeskgeek.com/how-to/how-to-fix-the-application-was-unable-to-start-correctly-0xc0000142-error-in-windows/

muratulashozturk commented 1 year ago

Have you tried any of these fixes? https://helpdeskgeek.com/how-to/how-to-fix-the-application-was-unable-to-start-correctly-0xc0000142-error-in-windows/

It didn't work, I will deeply analyze the issue with the dependency walker.

muratulashozturk commented 1 year ago

Still couldn't find the issue. There are a lot of missing dependencies when in VCRUNTIME140.dll when I look it through Dependency walker.

RealTimeChris commented 1 year ago

Hmm interesting. Which version of Visual Studio are you building it with? Maybe try building it with VS2019 instead to see if it runs on Server 2019 more easily?

muratulashozturk commented 1 year ago

Prolly the issue is because of Server 2019, tried with home pc win 10, worked without an issue. Will try with server 2022 today.

muratulashozturk commented 1 year ago

Same result on server 2022 too, I am for sure missing some libraries but I don't know which

RealTimeChris commented 1 year ago

Interesting - this sounds inconvenient.

muratulashozturk commented 1 year ago

Windows reports that the discordcoreapi.dll is faulty. There are missing dependencies for discordcoreapi.dll I think. I'll look on it more

muratulashozturk commented 1 year ago
        const auto _Max_storage_buckets               = static_cast<size_type>(1) << _Max_storage_buckets_log2;

^ Unhandled exception at 0x00007FFE8B9BAC1D (discordcoreapi.dll) in Bot.exe: 0xC000001D: Illegal Instruction.

When I debug the app on the server, It throws the error above. This is really strange. The app works on my friend's computer but on the server not. I don't know which dependencies are missing and can't really locate it too.

RealTimeChris commented 1 year ago

I think this must be due to the AVX instructions that are being used. "Illegal instruction" is what you get when you call one that is not supported.

RealTimeChris commented 1 year ago

I think this means I need to set it up so that you can easily select, at compile time, which instruction set gets used.

muratulashozturk commented 1 year ago

I will try it on Linux too

RealTimeChris commented 1 year ago

Are you running it in a VM by chance?

muratulashozturk commented 1 year ago

Are you running it in a VM by chance?

Nope

muratulashozturk commented 1 year ago

Hello, I saw that you published a new version, could you please try to build an exe and launch it in your free time? It could be helpful if there is an example project and documentation for publishing console exe to host bots on windows servers. @RealTimeChris

RealTimeChris commented 11 months ago

Hello, I saw that you published a new version, could you please try to build an exe and launch it in your free time? It could be helpful if there is an example project and documentation for publishing console exe to host bots on windows servers. @RealTimeChris

https://github.com/RealTimeChris/Bot-Template-For-DiscordCoreAPI This should help you. I just succesfully built and run an executable on Windows.