[英]Qt app built with CMake compiles, but doesn't run, in Windows
I'm porting a program to Windows and I got it to compile, but when I run it, it says " Qt5Cored.dll: cannot open shared object file". 我正在将程序移植到Windows,并且可以进行编译,但是运行该程序时,它显示“ Qt5Cored.dll:无法打开共享对象文件”。
I'm setting up a Windows box to port programs I've written on Linux to Windows. 我正在设置一个Windows框,将我在Linux上编写的程序移植到Windows。 All of my C++ programs use CMake.
我所有的C ++程序都使用CMake。 After setting up Git, ssh, CMake, and MinGW, I compiled a program that uses no libraries except C++ and math and got it to run.
设置了Git,ssh,CMake和MinGW之后,我编译了一个程序,该程序除了C ++和数学之外不使用任何库,并使其运行。 I then installed Qt and cloned Mirasol ( https://github.com/phma/mirasol ; it's for teaching young children numbers) and got it to compile, but it doesn't run.
然后,我安装了Qt并克隆了Mirasol( https://github.com/phma/mirasol ;用于教育幼儿数字)并进行编译,但无法运行。
This is my build script on Windows. 这是我在Windows上的构建脚本。 Suggestions on where to install programs are welcome.
欢迎提供有关在哪里安装程序的建议。 CMake did not find Qt until I told it where to look.
直到我告诉它在哪里看,CMake才找到Qt。
#!/bin/sh
#export CMAKE_PREFIX_PATH=/c/Qt/5.13.0/lib/cmake/Qt5
export Qt5_DIR="C:/Qt/5.13.0/mingw73_64/lib/cmake/Qt5"
mkdir -p ~/build/$1
cd ~/build/$1
mkdir -p dbg
mkdir -p rel
mkdir -p ins
cd dbg
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=~ ~/src/$1
cd ../rel
cmake -GNinja -DCMAKE_INSTALL_PREFIX=~ ~/src/$1
cd ../ins
cmake -GNinja -DCMAKE_INSTALL_PREFIX=/usr/local ~/src/$1
My build script on Linux is at http://bezitopo.org/developers.html (I've since added afl and Android builds, which are irrelevant). 我在Linux上的构建脚本位于http://bezitopo.org/developers.html (此后,我添加了无关的afl和Android构建)。
On Linux, it runs fine, and "ldd mirasol" produces the following output: 在Linux上,它运行良好,并且“ ldd mirasol”产生以下输出:
linux-vdso.so.1 (0x00007ffdfe6d1000)
libQt5Widgets.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 (0x00007f714c35d000)
libQt5Gui.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f714bbf4000)
libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f714b4a9000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f714b120000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f714ad82000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f714ab6a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f714a779000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f714a55a000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007f714a2ce000)
libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f714a09c000)
libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f7149dfe000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7149be1000)
libicui18n.so.60 => /usr/lib/x86_64-linux-gnu/libicui18n.so.60 (0x00007f7149740000)
libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60 (0x00007f7149389000)
libdouble-conversion.so.1 => /usr/lib/x86_64-linux-gnu/libdouble-conversion.so.1 (0x00007f7149178000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7148f74000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f7148c5e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f714cdf9000)
libGLX.so.0 => /usr/lib/x86_64-linux-gnu/libGLX.so.0 (0x00007f7148a2d000)
libGLdispatch.so.0 => /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0 (0x00007f7148777000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f71484c3000)
libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f7148296000)
libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60 (0x00007f71466ed000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f714647b000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f7146143000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f7145f1b000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f7145d17000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f7145b11000)
libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f71458fc000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f71456f4000)
On Windows, running it produces the error 在Windows上,运行它会产生错误
C:/Users/phma/build/mirasol/dbg/mirasol.exe: error while loading shared libraries: Qt5Widgetsd.dll: cannot open shared object file: No such file or directory
and ldd produces the output 和ldd产生输出
ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffad3a20000)
KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffad3010000)
KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffad0e10000)
msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ffad3560000)
libgcc_s_seh-1.dll => /mingw64/bin/libgcc_s_seh-1.dll (0x61440000)
libstdc++-6.dll => /mingw64/bin/libstdc++-6.dll (0x6fc40000)
USER32.dll => /c/Windows/System32/USER32.dll (0x7ffad2bb0000)
win32u.dll => /c/Windows/System32/win32u.dll (0x7ffad0c30000)
GDI32.dll => /c/Windows/System32/GDI32.dll (0x7ffad2e00000)
gdi32full.dll => /c/Windows/System32/gdi32full.dll (0x7ffad1840000)
msvcp_win.dll => /c/Windows/System32/msvcp_win.dll (0x7ffad0a60000)
ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ffad0b30000)
. 。 It doesn't say "Qt5Widgetsd.dll => not found", and I don't know where the extra 'd' came from.
它没有说“ Qt5Widgetsd.dll =>找不到”,我也不知道多余的“ d”来自哪里。
ETA: I changed the build script to tell CMake to use MSYS Makefiles instead of Ninja. 预计到达时间:我更改了构建脚本,以告诉CMake使用MSYS Makefile而不是Ninja。 I still get the error.
我仍然收到错误。
ETA: I copied the DLLs to the directory where the program is compiled, and it runs. 预计到达时间:我将DLL复制到了程序编译所在的目录,并且该目录运行。 It doesn't look canonical to me, coming from Linux where the libraries are in /usr/lib/, but on Windows, in the bin directory next to the Kate binary, are many DLLs.
对于我来说,这看起来并不规范,它来自Linux,其库位于/ usr / lib /中,但是在Windows上,Kate二进制文件旁边的bin目录中有许多DLL。
Be sure to put the debug versions of the dlls (look at the d postfix of the output) near the EXE (remember that Windows adds "./" to the cwd. 确保将dll的调试版本(查看输出的d后缀)放在EXE附近(请记住Windows向cwd添加了“ ./”)。
The d postfix is because you built a debug version. d后缀是因为您构建了调试版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.