MXE and QT deployment gives Runtime Error - c++

I'm building a QT application on Ubuntu that works pretty good. Now I have to deploy it on Windows, so I installed MXE in order to cross compile my sources.
MXE build
git clone https://github.com/mxe/mxe.git
cd mxe
# I need posix threads, that why I build static.posix target
make MXE_TARGETS='i686-w64-mingw32.static.posix' qtbase libxml2
I use a personal library (that uses cmake) and a client/server code for my QT code, that I compiled with MXE and it did not give any error (I worked hard to fix them...). Then, the compilation for the QT reaches the end without any error.
Whenever I try to execute the program (with wine on Ubuntu or on Windows) it does not work. wine freezes and Windows shows me a Runtime Error.
I also tried to use the windeployqt.exe using wine on my executable, hopping it will give me the missing dlls, but it tells me :
Z:\path\release\Executable.exe 32 bit, release executable
Z:\path\release\Executable.exe does not seem to be a Qt executable.
I really have no idea on what is broken. Am I forgetting to put dlls, or is my compilation failing silently ? Does anyone knows or have ideas on how to deal with that case ?
EDIT
Apparently I compile correctly my program, the error seems to come from GetAdapterAdresse when using Windows. The problem is not coming from MXE at all (I'm glad I made it work though).
I'll have to have a look on this function, but anyone knows how to make gdb work with MXE ? When I ran make gdb, it has built something, but I can't figure out where is the program.

Related

VS Code can't step into linked library project

VS Code 1.48, Ubundu 18.04, cmake 3.10, gdb 8.1-ubuntu3.2, gcc 7.5.0.
VSC newb, ubuntu newb, unix experienced, cmake experienced, gdb newb, c++ grizzled vet. I'm mostly a windows guy, though I've dabbled with various flavors of Unix since college back in the early 90s. wheeze
I have two project directories loaded into my VSC workspace... both written in C++ with a dash of python hither and yon. The first, we'll call it Orc, works great. All it's tests pass, it's cmake-defined install ran just fine. Life is good.
The second project, we'll call Elf, builds fine, and works fine until it needs to depend on Orc, at which point I get a seg fault. Another call to that same library succeeded (the version check:trivial, no parameters), though I cannot step into that either. When it comes time to tell Orc to do some actual work: boom. I also haven't noticed any core dumps lying about to be interrogated.
(side question: where does VSC stash its core dumps?)
I made sure both projects are debug builds. They're both using the same version of Boost. I've succeeded in running all our unit tests in both Orc and Elf on windows.
What do I need to do to be able to step into Orc so I can see what's going wrong?
I added the following to my CMakeLists.txt and it seems to be happy. There's probably a better way to do it though.
if (UNIX)
add_definition(-ggdb)
endif()
Down side: Always adds -ggdb to Linux builds, including Release... not just the debug variants. Problems in with non-gdb debuggers.
I'm guessing there's a better way to specify a debug-only flag like this, but I'm not sure what that might be. I'm getting familiar with CMake, but I'm no expert.

SFML Can't Start Application

I am running a project which use SFML and who works perfectly fine on Linux.
I am now Compiling my project on Window and it works.
I am Using Cmake actually.
The thing is when I start my SFML APPLICATION it just doesn't run.
I mean when I start it, The main's first line of code isn't executed.
The error seems to be due to Shared Libraries Linking but I can't figure Why ?
I've Included the SFML dlls in the binary directory, so I didn't got (explicitly at least) errors about shared libraries. (When running Through a terminal)
I do not Compile my program with static SFML Linking otherwise I wouldn't have this question
I've also compiled SFML myself (and installed it ofc) and use the same Compiler ("-G"MinGW Makefiles") to build my SFML Application.
I've seen someone who got a driver's update problem, but I've already tried the solution
The error code is:
when running through a Git-bash terminal. (No explicit Error)
echo $? -> 127
(so -1 at runtime)
And when Running through CLion:
Process finished with exit code -1073741792 (0xC0000020)
If someone can help me it would be great!
EDIT:
When using dependency walker (and select SFML dlls)
I got an error too This files is not a valid 32-bit or 64-bit Windows Module
But I do not understand why since I've compile SFML myself

SFML - Applications has stopped Responding

So, I'm using CodeLite on Windows, building with Mingw64 on 64 bit system. Everything builds, but when i run the application, it crashes with "Client.exe" has stopped responding. Client.exe being my application. I'm literally running the default example code off the SFML website. When I've googled around for quite some time now and I honestly have no idea as what to even look at for this error.
Sometimes my console will output
Application has exited with error code: 255
But most of the time it outputs:
Program exited with return code: -1073740940
Using help from the comments on my question.
As stated by Satus, The issue was, first, my libraries were statically linked, using the Dynamic libraries, instead, seemed to have fixed my issue. My second issue was that my SFML libraries were built using the wrong version of MingW. Recompiling this was simple enough. I downloaded the SFML source code. Used CMake to set everything up as displayed on the official SFML compiling and building tutorials, and built it using my version of MinGW. After copying the newly compiled DLL's and Debug DLL's, everything worked perfectly.
Be sure if you're using two different version of MingW (64bit and 32bit) to compile each version in CMake accordingly, otherwise you may get issues.

Installation wxWidgets with mingw64

I try to get wxWidgets installed on a Windows7 x64 Machine but wxWidgets Installation doesn't even work, I cannot get a Hello World App running.
I found out there are several ways to get the library installed and I tried some of them (with Cygwin and the included mingw64 compiler, with mingw64 using diffrent settings), all the time I get Errors while building the library. Could somebody point me out what's wrong with my current setup (which was also my first try) or show another solution?
First I installed mingw64 with the online installer to c:/mingw64. I tried some different setups concerning Version and Threads, but ended up with 4.9.2, x86_64, posix Threads, sjlj Exceptions.
Then I downloaded MYSYS from sourceforge.net and extracted it to C:/mysys.
Then I created a folder C:/wxWidgets and mounted it as /wxWidgets, downloaded the wxWidgets 3.0.2 source and put in into my mysys-home folder.
From /wxWidgets I executed: /home/Martin/wxWidgets-3.0.2/configure --host=x86_64-w64-mingw32 --disable-shared --enable-monolithic
The configure did his job without errors though some libraries couldn't be found and built-in libraries were taken instead (jpeg, png, regex, tiff, expat).
Then I executed make and it ran for some minutes and suddenly crashed. The only output was make: *** [monolib_any.o] Error 1
The last executed command was /wxWidgets/bk-make-pch ./.pch/wxprec_monolib -D__WXMSW__ ...
Right before, there is an note concerning POSIX paths: "CYGWIN environment variable option "nodosfilewarning" turns off this warning...
All the other tries ended up like this one, make suddenly hung up. Any help appreciated.
If the make/compile process really dies without any other error messages, the most likely explanations are that either it runs out of memory (but even then normally there would be some error message) or some hardware problem, it's really not supposed to do this on a working machine.
So my advice would be to run some hardware diagnostics. If this shows nothing, run make -n and execute the command used to compile any.cpp by hand by copy and pasting it.

Program only executes if I run it in Visual Studio

I have been trying to find a solution for this problem but I haven't been able to see/find any answer that correctly solves it.
I coded a program (Qt + OpenCV) that works fine when I run it with Visual Studio, but trying to run the executable it simply does not execute anything. The program doesn't give any error: it just never starts.
I am not sure where to start checking what is happening and why it is not even starting (I could understand lack of libraries, some other error..).
I am basically interested on what are the best way of checking why a program runs when executed from the IDE and not from the executable created. As I said, I was expecting an error message if something was wrong. Any ideas? Any good programming advice regarding how to avoid this problem in the future?
Edit: I forgot to mention that I am coding with a Windows XP machine. It doesn't work in this machine when I try to execute the file. It executes normally on a W7 machine but not in other W7 machine.
The executable will need the QT libraries on the computer that you are running it on. On linux there is command (I think ldd) that will show you what libraries your executable needs. I am not sure about Windows but there should be something similar. At least on a linux computer it will not necessarily give you an error if the QT libraries are missing. The executable just seems to do nothing.
Try copying the executable into the same directory as the .dll files in the Qt 'bin' directory.
If that works then you just need to put the Qt bin directory into your path, or copy the dlls into the windows\system directory
You need not only the correct dlls in your path (best in the application directory), but also the plugins in the correct location. See my answer to the question: Qt dll deployment on windows.