Code::Blocks Forums

User forums => Help => Topic started by: Brissou72 on December 15, 2022, 03:12:45 pm

Title: can't execute .exe in bin folder 0xc000007b
Post by: Brissou72 on December 15, 2022, 03:12:45 pm
Hello I ve just finished a small program. I can build it and run directly from codeblocks and it works perfectly. But when i try to use the exe, it tells me "0xc000007b" before that I ve had to add dll file in the exe folder (libgcc_s_seh-1.dll and libwinpthread-1.dll).

I don't know if it is important but for my program i used :
#include <windows.h> , #include <stdio.h>, #include <tchar.h>, #include <psapi.h>, #include <chrono>, #include <thread>, #include <functional>
linkers Kernel32.lib and psapi.lib.

It s not depending on my machine, because it does the same on every machine.

Thanks for your help.






Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: Miguel Gimenez on December 15, 2022, 03:27:41 pm
You are mixing 64 and 32-bit code, replace the DLLs with other versions using the same bitness of the executable.
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: Brissou72 on December 15, 2022, 06:08:41 pm
Hello, so basically bitness of executable is 64. but there is 1 dll i cannot find in 64 so I ve tried to switch my exe in 32, but at this moment on CB it gives me a lot of compiling errors ("cannot find"):

ld.exe||cannot find -lstdc++|
ld.exe||cannot find -lmingw32|
ld.exe||cannot find -lgcc|
ld.exe||cannot find -lgcc_eh|
ld.exe||cannot find -lmoldname|
ld.exe||cannot find -lmingwex|
ld.exe||cannot find -lmsvcrt|
ld.exe||cannot find -lpthread|
ld.exe||cannot find -ladvapi32|
ld.exe||cannot find -lshell32|
ld.exe||cannot find -luser32|
ld.exe||cannot find -lkernel32|
ld.exe||cannot find -liconv|
ld.exe||cannot find -lmingw32|
ld.exe||cannot find -lgcc|
ld.exe||cannot find -lgcc_eh|
ld.exe||cannot find -lmoldname|
ld.exe||cannot find -lmingwex|
ld.exe||cannot find -lmsvcrt|

i m little bit lost...
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: gd_on on December 15, 2022, 06:25:05 pm
If a program work inside codeblocks but fails when you launch it as standalone (outside codeblocks) this clearly indicates that something is missing in the system path : have a look in logs & other window : you can see that C::B displays the path it uses for itself when a program is launched.
I suggest to add in your system path, the bin folders of your compiler : it contains all the needed dll. Don't switch to 32 bits if you have not installed a 32 bits compiler, it won't work.
An other solution, is to add the needed dlls in the same folder than your exe. Nice if you want to distribute your program, but not for using on your computer for several programs (you'll have many copies of the same dlls ...)
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: Brissou72 on December 15, 2022, 07:16:32 pm
OK tanks for your advice, i switched back to 64 bit and put the 2 dll files in the exe directory and go back to the error "0xc000007b".
libwinpthread-1.dll is 32 bits.
libgcc_s_seh-1.dll is 32 bits.
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: Brissou72 on December 15, 2022, 07:17:12 pm
libgcc_s_seh-1 64 bit sorry
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: gd_on on December 15, 2022, 07:25:44 pm
So, you say that you have 32 bits dlls and 64 bits dlls in the same directory ? I'm not sure it works.
Which compiler did you install ? and where ?
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: Brissou72 on December 15, 2022, 10:12:23 pm
So now i have fixed the problem of DLL by adding the DLL directly in C:\MinGW\bin but still the 0xc000007b
In "setting", "compiler", the selected compiler is GNU GCC compiler.
I noticed that under codeblocks i can only select target debug if i choose release then following :
"EnumProcessModules", "GetModuleBaseNameA", and "EnumProcesses" are in errors as undefined references.
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: Brissou72 on December 15, 2022, 10:14:01 pm
and compiler install directory is C:\Program Files\CodeBlocks\MinGW
Title: Re: can't execute .exe in bin folder 0xc000007b
Post by: Brissou72 on December 16, 2022, 08:26:24 am
Hello Finally I found out my problem... but i would libe to be more explained (basically my job is automation of industrial plants, so i m not specialist)

So I noticed I had to folder of compiler in my system (C:\Program Files\CodeBlocks\MinGW and C:\MinGW\). When I copy in "exe folder" bin folder of C:\MinGW\ it does not work but when i copy C:\Program Files\CodeBlocks\MinGW it works !

My configuration of compiling in CB points to C:\Program Files\CodeBlocks\MinGW. But yesterday i ve noticed that when i put the missing dll to C:\MinGW\ i was not noticed of missing dll but error 0xc000007b, i assume that if I copy the C:\Program Files\CodeBlocks\MinGW to C:\MinGW\ it will work without copying the bin file to "exe folder". So I don't understand what is the reason as i m configured with codeblocks to work with C:\Program Files\CodeBlocks\MinGW.

Thank you very much for your help and your explainations.