MinGW Compilation Problem - c++

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.

Related

How to set the working directory of an executable program in Mac OSX

I created a C++ project in Xcode which successfully builds and runs a program in the Xcode environment. This program is dependent on existing in its current working directory to access several files. Outside of the Xcode environment, when I double-click on the executable file, I get a message that notifies me that the terminal exits the current working directory.
The current working directory exiting twice
[1]: https://i.stack.imgur.com/EZ5kc.png
After the exit messages, my current working directory results in /Users/chefjeff/
Judging by this other post: How to change default working directory on Mac OS X?
There might not be an easy solution to double-clicking an executable so that it opens in its current directory, but I still need a solution to using the GUI on Mac in some sort of way to open the file in its working directory.
EDIT:
The project folder, CultGame, must be able to exist at any location in the user's filesystem and still have its packaged files and executable files work.
So here's how I solved this:
I couldn't change the default directory that double-clicking on the program to run it would start up on.
I can use the chdir() function to move around directories. I moved to the root directory using chdir() after the program began and started me in Users/Username. More on chdir here: https://www.geeksforgeeks.org/chdir-in-c-language-with-examples/
I used _NSGetExecutablePath() to get the directory that the currently executing file is located in. More on that here: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html
From root, I used chdir() to navigate to the path of the currently executing file which I obtained with _NSGetExecutablePath().
I will update my answer in a bit with a code example. Hopefully this helps!

Launched failed. Binary not found c++ eclipse

I have no idea why my c++ file will not compile correctly. I added the MinGW installer in the right environment path. I selected my Binary parser to PE Windows Parser.
Open a command prompt from any folder and type make. Press enter. If it gives you a message like file not found, then you either do not have make on the path, or it was not installed with Mingw.
So if not found, first go to the Mingw folder and verify that you have a file called make.exe. If you don't, you need to reinstall (possibly with msys), if you do, then you need to make sure that the exact folder with make is on your path.
You can see what folders are on your path by running echo %PATH% in a command prompt.

cygwin1.dll is missing - Cannot run program

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.

How do I inform the debugger of the location of run-time linked DLL files?

I have a C++ program that uses the freeglut library (and hence requires the freeglut.dll at run-time. I have added the folder C:\Program Files\Common Files\freeglut\bin to my PATH environment variable.
To confirm that the location is correct, when I compile my program (debug build) and run the resulting .exe file, it works fine (the freeglut.dll file is not in the same directory as the executable).
However, when I run the program directly from the VS2012 debugger, I get this message:
The program can't start because freeglut.dll is missing from your computer. Try reinstalling the program to fix this problem.
I know that one solution is to place the freeglut.dll file in the directory of the executable. This is what I've been doing so far, but I would much rather simply inform VS2012 (or my program) of where to find the dll file. Note that this post also seems loosely related, but it doesn't seem to contain an answer relevant to what I am trying to achieve (I just want the debugger to look in the same place for DLLs as any other program!).
How do I achieve this in VS2012? Icing on the question cake would be an explanation as to why the debugger doesn't just look in the PATH variable like any other program...
You can also set project based Environment:
Open project Properties
Go to Configuration Properites -> Debugging
Enter the path in Environment, eg:
PATH=$(PATH);C:\Program Files\Common Files\freeglut\bin
Restart Visual Studio after modifying your PATH variable.
What I did actually worked. I just didn't restart VS...

SDL.dll is missing from my computer - VS 2010

I'm trying to compile a SDL-program I've written, but when I do, this error shows up:
The program can't start because SDL.dll is missing from your computer.
Try reinstalling the program to fix this problem
I have no idea as to why. I have SDL.dll.
I have put it in the correct folder: C:\Windows\System32.
I have the correct PATHS to all the SDL headers and such as well.
VS says:
Build succeeded: 1
and THEN the error above pops up on screen.
Add it into your debug folder or whatever directory your program is currently located at.
SDL.dll has to either be in the same directory as your application, or in a directory that's in the PATH environment variable.
IfSDL.dll is 32-bit and you're running a 64-bit system you have to place the dll into /Windows/SysWOW64/ rather than /Windows/System32/, which is used for 64-bit dlls.
EDIT:
You probably shouldn't be deploying your DLLs by copying them into the System32 directory, unless they're common libraries that are used by several applications, and even then I would use discretion. For example, an application could update the DLL, which could break other applications that rely on an older version of the library.
Instead, copy the DLLs into the same directory that the executable is being built in. If you're building and executing with Visual Studio it will look for the DLL in the Project directory, where your source files are probably located.
Just place your SDL.dll in the same folder and your problem will be solved.
And to answer to your problem with the PATH, you can specify in visual studio where he will look for executables while debugging. Maybe this isn't set correctly and that's why VS can't find SDL.dll?