Author Topic: exe can't find dll  (Read 9045 times)

Offline profSteve

  • Single posting newcomer
  • *
  • Posts: 4
exe can't find dll
« on: March 31, 2021, 01:37:29 pm »
I'm new to Code::Blocks.  I selected GNUGCC as my compiler.   I'm running Windows 10 on a plain vanilla Dell desktop computer.
 The first code I wrote, builds and runs without any problem within the IDE.  But when I try to execute the standalone .exe (which I found in the project's debug folder) I get two error messages:   "can't find libstdc++-6.dll"  and   "can't find libgcc_s_seh-1.dll"   [both with a suggestion that reinstalling the program might help].  I found these two  dll files , both in three places on my hard drive:
     (1) C:\programFiles\Codeblocks
     (2) C:\programFiles\Codeblocks\mingw\bin
     (3) C:\programFiles\Codeblock\mingw\bin\x86_64-mingw32\lib
So I went to Settings > compiler > searchDirectories and entered these three directories. 
 This didn't solve the problem:  when I execute the exe I still get the same two error messages.
  I would be grateful if someone can explain this to me.  Shall I uninstall Code::Blocks and then reinstall it? 
   Thanks in advance for any advice.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1633
Re: exe can't find dll
« Reply #1 on: March 31, 2021, 01:59:47 pm »
The quickest solution is copying those DLL from (2) or (3) to the Debug folder.
Other options are adding (2) to your path or linking statically with them (see compiler options)

Offline profSteve

  • Single posting newcomer
  • *
  • Posts: 4
Re: exe can't find dll
« Reply #2 on: April 01, 2021, 12:38:52 am »
Miguel -
   Thanks for your suggestions.  I tried three things:
    (1)  I copied both dll files to   [myProj]\bin\debug  and to   [myProj]\obj\debug .   
    (2)  I added  C:\programFiles\Codeblocks\mingw\bin   to my LinkSettings and to my Search Directories
    (3)  I uninstalled Code::Blocks  and then reinstalled it.

None of these things worked.  My code runs flawlessly from inside the IDE, but when I execute the exe file I get two "can't find dll" messages.
  Any other suggestions ?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7680
    • My Best Post
Re: exe can't find dll
« Reply #3 on: April 01, 2021, 12:52:32 am »
Miguel -
   Thanks for your suggestions.  I tried three things:
    (1)  I copied both dll files to   [myProj]\bin\debug  and to   [myProj]\obj\debug .   
    (2)  I added  C:\programFiles\Codeblocks\mingw\bin   to my LinkSettings and to my Search Directories
    (3)  I uninstalled Code::Blocks  and then reinstalled it.

None of these things worked.  My code runs flawlessly from inside the IDE, but when I execute the exe file I get two "can't find dll" messages.
  Any other suggestions ?

You failed to understand the directions; I will post how I think it should be done and maybe it will help.

1. Copy the needed DLLs to the same folder as the exe you are running is located.
2. Edit the Windows PATH variable (This has nothing to do with any Code::Blocks setting) to include the location of the DLLs

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline profSteve

  • Single posting newcomer
  • *
  • Posts: 4
Re: exe can't find dll
« Reply #4 on: April 01, 2021, 03:44:59 am »
Yes !!!  That solves my problem.  Tim, you are right in saying I misunderstood Miguel's instruction to add the dll files "to your path."  I thought he meant CodeBlock settings Search Directories.  When I add the relevant folders to my Windows Path, those error messages don't appear and my exe executes perfectly.
  Thanks to you both, Miguel and Tim, for educating me on this.