Qt deploying issue on other computer - c++

I have a deployment problem after having compiled the release of my program. I can use it on my computer, but it doesn't work on another computer unless I install Qt on it.
I tried to compile with MSVC2012 and MinGW:
With MSVC2012, the program doesn't show any error messages.
With MinGW the program sends me a c++ runtime error.

You have three options:
Compile Qt with static libraries and link you program with those static libraries. All dependencies will be included in the program binary.
Ship Qt dynamic libraries that your program needs with your program.
Ask the user to install Qt libraries with the same major version you used to compile your program.
I'm not a Windows guys so I can't tell you Windows specifics, but these will do the job.

Related

SDL2 executable not working outside CodeBlocks

I recently developed a SDL2 game using C++ and the latest version of CodeBlocks. The game works just fine if I run it inside the IDE - the problem is that if I try to run it outside CodeBlocks it will get an error:
The application was unable to start correctly(0xc000007b)
What should I do in order to solve it?
You need to ship/install all libraries that your application uses. This includes SDL, but also your compilers runtime libraries.
If you don't include all libraries your application links with, then it cannot run.
And no, just linking with them locally is not enough. You need to ship them to the other computer that needs to run the program.

Compiling a C++ program with all libs it needs

When I compile C++ code that uses openmp libs with visual studio, the program is very portable - because it runs in other machines with Windows without problems.
When I compile the C++ code with Eclipse CDT (oxygen and g++ cygwin) for Windows, in general, I need to install the correct runtime libs in the other machines to be able to run the program. I don't find it practical.
Based on this:
1) What is the right way to compile the code including all libs (g++ and openmp) to run in another Windows system?
2) How can do this in Eclipse CDT for Windows?
The problem is not in compiling, but in distributing. Windows and windows toolchains intend to use dynamic linking. Now, if created software are dependent on particular version of runtime, which includes side-by-side build, they can be run only if exactly that build is installed. Several builds of same library version may exist, they are fetched using side-by-side (SxS) mechanics.
On Linux platform this problem is solved through package manager and dependencies. On Windows you have to create an installer, which would contain or have ability to download proper version of libraries. Also installer may do proper changes to OS settings, and register them , for future rollback.
Note, that runtime libraries have debug variants which cannot be distributed and debug build of software must be run on developer system only.
"Portable" apps that appear here and there and can be run without installation, have special status not to be dependant on SxS run-time library. To my knowledge cygwin and mingw32 allowed to create such, the 64bit project of mingw had problems with that. But they are still dependant on particular versions of system .dll and may break or malfunction in case of mismatch.
Even in that case you still need some .dll, from mingw, cygwin, Qt, whatever you use and what is not a part of OS, to place them where program can reach them. Which can be folder comtaining the executable. Static linking became a gimmick of past for desktops, because of code bloat - dynamic library size easily can be dozens of megabytes.
And last: you don't compile anything with Visual Studio or with Eclipse CDT. Both designed to use various compilers, it's juse environments. You have to specify normal;y, what compiler your IDE uses, not what IDE you use to run ot.

Deploying a Qt 5.5.1 C++ application on multiple Linux distributions

I have an application written in pure C++ and Qt 5.5.1. It compiles fine in both GCC (Lubuntu 15.10 x86) and MSVC 14.0 (Windows 8.1 x64), and works properly on both those platforms. I now want to distribute it so that it will run on other Linux distros without recompiling them there.
I'm not entirely sure how to achieve this; the Qt docs page generally suggests to link everything statically, but this is not what most other sources say (from what I understand it is a bad idea to link with glibc statically). In any case I cannot really link everything statically because GCC complains that Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking and from what I understand this isn't a warning one can simply ignore. I've tired linking statically against only libgcc and libstdc++, I copied the other missing libraries - libXau.so.6, libXdmcp.so.6 and libxcb.so.1 on a clean CentOS 7 installation and tried to run the program there, but that gave me a segmentation fault; possibly because the system is 64 bit as opposed to the platform I compiled the application on?
How can I distribute the application in a form runnable by most common configurations? Static linking is not an issue because the source is going to be released anyway.
Is it better to link against Qt statically or dynamically (if maximum binary portability is the priority)?
Do I need to provide two separate versions of the binary, 32 and 64 bit, or will a 32 bit build suffice?
My suggestion would be to offer two builds: an unsupported, fully static build that will work "anywhere" with an asterisk that there's no way you can support it if it's a commercial offering. People'll try to run it on their fridges, I kid you not. The officially supported builds must be for specific platforms only, and you can't but have VMs/test targets that run these platforms, and where you build and test on.

Compile A MSVC++2010 Project So It Can Run On Ubuntu

I have a MSVC++ 2010 project. All the libraries it's using are cross platform (SDL, OpenGL and FLTK).
Obviously, all I have to do right now is press the debug button and it will compile a nice old .exe for me which can now run on Windows, as long as the DLL files are with it.
I had thought before that if you use cross platform libraries, then the generated .exe would run fine on Ubuntu too. I recently found out that this is not possible, and that the program must be compiled in a special way to run on a certain platform.
Is it possible to compile my project in this magical way with MSVC++ 2010 so that it can run on a Ubuntu computer? If so, then could you please answer my question with some clear steps as to what I should do to compile it this way, keeping in mind I'm new to how all this cross platform stuff works?
EDIT:
If I cannot compile a MSVC++ 2010 project for Ubuntu, is there an IDE I could use that could compile the project for both Windows and Ubuntu?
Thanks.
I suggest you use QT. http://qt.digia.com/
It's probably the best cross platform IDE that can let you compile for Windows, Mac and Linux(ubuntu) systems.
Nope, not possible. While the binary code corresponding to the program can be portable, that's not enough. Executable formats on various file systems are different and not compatible. The executable format is essentially a packaging of the binary data and wrapping it with a header that the target file system understands. In order to produce executables for Ubuntu, the linker must support it. MSVC++ doesn't support Linux formats.

How to compile a .cpp file into a Windows executable (.exe) file in Linux

I make this program in C++ using Code::Blocks on Ubuntu. I need to turn it into a Windows executable binary (.exe file), but I don't know how to do this. Is it possible?
If you meant, compiling an executable for Windows on Linux you might find some pointers on how to do that here.
Both the MinGW32 distribution of GCC and Wine should be available for your distribution.
MinGW has instructions and winegcc wraps a similar compiler that comes with the Wine distribution.
I've used both to compile both applications and libraries for Windows.
You could read here on how to compile wxWidget applications on Linux for Windows using Code::Blocks.
This is a fairly unusual question. What you're asking is that you want to develop on Ubuntu, but the target platform is Windows?
My guess is that you have an assignment to turn in. My belief is that you should go to a lab and compile it and make sure it's working.
However, doing some research, you should try mingw at http://www.mingw.org/