cygwin1.dll is missing - Cannot run program - c++

I wrote a program in C/C++ and compiled it using Cygwin. When I ran the compiled file, I receive an error about a missing library.

Cygwin is like a simple framework: With every program you build you have to include the library cygwin1.dll.
Important note: Downloading the library online might be risky as it can be a virus.
To fix the issue:
1. Go to your cygwin directory. Usually that is C:\cygwin or C:\cygwin64.
If you don't know where cygwin is, download the setup file and run it. The installation path the installer suggests is the Cygwin installation location.
Tip: Don't use a directory to put cygwin in that includes spaces (" ") as it will be easier to run programs with command-line parameters.
2. Copy the file. It should be in <Drive>:\cygwin\bin\cygwin1.dll.
3. Copy the file to your program folder, the same directory as your exe file.
Your program should run without throwing an exception.

Related

Missing libgcc_s_seh-1.dll starting the .exe on Windows

Intro
I have a CMake-based C++ project. Until now I build and ran the project via CLion. Everything worked fine until I tried to run the .exe-file directly (not via CLion).
Problem
When I navigate to the cmake build directory in order to start my program via the executable file, it fails with the following message in the popup: Cannot continue the code execution because libgcc_s so-1.dll was not found. Reinstalling the program may resolve the issue.
I have the following questions
If I interpret the error message correctly, then this dll is missing on my computer. So I ask myself, why does my program still work when I start it via the development environment (CLion), although the error message expressly states that the source code requires this dll?
Is it the fault of my application/source code that the error appears or rather the current state of my computer? If the former, how can I prevent this error from appearing for other users?
What is the best way to fix this error? It's obvious that I need to download this dll, but where is the best place to put it (which directory and environment variable to use on Window)?
Which source is trustworthy to download this dll? I don't want to download any malware under this dll-name.
Optional: What kind of library is that? What functionalities does it offer?
Additional information
I use CMake as my build tool, CLion as the IDE and MinGW as the compiler.
What I have did so far?
I made sure it still works through the IDE.
I found this dll does not exist in the MinGW installation folder.
I searched the web for more information. Unfortunately, there are only pages unknown to me that only offer the download of this dll. That doesn't satisfy me.
I found the cause of my problem: I had two MingGW installations on my machine. Once the installation that comes with CLion and a separate one. The latter did not have the required dll. However, CLion used its own installation, which in turn owns the DLL. So the solution was to remove the separate installation and include the path to the CLion installation's bin/ directory in the PATH environment variable.
This file is part of MinGW-w64 when using SEH as exception model (as opposed to Dwarf or SJLJ). You need to distribute the .dll files your .exe file(s) depend on in the same folder as the .exe file(s).
If you don't have that file, then you probably have been using libraries compiled with different versions of GCC/MinGW(-w64). I recommend building everything with the same compiler to ensure stable binaries.
Tools like Dependency Walker can help you figure out which .dll files your .exe file depends on.
Or use the command line tool copypedeps -r from https://github.com/brechtsanders/pedeps to copy the .exe files along with it's dependencies.

Unable to execute .cpp files in CLion using the console and make commands (Windows 10)

I got a bunch of .cpp files in a project in the CLion IDE which I would like run in order to see what the code is actually doing. The makefile looks like this:
## ptp test
run-ptp: create-ptp
./systems/ptpTest/build/ptpTest
To run the code I went to the console and went to the project root directory which contains the .cpp files I like to run. When I enter the make command "make run-ptp" on the console it returns:
The "make" command is either misspelled or could not be found.
What could possibly be the reason for this to happen and how can I make it work, so that I can run the .cpp files via console and make command? Thanks in advance.
It means either (a) you don't have make installed on your system, or (b) you have it installed but the directory it's installed into is not on your PATH so your shell can't find it, or (c) you have it installed and it's on your PATH but it's installed using a different name than make such as gmake or something like that.
Since you haven't described what operating system you're using nor how you installed make on it that's the best we can do.

How to run c++ program written in eclipse, from terminal

