Author Topic: missing dlls in Codeblocks-20.03mingw- Solved  (Read 1896 times)

Offline bdad

  • Multiple posting newcomer
  • *
  • Posts: 29
missing dlls in Codeblocks-20.03mingw- Solved
« on: December 09, 2022, 12:40:29 am »
I've installed https://www.fosshub.com/Code-Blocks.html?dwl=codeblocks-20.03mingw-setup.exe  from the fosshub site, and a week or so ago from sourceforge. on my w10 pc In total, I've tried installing it four or five times.

I can debug my c++ code OK, and run and compile it from within code-blocks ide, but when I try to run the .exe stand-alone, it gives a couple of error messages referring to absent dll's. It suggests reinstalling the program. That does nothing to improve the situation. If I find these dlls, in which directory should they be placed? Does it mean that if I use the .exe on another pc, I will have to include the .dll's as well? Will different exes require different dlls? I hope not, as it is just a console app. with a bit of disk i/o.

This is the ide and c++/c/fortran simple combined install package, linked from your site.  I am new to code blocks, and not up to speed with c++, but the installation process involved nothing fancy, and I was surprised it is not working  for me straight out of the box, so to speak.
« Last Edit: December 10, 2022, 10:08:08 pm by bdad »

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1487
Re: missing dlls in Codeblocks-20.03mingw-
« Reply #1 on: December 09, 2022, 09:29:22 am »
All programs you write are linked dinamically by MinGW (not Code::Blocks, it does not link because it is an IDE) to two or three MinGW's DLL: libgcc, libstdc++ and (possibly) libwinpthread. For your program to work stand alone, you must copy said DLLs from the MinGW's lib folder to the folder where your exe is.

Other option is to link statically the libraries. This method may have license issues, but not technical ones. Goto Project -> Build options -> Compiler settings tab and check "Static libgcc", "Static libstdc++" and, if needed, "Static linking".

Offline gd_on

  • Lives here!
  • ****
  • Posts: 791
Re: missing dlls in Codeblocks-20.03mingw-
« Reply #2 on: December 09, 2022, 03:32:01 pm »
An other solution, for your own PC, is to add the path of the dlls (something like C:\MinGW\bin or C:\program files\codeblocks\mingw\bin) to your PATH system variable. This avoid multiples copies of theses dlls.
But to execute the exe on another PC, add the dlls in the directory where your exe is (except if the other PC has also MinGW installed, preferably with the same version.
Something you should understand is that Code::Blocks adds this path for it's own usage, but only temporarily. It's why inside C::B your code works.
« Last Edit: December 09, 2022, 05:16:03 pm by gd_on »
Windows 11 64 bits (22H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline bdad

  • Multiple posting newcomer
  • *
  • Posts: 29
Re: missing dlls in Codeblocks-20.03mingw-
« Reply #3 on: December 09, 2022, 05:16:59 pm »
Thanks for your answers. Coming from visual studio and windows, I did not realise that extra dll's needed to be included (I wanted to get away from .net type stuff). I've followed Miguel's reply wrt static linking, and that worked nicely. As the software is for my own use, I guess the licensing requirements will not apply. I noticed, once I'd rebooted codeblocks and recompiled, the exe in the release directory was larger than before, and in fact larger than that in the debug directory, although previously it was smaller, and it now ruins fine, stand-alone. As it happens, the same program, compiled in visual studio, is considerably smaller, I guess it uses links directly into the windows system.

As an aside, I've tried on four occasions, different email addresses to register with cplusplus.com forum. I do not get the email, and no reply to their inquiry form.  It seems it is broken, wrt new registrations, If either of you are members, any chance you could pm an admin or something. No problem registering here, on this code blocks forum.