Executable built with VS2010 does not find DLLs in System32 - c

I recently built a project on VisualStudio. I got an executable in the bin folder and I put all the dependencies x64 DLL in C:\Windows\System32 and all the x32 DLL in C:\Windows\SysWOW64
When I execute my executable, I get an error message This program can't start because foo.dll is missing from your computer.
I tried to get the dependencies with ldd.exe on Cygwin, but I don't see any references to foo.dll. I also tried to execute from PowerShell Start-Process -PassThru sample.exe, but I still get the same error message.
Where does Windows executables look for DLLs?
I've read that a Windows executable will look for its dependencies in a certain order:
In the local folder
In System32
In the %PATH%
I also read that I may need to use regsvr32.exe to register my DLL if it is located into System32.
What is the actual reality of this story?

Alternatively, you can simply add the DLL files to the bin folder as well.

Related

Mingw gives my a libwinpthread-1.dll was not found error when compiling code

I just downloaded and installed Mingw. I also setup the system environment variables for C:\MinGW\bin and C:\MinGW\msys\1.0\bin. I wanted to test to see if I had installed it correctly (it seemed to be since running gcc --version worked), so I wrote hellow world in c and tried to compile with gcc main.c -o hello_world.exe. However I got the error:
"The code execution cannot proceed because libewinpthread-1.dll" was not found. Reinstalling the program may fix this problem."
I have tired reinstalling it and restarting my computer. I have also tried to see if this problem has occurred to others, and while there are a few places it is mentioned, I can't seem to find a solution mentioned. I have thought about trying to download the dll separately, but if I remember correctly, downloading dlls is a big no no.
Awhile ago I installed mingw though chocolatey and it seemed to be working. I have deleted that download from my computer and removed the paths, since I wanted to try to install it the normal way. Could this be part of the error?
Any ideas what the issue could be? Thanks!
You have built an .exe file that depends on libwinpthread-1.dll.
Solutions to make sure the .exe can run:
Add the MinGW bin path to your PATH so libwinpthread-1.dll - this would only fix it for your own system so I wouldn't recommend this if you want to use the .exe file on other systems.
Copy libwinpthread-1.dll from MinGW in the same folder as your .exe file. This is generally needed for any shared dependancy library your .exe is linked against.
Build a static .exe (--static linker flag) to avoid the shared (.dll) dependancy.
Yes! probably is an error, cause MinGW is a bit stinky when it comes to DLLs
Here are some things you have to check:
Make sure the variable helding the location of MinGW is named "path"
and its pointing at: C:\MinGW64\bin

Code execution cannot proceed because libquickmail-0.dll was not found?

I was looking for a quick and easy way to automatically send a file to my gmail for debugging purposes on multiple remote machines. However I am apparently having linking issues which I can't seem to solve.
I downloaded the win64 zip file of libquick, IDE is CodeBlocks, compile target is x64 and running on 64-bit Windows 10.
There were 10 files that came in the zip folder, in lib/include/bin. They were
bin > libquickmail-0.dll, libquickmaillight-0.dll, quickmaillight.exe.
include > quickmail.h.
lib > libquickmail.a, libquickmail.dll.a, libquickmail.la, libquickmaillight.a, libquickmaillight.dll.a, libquickmaillight.la.
I linked to all of the .a/.dll.a/.la and .dll files and it still gives me this error: Code execution cannot proceed because libquickmail-0.dll was not found
I have no idea what the problem is and am very open to ideas. Thank you for your time.
Either copy the libquickmail-0.dll to the same directory as your linked executable or add the libquickmail bin directory to your path. This will allow Windows to find the DLL to run the executable.

How to ship .dll files with the .exe file

I have an application that depends on some .dll files.
I know if I just make them in the same folder as the .exe file, it would work, but I don't want to leave 30 .dll files with my .exe file. Is there a way I can put them in a folder with my .exe file ?
Or even better, is it possible to compile them and link them with the .exe file to have a standalone file? And no I don't have the static version of these dynamic libraries.
(p.s. the application is written with c, compiled with gcc, mingw win64, and the .dll are from gtk3 libs)
Thank you for reading my question
You have a number of options.
A) get hold of the library files, .lib on windows and statically link with these libraries.
B) It is a bit of a hack but you can attach resources into a Windows executable. This is usually used for strings, icons, that sort of thing, but you could even attach in a binary file. But if you do this you would probably need to generate the dll binaries at program startup and save to eg same folder as your executable. So no point in doing this really, simply distribute in the same folder as your exe. What is the problem doing that? (lookup LoadResource, FindResource, MAKEINTRESOURCE, etc)
C) If you don't want to put the dlls is the same path as your exe you will need to store them in a folder in your system's path env variable. Eg you could copy them to C:\Windows - but due to security that will be harder. You could create your own dll_path and add this path to the env variable as part of the installation of your program.
D) One other variation on C) is that you copy to for example a subdirectory of you exe location, called eg dll_files. Then you use a startup script to launch your program like this:
#echo off
set PATH=%PATH%;<path to dll files>
myprogram.exe
Let's make is simple
download winrar from www.rarlab.com/download.htm A) create standalone winrar executable pack your file in archive and execute your main program.
no idea how to create standalone installer guide for you
http://www.groovypost.com/howto/howto/how-to-make-your-own-offline-installers-using-winrar/