I'm using Ubuntu and I have written my c++ code in Eclipse Neon.
My workspace contain 4 projects. The main project is called BaseCppProjectRun (it contains main.cpp file) and I have other projects with these names: Encoders, frmwrk, NetworkLayer - the BaseCppProjectRun using each one of them.
If I running my program directly from eclipse everything works.
But I want to running my program from terminal - and I can't.
Because When I'm trying to run my progrm like this:
root#ubuntu:/builds/BaseCppProject/BaseCppProjectRun# ./Debug/BaseCppProjectRun
I'm getting this error:
./Debug/BaseCppProjectRun: error while loading shared libraries: libfrmwrk.so: cannot open shared object file: No such file or directory
As I said before, if I'm running it directly from eclipse everything works.
How can I run my program from terminal?
How is Linux supposed to know where to find libfrmwrk.so, if you don't put that either where it normally looks nor tell it where it can be found.
Eclipse seems to set up the paths the runtime linker looks into so, that when your program is loaded, the runtime linker knows where to find your libfrmwrk.so and so on.
You'll either have to
install these libraries (.so's) so that they are found in default locations, or
set LD_LIBRARY_PATH to contain all the folders to look into.
I haven't worked with Eclipse CDT in ages, but you can by now probably export some project formats that allow you to easily install things.
Another thing: It seems you're running software you're still debugging as root: That is a terrible idea, and if it can be avoided, avoid it.
I finally figure it out!
Refere to Marcus Muller's answer + my steps this is how I have fixed it ( all steps via terminal):
Create new directory in my workspace directory and called it libs.
In each one of your projects do: right click > c/C++ Build > Build Steps (tab) and in Post-build steps paste this:
cp ${BuildArtifactFilePrefix}${BuildArtifactFileName} "${WorkspaceDirPath}/libs/"
This code copy the so files directly into your libs directory when you compile your program.
And finally, in your terminal execute this:
export LD_LIBRARY_PATH=/builds/BaseCppProject/libs/
Now you can run your program via terminal.

libgmp-10.dll is missing

I recently installed MinGW on my 64-bit Windows 7 computer and when I attempt to compile the most basic of c++ programs, for example
#include<iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
}
I get the error that "The program can't start because libgmp-10.dll is missing from your computer."
Have you tried adding C:\MinGW\bin as a System variable Path (not PATH) in Settings->System Properties->Environment Variables?
I saw this solution on this page: Missing libgmp-10.dll
Go to the mingw download page and browse the following directories:
MinGW / Base / gmp / gmp-5.0.1-1
Currently you end up with the following link:
http://sourceforge.net/projects/mingw/files/MinGW/Base/gmp/gmp-5.0.1-1/libgmp-5.0.1-1-mingw32-dll-10.tar.lzma/download
and it contains the needed file.
I know there are automated methods for installing mingw gcc, but when one uses single mingw packages, then gmp is one of obligatory downloads.
added
c:/MinGW/bin to PATH
and restarted CMake-gui
worked for me
I came upon this question when I started CodeBlocks and then clicked on my project. After the project notes appeared and I pressed OK, the error appeared:
"System Error: The program can't start because libgmp-10.dll is missing from your computer.
Please reinstall the application to fix this problem."
I presse OK a bunch of times and then was able to do normal compile, link, etc. but that error showed up everytime I started C::B and went to the project. Then I noticed that the LLVM Clang compiler was my default compiler in the compiler settings, though GCC was set as the compiler specific to the project I was working on.
The solution was to set the compiler in the compiler settings to GCC (mingw) and also set it as the default compiler. After that this system error stopped popping up every time I started the project.
The reason I posted this answer is because it answers the OP's question and other people with the same question may have a similar reason for this irritation, and my personal experience in this matter may prove useful to those people.
If you did not find this file in your installation directory, and then went to the site [Click here] to download the file, and then extract it to your installation directory.enjoy:-)
Caution - removing stuff from your path can compromise your system!
Interestingly, you not only need to add the MinGW bin to your Path, but also you need to make sure that certain things are not on your path*. In my case, I saved my entire path variable as a backup, deleted everything non-system from my path except for MinGW and CMake, leaving:
C:\MinGW\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files (x86)\CMake\bin
You should use the appropriate elements from your system path.
I first tried to do this with a batch job that launched CMake, but it seems that the CMake GUI was reaching back and grabbing the System 'Path' variable instead of the command prompt 'Path' variable, which I had printed and confirmed was as listed above before launching CMake.
Incidentally, I backed up the entire Windows VM before starting!
* For instance: various references, including known issues, mention sh.exe. I inherited this VM from my client and hacked it up further, so it's easier for me to use a clean path for my cross-compiling task and return afterward...
In just installed MinGW using the mingw-get-setup.exe v0.6.2beta-20131004-1 installer. Even though during the install I selected the gcc package, the installer didn't include the "mingw32-gmp" package, which includes libgmp-10.dll. I had to rerun the installer, chose the "Reinstall" option, and manually select the "mingw32-gmp dev" package.
If you don't have the permission modifying your global path, you can also change the active directory of your cmd shell.
How to do it (in the cmd shell):
C:\> cd C:\MINGW\bin
C:\MINGW\bin> gpp.exe C:\Users\James\Desktop\Program.cpp
How it doesn't work:
C:\>C:\MINGW\bin\gpp.exe C:\Users\James\Desktop\Program.cpp
Note: you have to change "C:\Users\James\Desktop\Programm.cpp" to wherever your program lays
How it works: windows looks for needed DLLs while in the same directory and if it can't find it there it'll look in the PATH variables (so it will search system32 by default), if you add any missing DLLs to the directory from where you run it, windows looks and uses them (even before it looks in the PATH).
A very simple fix to this problem of having missing driver file/s is to select and copy all the dll files from C:\MinGW\Bin and paste them into your C:\MyPrograms or whereever else your folder for created c++ (.cpp) files are being located.
Just search google for the dll file and download it. Then paste it into the folder in this path
C:\MinGW\libexec\gcc\mingw32\9.2.0

MinGW Compilation Problem

I just installed MinGW using the automatic installer MinGW-get-inst that I found on their website. I am using eclipse to write my C++ programs. My code compiles fine, and I get a .exe file. However, when I try to open this executable, I get the error that libgcc_s_dw2-1.dll is missing from my computer. I have located this file under MinGW\bin so I know it exists.
This is for all C/C++ programs, I am testing with a simple hello-world program. Any fixes?
Thanks
You need to ensure that the MinGW\bin directory is on the path from where you are running application.
If you were running the resulting executable, say a.exe for example, from a CMD window do the following to check that MinGW\bin is on the path.
set PATH
At this point you will see the current value for the command path. Make sure the MinGW\bin directory is in it somewhere.