Publishing exe application - c++

I have written a code in C and C++ that uses PCRE library. To test my code I use Cygwin which contains MinGW and it works fine when I run my code from console but I get the following error when I try to install the .exe file.
The program can't start because cygwin1.dll is missing from your computer
How can I publish .exe application that works on windows with all its dependancies?

As it depends on cygwin1.dll is NOT a mingw program it is a cygwin one.
If you want to built a mingw program you need
1) install a cygwin to minw cross compiler; two are available depending on your arch
mingw64-i686-gcc
mingw64-x86_64-gcc
2) install the needed additional libraries, depending on your arch and the pcre release you want to use:
mingw64-i686-pcre
mingw64-i686-pcre2
mingw64-x86_64-pcre
mingw64-x86_64-pcre2
3) set your build as cross one.

Related

GCC x64 on Windows

I tried installing CygWin64, but I cannot find any executables to build my code with in the C:\cygwin64 directory created.
I tried Win-Builds but the setup doesn't load with any mirror I give it. It tries to connect 3 times then aborts.
I tried MinGW-W64-Builds, but I cannot figure out how to install it. I can see a .sh file there, but I believe that is for Linux, so I do not know why because it says it is for Windows
Is there even a way to use 64-bit GCC on Windows? I am trying to tie it to a Code::Blocks IDE as that one only comes with the 32-bit version of MinGW.
Check out out the MinGW-w64 + GCC personal build at http://winlibs.com/.
No installation required, just unzip.
Examples on how to use are on the site, including on how to integrate with Code::Blocks IDE.

Can I generate exe from ubuntu

I'm using Ubuntu and I use Code::Blocks as my IDE, I'm still a student and my professor wants us to write and compile some c++ programs and give him the exes to check them
Is there a way for me to generate exe files on my Linux os ?
ps: I'm new to Linux so take it easy on me.
Thanks
You need a cross-compilation. You can use mingw tool chain, if your want 32bit Windows application, install mingw32. Here are the detailed instructions for using it with IDE CodeBlocks.
If you want to build 64-bit applications, try mingw-w64 fork.
Also, then you could run the compiled application (or, even some native windows applications, compiled on Windows) in Linux under Wine:
sudo apt-get install wine
wine myapp.exe

"Cannot execute binary file" when running compiled c++ programs with Eclipse on Ubuntu for Windows platform

I would like to move from Visual Studio on Windows platform to Eclipse on Ubuntu for c++ development, since I develop almost all my programs on Java, with Eclipse, and I just use a Windows virtual machine in order to develop C++ programs for Win OS. So if I would be happy being able to not use Windows VM at all. However, I've managed to configure MinGW and Eclipse successfully enough to compile programs, but not to execute them.
Steps I've gone through so far:
I've installed mingw32 package and dependencies:
$ sudo apt-get install mingw32
I've installed Eclipse Mars for C/C++ development (manually, to keep this installation isolated from other Eclipses I have) and created a new project in this way:
- New C++ project.
- [...]
- Cross-prefix: i586-mingw32msvc-
- Cross path: /usr/bin/
With this configuration I'm able to correctly build a .exe which I can successfully execute on Windows, but when trying to debug it or execute it under Eclipse I get this error: "cannot execute binary file".
Googleing I've seen some posts suggesting to use wine in order to execute the .exe, but I thought mingw32 would be able to execute it. Am I wrong and this is not possible or just doing something wrong?
Mingw32 is a windows compiler, and will compile source to a Windows executable file. Additionally, the compiler cannot execute files (as worded in the question), it just compiles the source code to an executable form, in this case the windows executable (*.exe). So yes, in order to run the .exe in Ubuntu you would need something like Wine which emulates a Windows environment
mingw is a set of GNU tools for building native Windows executables.
It does not execute anything.
If you really want to cross-compile for Windows, you need Windows or an emulator for the execution.
To build for Ubuntu you can just use the native compilers.
sudo apt-get install gcc

Run cygwin built exe in windows without cygwin's environment

I'm trying to port a linux software in Windows.
My software depends on gtk, boost and libgerbv (which I've manually compiled on cygwin)
I've successfully compiled it and it works if I run it in the cygwin's terminal, but if I copy the .exe in a folder with cygwin1.dll and I run it, it terminates silently
Same result if I run it within cmd.exe.
How can I "export" this executable outside the cygwin environment? I want to distribute it with just the needed shared libraries and cygwin1.dll
Thanks
"How can I "export" this executable outside the cygwin environment?"
In short: That's not possible. You'll need to have a cygwin environment installed on the target machine, and run the programs created in cygwin from a cygwin shell.
Cygwin requires a number of it's own .dll files, to bind to the underlying Windows OS. These cannot be just copied to another windows system without having a complete installation of cygwin.
Here're some more details about this: What is the difference between Cygwin and MinGW?
That's why I prefer to use MinGW to target windows systems portably. Cygwin has it's powers and right to exist, when it comes to cross compile code for different (e.g. embedded) targets running on windows as host.

Building a Windows Console App In Cygwin 1.7.16 Targeted to Cygwin 1.5.24

I have a Windows console app that is pure standard C++. I am building it in Cygwin 1.7.16 (running on Windows 7) for target Cygwin 1.5.24 (running on Windows XP SP 2).
My build command is:
g++ -o mgen_stats.exe -I ../include ../src/*.cpp
On the target, my path includes /usr/bin, which is where cygwin1.dll lives.
When I run the application with no arguments on the target in a Cygwin 1.5.24 shell, I immediately get the command prompt back. I should see the application's usage printed out.
Some immutable constraints I'm working under:
The build and target machines are isolated from each other.
There is no C++ build tool chain on the target.
I may not install a C++ build tool chain on the target.
I may not modify the C++ build tool chain I have on the build machine.
As a result of the above, I must build on my build machine, burn the .exe to a CD, and copy it onto the target machine.
I would be just as happy for my application to be a native Windows application (i.e. run it in a DOS shell rather than a Cygwin 1.5.24 shell). To this end, I tried using g++ build flag -mno-cygwin. g++ tells me that flag -mno-cygwin has been removed. It then suggests that I "use a mingw-targeted cross-compiler". I do not know how to tell if I have the mingw-gcc, mingw64-i686-gcc, and mingw64-x86_64-gcc packages (which, according to the Cygwin FAQ, contain the suggested cross-compilers), and if I do have them, I do not know what the names of the compiler executables are.
Can anybody help me get this app built such that it will run successfully under either a DOS or Cygwin 1.5.24 shell on my Windows XP SP 2 target?
Thank you in advance.
The MinGW packages (like any other Cygwin package) can be installed on Cygwin using the "setup.exe" that Cygwin provides on its website. If you do have them installed, you'll find the compilers as i686-w64-mingw32-g++ or x86_64-w64-mingw32-g++.
Alternatively, you can also install the MinGW packages directly (without using Cygwin).