我想使用QML和Go构建一个独立的应用程序。
我静态编译了QT:
./configure -static -release -opensource -confirm-license -prefix /home/simon/projects/qt-5.6.1/ -nomake examples -nomake tests -no-cups -no-alsa -no-pulseaudio -no-egl -no-audio-backend -no-gstreamer -no-sql-mysql -no-sql-sqlite -skip qtwebengine -skip multimedia -skip qtwebsockets -skip qtwebchannel -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype -qt-harfbuzz -no-libproxy -qt-pcre -qt-xcb -qt-xkbcommon-x11 -dbus-runtime -no-mtdev -no-openssl -no-glib -no-xcursor -no-xfixes -no-xrandr -no-xinerama -no-xinput -no-iconv -no-largefile -skip qtwayland -skip qtwinextras -skip qtsvg -skip qtsensors -skip qtcanvas3d -skip qtconnectivity -no-icu
make -j2
make install
我用以下代码编译了我的应用程序:
go build --ldflags '-extldflags "-L/home/simon/projects/qt-5.6.1/lib -l qtpcre -l poly2tri -lqxcb -l qtharfbuzzng -l GL -l icuuc -l icuio -l icui18n -Wl,--no-as-needed -ldl"'
我得到的是一个与QT静态链接的可执行文件,并与libc / opengl / others动态链接:
ldd frontend
linux-vdso.so.1 (0x00007fffa295d000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007f7006012000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f7005df5000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007f7005bf1000)
libGL.so.1 => /usr/lib/libGL.so.1 (0x00007f7005980000)
libicuuc.so.57 => /usr/lib/libicuuc.so.57 (0x00007f70055d8000)
libicuio.so.57 => /usr/lib/libicuio.so.57 (0x00007f70053ca000)
libicui18n.so.57 => /usr/lib/libicui18n.so.57 (0x00007f7004f50000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f7004c4c000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007f7004a36000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f7004695000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7006399000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0x00007f7004469000)
libxcb-dri3.so.0 => /usr/lib/libxcb-dri3.so.0 (0x00007f7004266000)
libxcb-present.so.0 => /usr/lib/libxcb-present.so.0 (0x00007f7004063000)
libxcb-randr.so.0 => /usr/lib/libxcb-randr.so.0 (0x00007f7003e53000)
libxcb-xfixes.so.0 => /usr/lib/libxcb-xfixes.so.0 (0x00007f7003c4b000)
libxcb-render.so.0 => /usr/lib/libxcb-render.so.0 (0x00007f7003a3d000)
libxcb-shape.so.0 => /usr/lib/libxcb-shape.so.0 (0x00007f7003839000)
libxcb-sync.so.1 => /usr/lib/libxcb-sync.so.1 (0x00007f7003632000)
libxshmfence.so.1 => /usr/lib/libxshmfence.so.1 (0x00007f700342f000)
libglapi.so.0 => /usr/lib/libglapi.so.0 (0x00007f7003201000)
libXext.so.6 => /usr/lib/libXext.so.6 (0x00007f7002fef000)
libXdamage.so.1 => /usr/lib/libXdamage.so.1 (0x00007f7002dec000)
libXfixes.so.3 => /usr/lib/libXfixes.so.3 (0x00007f7002be6000)
libX11-xcb.so.1 => /usr/lib/libX11-xcb.so.1 (0x00007f70029e4000)
libX11.so.6 => /usr/lib/libX11.so.6 (0x00007f70026a2000)
libxcb-glx.so.0 => /usr/lib/libxcb-glx.so.0 (0x00007f7002486000)
libxcb-dri2.so.0 => /usr/lib/libxcb-dri2.so.0 (0x00007f7002281000)
libxcb.so.1 => /usr/lib/libxcb.so.1 (0x00007f7002058000)
libXxf86vm.so.1 => /usr/lib/libXxf86vm.so.1 (0x00007f7001e52000)
libdrm.so.2 => /usr/lib/libdrm.so.2 (0x00007f7001c43000)
libicudata.so.57 => /usr/lib/libicudata.so.57 (0x00007f70001c7000)
libXau.so.6 => /usr/lib/libXau.so.6 (0x00007f6ffffc3000)
libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x00007f6fffdbd000)
但是当我尝试运行它时:
./frontend
2016/06/13 19:49:18 .:0: QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3" since plugins are disabled in static builds
2016/06/13 19:49:18 .:0: This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".
Reinstalling the application may fix this problem.
SIGABRT: abort
PC=0x7f85aa7fc295 m=0
signal arrived during cgo execution
goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x7d9df0, 0xc82004be10, 0x0)
/usr/lib/go/src/runtime/cgocall.go:123 +0x11b fp=0xc82004bde8 sp=0xc82004bdb8
gopkg.in/qml%2ev1._Cfunc_newGuiApplication()
??:0 +0x36 fp=0xc82004be10 sp=0xc82004bde8
gopkg.in/qml%2ev1.Run(0xc82000b240, 0x0, 0x0)
/home/simon/go/src/gopkg.in/qml.v1/bridge.go:55 +0x10f fp=0xc82004be68 sp=0xc82004be10
main.main()
/home/simon/go/src/github.com/ProtonMail/Desktop-Import/frontend/main.go:52 +0x2d3 fp=0xc82004bf50 sp=0xc82004be68
runtime.main()
/usr/lib/go/src/runtime/proc.go:188 +0x2b0 fp=0xc82004bfa0 sp=0xc82004bf50
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc82004bfa8 sp=0xc82004bfa0
goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/usr/lib/go/src/runtime/asm_amd64.s:1998 +0x1
rax 0x0
rbx 0x7ffc69a64030
rcx 0x7f85aa7fc295
rdx 0x6
rdi 0x359b
rsi 0x359b
rbp 0x407b270
rsp 0x7ffc69a63cd8
r8 0x211f1e0
r9 0x8
r10 0x8
r11 0x202
r12 0x7ffc69a63ff0
r13 0x18
r14 0x7ffc69a64040
r15 0x7ffc69a64000
rip 0x7f85aa7fc295
rflags 0x202
cs 0x33
fs 0x0
gs 0x0
发生了什么?