Running Executable

I have an executable that is generated using VC++. The VC++ project includes some of the dlls and when I tried double clicking the exe, it is asking for the path of the dll's.
Is it possible to place the generic dll's into a common folder, open the exe file using the batch file and provide the reference path of the dll's??
See this link for information on DLL search order on Windows.
Quick and incomplete summary:
The directory where the executable module for the current process is located.
The current directory.
The Windows system directory.
The Windows directory.
The directories listed in the PATH environment variable.
Note: The LIBPATH environment variable is not used.
EDIT
To address the comment about having the external DLLs copied locally:
After adding the files to your project, right-click one, select Properties. In the General section, change Item Type to Custom Build Tool. Now in the new section Custom Build Tool, change the Command Line to copy that particular file to the output directory.
You can also do all the necessary file copying in the Pre/Post-build steps of the project.

Eclipse CDT plugin problems

im trying to run a c program on my windows 7 computer using eclipse and im running into a little snag. I currently have Eclipse downloaded on my computer with the CDT plugin and i have also downloaded Mingw and set it to my path. When i build my simple "Hello world" program it does create a debug file with the makefile and everything in it but the concle dialog states
**** Build of configuration Debug for project C_Test ****
make all
`Cannot run program "make" (in directory "C:\Users\Chmoder\workspace\C_Test\Debug"): CreateProcess error=2, The system cannot find the file specified
Error: Program "make" is not found in PATH
PATH=[C:\Users\Chmoder\Downloads\eclipse;C:\MINGW\Bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\ATI Stream\bin\x86_64;C:\Program Files (x86)\ATI Stream\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\;C:\Program Files (x86)\Windows Live\Shared]`
Also, when i try to run my program after building it, it says
"Binary not found"
any help people?
Another solution is to set the MINGW_HOME variable in eclipse.ini :
-DMINGW_HOME=C:\Program Files (x86)\CodeBlocks\MinGW
This avoid to change the system PATH (often requires administrator rights)
(solution suggested by help of eclipse / CDT)
The error is: there is no make in %PATH. Make is UNIX utility to help building a projects. For windows OS, the make utility is part of msys, not of mingw32.
According to your path and to my setup of mingw and msys, you have no msys installed (or the path of Msys was not recorded in system %PATH variable).
For you, msys will be like this path in $PATH variable:
C:\MINGW\msys\1.0\Bin;
Msys can be downloaded from http://www.mingw.org/ too.
If you did a download of universal installer (it is the easiest variant), you just should check, is there a make.exe file in the C:\MINGW\msys\1.0\Bin directory and add this directory to the system PATH variable.
For me (on OS X), even though my personal environment (i.e. if in bash, echo $PATH) had /Developer/usr/bin in it, I still had to add it to Eclipse's Environment variables:
Go to Eclipse Preferences -> C/C++ -> Environment -> Add.. -> "${PATH}:/Developer/usr/bin
In the case of cygwin, you'd just put the right directory to where make is.
This was confusing for me, so figured share the details that helped me. :)
source: eclipse forum post via Adel on another SO post.
Goto "Window"->"Prefenerces"->"C++"->"Build"->"Environment"
add "COMMAND"="c:\mingw\bin\make.exe"`.
on the other side, you need a batch file "c:\mingw\bin\rm.bat"
In that file, put:
#echo off
:start
if "%1" == "" goto end
if "%1" == "-f" goto loop
del %1
:loop
shift
goto start
:end
I had the same problem with eclipse Luna version.
I could not even compile the "Hello World" example that comes embedded in the IDE. It kept saying that make file was not found in the path even though it was.
I tried every suggestion in this forum (making sure the path was in Windows and Eclipse variables, and making the rm.bat file) but nothing helped.
What I did is that I copied make.exe from C:\MINGW\msys\1.0\Bin and paste it into the folder where eclipse.exe resides. This might not be the optimal solution but it solved it.

Resources