Thinker-101
Thinker-101

Reputation: 651

C++ code compiled with cygwin needs cygwin1.dll to run

I have no special code to share to ask this, but I wrote a C++ code (which could even be a simple Hello World program) compiled to an exe file, requires the cygwin1.dll available either via %path% or in the same folder as the exe to run (for runtime).

If it were libstdc++-6.dll needed I could have done something like use the tag -static or -static-libstdc++. But, what can I do to not depend upon cygwin1.dll file for exe execution? Should I use some other compiler instead?

Ps: I am expecting some kinda solution similar to this if it makes sense. MinGW .exe requires a few gcc dll's regardless of the code?

Also, I do not want to create Or use a separate installer to add the dll to the right place for my case.

Upvotes: 2

Views: 792

Answers (1)

Joshua
Joshua

Reputation: 43337

As discussed in comments, the native gcc inside Cygwin targets Cygwin. You want the GCC targeting mingw32 not the one targeting Cygwin. While you can install that GCC inside Cygwin as a cross compiler, the native GCC from MSYS works just fine and I too would recommend that.

Note that if you need a library that isn't available in MINGW, pulling the one from Cygwin will essentially never work. Consider this a hard line: never mix Cygwin dependent dlls with non-Cygwin dependent dlls. Treat Cygwin as a subsystem that happens to be startable directly from Win32 rather than a Win32 library.

MINGW has had pthread for awhile; however many times the port doesn't work. If the pthread-using program calls fork(), it will not work. That's when you need Cygwin.

Upvotes: 1

Related Questions