Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946
911: still can't build a standalone application
Hi, guys -
I thought I had this licked, but evidently I was wrong.
I have a single-file program that I NEED to build into a standalone application. It uses a couple of files that I find with this line in my .pro file:
@LIBS += -lws2_32@
It seems to execute OK on my system, but when I sent the binary to someone, he got a message about missing .dlls.
Am I overlooking something?
Any quick help on this would be most appreciated; it's squarely on the critical path and I'm in the hot seat.
ws2_32 is an import library for the Winsock2 API on Windows. The corresponding DLL is shipped with every modern version of Windows. Do you link against Qt? If yes statically or dynamically ?
Here's my .pro file:
@TEMPLATE = app
CONFIG += CONSOLE
CONFIG -= qt
TARGET = storefile
win32:LIBS += -lws2_32
INCLUDEPATH += "../../inc/"
So, I guess I don't link against Qt.
If I understand what you're saying, it's that I should assume that any system trying to run my app already has this library? I can make that a user requirement if need be, though I was hoping to have a truly self-contained app image.
Are you using MinGW by any chance? There are some DLL dependencies such as mingw10.dll if I remember correctly and maybe one or two others.
If you are using Visual Studio, make sure you create your executable with static runtime linking (/MT) as specified "here":http://goo.gl/dzLwL otherwise you need to redistribute the runtime distributable for that specific version of Visual Studio along side your application.
Anyway you can find out which DLLs your executable is linked against using a tool named Dependecy Walker which you will find "here":http://www.dependencywalker.com/
Hope this helps!
I was using MinGW, and ran into that exact problem, so I switched to MSVC.
That static linking is exactly what I wanted to know...thanks a ton. Now, can you tell me how I put that into my .pro file (if in fact that's what I do)?
I am not fond and therefore not an expert on .pro files. I think you have to add the /MT flag to the CXX flags, you'll just have to figure out the how!
OK...I added a line:
@QMAKE_CXXFLAGS += /MT@
The compiler warned me that it was overriding /MT with /MDd (which from the description on the MS page looks OK).
My executable only grew about 1K in size, though, which has me wondering if it did indeed pick up all the needed files during compilation. Running the app on my system isn't a good test (since I have all the libraries anyway), so I guess I'll have to find a system with an older version of Windows, huh?
Thanks for all the help...I think I'm at least on the right track here.