Ubuntu 14.04 LTS + Qt 5.2.1 源码编译搭建环境
来源:互联网 发布:adb for mac安装教程 编辑:程序博客网 时间:2024/06/05 05:22
配置
配置选项
+ cd qtbase+ /home/liu/sfw/qt-everywhere-opensource-src-5.2.1/qtbase/configure -top-level -hUsage: configure [options]Installation options: These are optional, but you may specify install directories. -prefix <dir> ...... This will install everything relative to <dir> (default /usr/local/Qt-5.2.1, $PWD if -developer-build is active) -extprefix <dir> ... When -sysroot is used, install everything to <dir>, rather than into SYSROOT/PREFIX. -hostprefix [dir] .. Tools and libraries needed when developing applications are installed in [dir]. If [dir] is not given, the current build directory will be used. (default EXTPREFIX) You may use these to separate different parts of the install: -bindir <dir> ......... User executables will be installed to <dir> (default PREFIX/bin) -headerdir <dir> ...... Headers will be installed to <dir> (default PREFIX/include) -libdir <dir> ......... Libraries will be installed to <dir> (default PREFIX/lib) -archdatadir <dir> .... Arch-dependent data used by Qt will be installed to <dir> (default PREFIX) -plugindir <dir> ...... Plugins will be installed to <dir> (default ARCHDATADIR/plugins) -libexecdir <dir> ..... Program executables will be installed to <dir> (default ARCHDATADIR/libexec, ARCHDATADIR/bin for MinGW) -importdir <dir> ...... Imports for QML1 will be installed to <dir> (default ARCHDATADIR/imports) -qmldir <dir> ......... Imports for QML2 will be installed to <dir> (default ARCHDATADIR/qml) -datadir <dir> ........ Arch-independent data used by Qt will be installed to <dir> (default PREFIX) -docdir <dir> ......... Documentation will be installed to <dir> (default DATADIR/doc) -translationdir <dir> . Translations of Qt programs will be installed to <dir> (default DATADIR/translations) -sysconfdir <dir> ..... Settings used by Qt programs will be looked for in <dir> (default PREFIX/etc/xdg) -examplesdir <dir> .... Examples will be installed to <dir> (default PREFIX/examples) -testsdir <dir> ....... Tests will be installed to <dir> (default PREFIX/tests) -hostbindir <dir> .. Host executables will be installed to <dir> (default HOSTPREFIX/bin) -hostlibdir <dir> .. Host libraries will be installed to <dir> (default HOSTPREFIX/lib) -hostdatadir <dir> . Data used by qmake will be installed to <dir> (default HOSTPREFIX)Configure options: The defaults (*) are usually acceptable. A plus (+) denotes a default value that needs to be evaluated. If the evaluation succeeds, the feature is included. Here is a short explanation of each option: * -release ........... Compile and link Qt with debugging turned off. -debug ............. Compile and link Qt with debugging turned on. -debug-and-release . Compile and link two versions of Qt, with and without debugging turned on (Mac only). -force-debug-info .. Create symbol files for release builds. -developer-build ... Compile and link Qt with Qt developer options (including auto-tests exporting) -opensource ........ Compile and link the Open-Source Edition of Qt. -commercial ........ Compile and link the Commercial Edition of Qt. -confirm-license ... Automatically acknowledge the license (use with either -opensource or -commercial) -no-c++11 .......... Do not compile Qt with C++11 support enabled. + -c++11 ............. Compile Qt with C++11 support enabled. * -shared ............ Create and use shared Qt libraries. -static ............ Create and use static Qt libraries. * -process ........... Generate only a top-level Makefile. -fully-process ..... Generate Makefiles for the entire Qt tree. -dont-process ...... Do not generate any Makefiles. -no-largefile ...... Disables large file support. + -largefile ......... Enables Qt to access files larger than 4 GB. -no-accessibility .. Do not compile Accessibility support. Disabling accessibility is not recommended, as it will break QStyle and may break other internal parts of Qt. With this switch you create a source incompatible version of Qt, which is unsupported. + -accessibility ..... Compile Accessibility support. -no-sql-<driver> ... Disable SQL <driver> entirely. -qt-sql-<driver> ... Enable a SQL <driver> in the Qt SQL module, by default none are turned on. -plugin-sql-<driver> Enable SQL <driver> as a plugin to be linked to at run time. Possible values for <driver>: [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ] -system-sqlite ..... Use sqlite from the operating system. -no-javascript-jit . Do not build the JavaScriptCore JIT compiler. + -javascript-jit .... Build the JavaScriptCore JIT compiler. -no-qml-debug ...... Do not build the in-process QML debugging support. + -qml-debug ......... Build the QML debugging support. -platform target ... The operating system and compiler you are building on (default detected from host system). See the README file for a list of supported operating systems and compilers. -no-sse2 ........... Do not compile with use of SSE2 instructions. -no-sse3 ........... Do not compile with use of SSE3 instructions. -no-ssse3 .......... Do not compile with use of SSSE3 instructions. -no-sse4.1 ......... Do not compile with use of SSE4.1 instructions. -no-sse4.2 ......... Do not compile with use of SSE4.2 instructions. -no-avx ............ Do not compile with use of AVX instructions. -no-avx2 ........... Do not compile with use of AVX2 instructions. -no-neon ........... Do not compile with use of NEON instructions. -no-mips_dsp ....... Do not compile with use of MIPS DSP instructions. -no-mips_dspr2 ..... Do not compile with use of MIPS DSP rev2 instructions. -qtnamespace <name> Wraps all Qt library code in 'namespace <name> {...}'. -qtlibinfix <infix> Renames all libQt*.so to libQt*<infix>.so. -testcocoon ........ Instrument Qt with the TestCocoon code coverage tool. -gcov .............. Instrument Qt with the GCov code coverage tool. -D <string> ........ Add an explicit define to the preprocessor. -I <string> ........ Add an explicit include path. -L <string> ........ Add an explicit library path. + -pkg-config ........ Use pkg-config to detect include and library paths. By default, configure determines whether to use pkg-config or not with some heuristics such as checking the environment variables. -no-pkg-config ..... Disable use of pkg-config. -force-pkg-config .. Force usage of pkg-config (skips pkg-config usability detection heuristic). -help, -h .......... Display this information.Third Party Libraries: -qt-zlib ........... Use the zlib bundled with Qt. + -system-zlib ....... Use zlib from the operating system. See http://www.gzip.org/zlib -no-mtdev ......... Do not compile mtdev support. + -mtdev ............. Enable mtdev support. -no-gif ............ Do not compile GIF reading support. -no-libpng ......... Do not compile PNG support. -qt-libpng ......... Use the libpng bundled with Qt. + -system-libpng ..... Use libpng from the operating system. See http://www.libpng.org/pub/png -no-libjpeg ........ Do not compile JPEG support. -qt-libjpeg ........ Use the libjpeg bundled with Qt. + -system-libjpeg .... Use libjpeg from the operating system. See http://www.ijg.org -no-freetype ....... Do not compile in Freetype2 support. -qt-freetype ....... Use the libfreetype bundled with Qt. + -system-freetype.... Use the libfreetype provided by the system (enabled if -fontconfig is active). See http://www.freetype.org * -no-harfbuzz ....... Do not compile HarfBuzz-NG support. -qt-harfbuzz ....... (experimental) Use HarfBuzz-NG bundled with Qt to do text shaping. It can still be disabled by setting QT_HARFBUZZ environment variable to "old". -system-harfbuzz ... (experimental) Use HarfBuzz-NG from the operating system to do text shaping. It can still be disabled by setting QT_HARFBUZZ environment variable to "old". -no-openssl ........ Do not compile support for OpenSSL. + -openssl ........... Enable run-time OpenSSL support. -openssl-linked .... Enabled linked OpenSSL support. -qt-pcre ........... Use the PCRE library bundled with Qt. + -system-pcre ....... Use the PCRE library from the operating system. -qt-xcb ............ Use xcb- libraries bundled with Qt. (libxcb.so will still be used from operating system). + -system-xcb ........ Use xcb- libraries from the operating system. -qt-xkbcommon ...... Use the xkbcommon library bundled with Qt. + -system-xkbcommon .. Use the xkbcommon library from the operating system. -no-xinput2 ........ Do not compile XInput2 support. * -xinput2 ........... Compile XInput2 support. -no-xcb-xlib........ Do not compile Xcb-Xlib support. * -xcb-xlib........... Compile Xcb-Xlib support. -no-glib ........... Do not compile Glib support. + -glib .............. Compile Glib support.Additional options: -make <part> ....... Add part to the list of parts to be built at make time. (defaults to: libs tools examples) -nomake <part> ..... Exclude part from the list of parts to be built. -skip <module> ..... Exclude an entire module from the build. -no-compile-examples ... Install only the sources of examples. -no-gui ............ Don't build the Qt GUI module and dependencies. + -gui ............... Build the Qt GUI module and dependencies. -no-widgets ........ Don't build the Qt Widgets module and dependencies. + -widgets ........... Build the Qt Widgets module and dependencies. -R <string> ........ Add an explicit runtime library path to the Qt libraries. -l <string> ........ Add an explicit library. -no-rpath .......... Do not use the library install path as a runtime library path. + -rpath ............. Link Qt libraries and executables using the library install path as a runtime library path. Equivalent to -R install_libpath -continue .......... Continue as far as possible if an error occurs. -verbose, -v ....... Print verbose information about each step of the configure process. -silent ............ Reduce the build output so that warnings and errors can be seen more easily. * -no-optimized-qmake ... Do not build qmake optimized. -optimized-qmake ...... Build qmake optimized. -no-nis ............ Do not compile NIS support. * -nis ............... Compile NIS support. -no-cups ........... Do not compile CUPS support. * -cups .............. Compile CUPS support. Requires cups/cups.h and libcups.so.2. -no-iconv .......... Do not compile support for iconv(3). * -iconv ............. Compile support for iconv(3). -no-icu ............ Do not compile support for ICU libraries. + -icu ............... Compile support for ICU libraries. -no-fontconfig ..... Do not compile FontConfig support. + -fontconfig ........ Compile FontConfig support. -no-strip .......... Do not strip binaries and libraries of unneeded symbols. * -strip ............. Strip binaries and libraries of unneeded symbols when installing. * -no-pch ............ Do not use precompiled header support. -pch ............... Use precompiled header support. -no-dbus ........... Do not compile the Qt D-Bus module. + -dbus .............. Compile the Qt D-Bus module and dynamically load libdbus-1. -dbus-linked ....... Compile the Qt D-Bus module and link to libdbus-1. -reduce-relocations ..... Reduce relocations in the libraries through extra linker optimizations (Qt/X11 and Qt for Embedded Linux only; experimental; needs GNU ld >= 2.18). -force-asserts ........ Force Q_ASSERT to be enabled even in release builds. -device <name> ............... Cross-compile for device <name> (experimental) -device-option <key=value> ... Add device specific options for the device mkspec (experimental) -no-separate-debug-info . Do not store debug information in a separate file. * -separate-debug-info .... Strip debug information into a separate file. -no-xcb ............ Do not compile Xcb (X protocol C-language Binding) support. * -xcb ............... Compile Xcb support. -no-eglfs .......... Do not compile EGLFS (EGL Full Screen/Single Surface) support. * -eglfs ............. Compile EGLFS support. -no-directfb ....... Do not compile DirectFB support. * -directfb .......... Compile DirectFB support. -no-linuxfb ........ Do not compile Linux Framebuffer support. * -linuxfb ........... Compile Linux Framebuffer support. -no-kms ............ Do not compile KMS support. * -kms ............... Compile KMS support (Requires EGL). -qpa <name> ......... Sets the default QPA platform (e.g xcb, cocoa, windows). -xplatform target ... The target platform when cross-compiling. -sysroot <dir> ...... Sets <dir> as the target compiler's and qmake's sysroot and also sets pkg-config paths. -no-gcc-sysroot ..... When using -sysroot, it disables the passing of --sysroot to the compiler -no-feature-<feature> Do not compile in <feature>. -feature-<feature> .. Compile in <feature>. The available features are described in src/corelib/global/qfeatures.txt -qconfig local ...... Use src/corelib/global/qconfig-local.h rather than the default (full). -qreal [double|float] typedef qreal to the specified type. The default is double. Note that changing this flag affects binary compatibility. -no-opengl .......... Do not support OpenGL. -opengl <api> ....... Enable OpenGL support With no parameter, this will attempt to auto-detect OpenGL ES 2, or regular desktop OpenGL. Use es2 for <api> to override auto-detection. * -no-system-proxies .. Do not use system network proxies by default. -system-proxies ..... Use system network proxies by default. -no-warnings-are-errors Make warnings be treated normally -warnings-are-errors Make warnings be treated as errors (enabled if -developer-build is active)QNX/Blackberry options: -no-slog2 .......... Do not compile with slog2 support. -slog2 ............. Compile with slog2 support. -no-pps ............ Do not compile with pps support. -pps ............... Compile with pps support.MacOS/iOS options: -Fstring ........... Add an explicit framework path. -fw string ......... Add an explicit framework. * -framework ......... Build Qt as a series of frameworks and link tools against those frameworks. -no-framework ...... Do not build Qt as a series of frameworks. -sdk <sdk> ......... Build Qt using Apple provided SDK <sdk>. The argument should be one of the available SDKs as listed by 'xcodebuild -showsdks'. Note that the argument applies only to Qt libraries and applications built using the target mkspec - not host tools such as qmake, moc, rcc, etc.Android options: -android-sdk path .............. The Android SDK root path. (default $ANDROID_SDK_ROOT) -android-ndk path .............. The Android NDK root path. (default $ANDROID_NDK_ROOT) -android-ndk-platform .......... Sets the android platform (default android-9) -android-ndk-host .............. Sets the android NDK host (linux-x86, linux-x86_64, etc.) (default $ANDROID_NDK_HOST) -android-arch .................. Sets the android architecture (armeabi, armeabi-v7a, x86, mips) (default armeabi-v7a) -android-toolchain-version ..... Sets the android toolchain version (default 4.8)
Desktop版
./configure -static -debug-and-release -nomake examples -linuxfb -prefix /usr/local/Qt-Desktop-5.2.1
配置后的 summary 如下:
Configure summaryBuild type: linux-g++ (x86_64, CPU features: mmx sse sse2)Platform notes: - Also available for Linux: linux-kcc linux-icc linux-cxxBuild options: Configuration .......... accessibility audio-backend avx avx2 c++11 clock-gettime clock-monotonic compile_examples concurrent egl eglfs evdev eventfd fontconfig full-config getaddrinfo getifaddrs gif glib gtk2 gtkstyle iconv icu inotify ipv6ifname jpeg large-config largefile linuxfb medium-config minimal-config mremap nis no-harfbuzz opengl openssl pcre png posix_fallocate precompile_header qpa qpa reduce_exports reduce_relocations release rpath small-config sse2 sse3 sse4_1 sse4_2 ssse3 static system-freetype system-jpeg system-png system-zlib xcb xcb-glx xcb-render xcb-sm xcb-xlib xinput2 xkbcommon-qt xlib xrender Build parts ............ libs tools Mode ................... release Using C++11 ............ yes Using PCH .............. yes Target compiler supports: SSE2/SSE3/SSSE3 ...... yes/yes/yes SSE4.1/SSE4.2 ........ yes/yes AVX/AVX2 ............. yes/yesQt modules and options: Qt D-Bus ............... no Qt Concurrent .......... yes Qt GUI ................. yes Qt Widgets ............. yes JavaScriptCore JIT ..... yes (To be decided by JavaScriptCore) QML debugging .......... yes Use system proxies ..... noSupport enabled for: Accessibility .......... yes ALSA ................... no CUPS ................... no FontConfig ............. yes FreeType ............... system Iconv .................. yes ICU .................... yes Image formats: GIF .................. yes (in QtGui, using bundled copy) JPEG ................. yes (in QtGui, using system library) PNG .................. yes (in QtGui, using system library) Glib ................... yes GTK theme .............. yes Large File ............. yes mtdev .................. no Networking: getaddrinfo .......... yes getifaddrs ........... yes IPv6 ifname .......... yes OpenSSL .............. yes (loading libraries at run-time) NIS .................... yes OpenGL ................. desktop OpenVG ................. no PCRE ................... yes (bundled copy) pkg-config ............. yes PulseAudio ............. no QPA backends: DirectFB ............. no EGLFS ................ yes KMS .................. no LinuxFB .............. yes XCB .................. yes (system library) MIT-SHM ............ yes Xcb-Xlib ........... yes Xcursor ............ yes (loaded at runtime) Xfixes ............. yes (loaded at runtime) Xi ................. no Xi2 ................ yes Xinerama ........... yes (loaded at runtime) Xrandr ............. yes (loaded at runtime) Xrender ............ yes XKB ................ yes XShape ............. yes XSync .............. yes XVideo ............. yes Session management ..... yes SQL drivers: DB2 .................. no InterBase ............ no MySQL ................ no OCI .................. no ODBC ................. no PostgreSQL ........... no SQLite 2 ............. no SQLite ............... yes (plugin, using bundled copy) TDS .................. no udev ................... no xkbcommon .............. yes (bundled copy) zlib ................... yes (system library)WARNING: Using static linking will disable the use of dynamicallyloaded plugins. Make sure to import all needed static plugins,or compile needed modules into the library.NOTE: libxkbcommon 0.2.0 (or higher) not found on the system, will use the bundled version from 3rd party directory.Info: creating super cache file /home/liu/sfw/qt-everywhere-opensource-src-5.2.1/.qmake.superQt is now configured for building. Just run 'make'.Once everything is built, you must run 'make install'.Qt will be installed into /usr/local/Qt-Desktop-5.2.1Prior to reconfiguration, make sure you remove any leftovers fromthe previous build.
这里虽然使用了 -linuxfb
标识, 但 Ubuntu 系统 貌似使用的 xcb
, 所以使用 linuxfb
运行 Qt 程序会出错, 如下所示:
$ ./HelloWorld -platform linuxfbOK, I'm running in Xilinx Zynq!This application failed to start because it could not find or load the Qt platform plugin "linuxfb".Available platform plugins are: xcb.Reinstalling the application may fix this problem.已放弃 (核心已转储)./HelloWorld -platform EGLFSOK, I'm running in Xilinx Zynq!This application failed to start because it could not find or load the Qt platform plugin "eglfs".Available platform plugins are: xcb.Reinstalling the application may fix this problem.已放弃 (核心已转储)$ ./HelloWorld -platform xcbOK, I'm running in Xilinx Zynq!OK, I'm running in Xilinx Zynq!---
使用 ./HelloWorld -platform xcb
与 ./HelloWorld
效果一致, 如下:
嵌入式ARM版
./configure -prefix /usr/local/Qt/Embedded/5.2.1 \-device linux-arm-xilinx-zynq-g++ \-device-option CROSS_COMPILE=/home/liu/sfw/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/bin/arm-xilinx-linux-gnueabi- \-release \-opensource \-confirm-license \-no-c++11 \-shared \-force-pkg-config \-qt-libpng \-qt-libjpeg \-qt-freetype \-qt-harfbuzz \-qt-xcb \-qt-xkbcommon \-xcb-xlib \-nomake examples \-no-compile-examples \-gui \-widgets \-xcb \-qreal float \-verbose
./configure -prefix /usr/local/Qt/Embedded/5.2.1 \-release \-opensource \-confirm-license \-no-c++11 \-shared \-force-pkg-config \-qt-libpng \-qt-libjpeg \-qt-freetype \-qt-harfbuzz \-no-xinput2 \-no-xcb-xlib \-nomake examples \-no-compile-examples \-gui \-widgets \-no-xcb \-linuxfb \-qreal float \-verbose
# Sourcery CodeBench Lite for Xilinx GNU Linux export ARCH=ARMexport PATH=$PATH:/home/liu/sfw/CodeSourcery/Sourcery_CodeBench_Lite_for_Xilinx_GNU_Linux/binexport CROSS_COMPILE=arm-xilinx-linux-gnueabi-export LD_LIBRARY_PATH=/home/liu/sfw/local:$LD_LIBRARY_PATHexport HOST=arm-xilinx-linux-gnueabiexport PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR:/home/liu/sfw/local/lib/pkgconfigexport PKG_CONFIG_SYSROOT_DIR=$PKG_CONFIG_SYSROOT_DIR:/home/liu/local/libexport PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/liu/sfw/local/lib/pkgconfig#export PKG_CONFIG_PATH=/media/liu/ROOTFS/usr/lib/pkgconfig:$PKG_CONFIG_PATHexport XCBPROTO_LIBS=/home/liu/sfw/local:$XCBPROTO_LIBSexport QTDIR=/usr/local/Qt/Desktop/5.2.1export QT_QPA_FONTDIR=$QTDIR/lib/fonts export QT_QPA_PLATFORM_PLUGIN_PATH=$QTDIR/plugins/ export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
./configure --prefix=/Qt-5.2.1 -no-c++11 -no-qml-debug -xplatform linux-arm-xilinx-zynq-g++ -qt-freetype -no-opengl -qt-pcre -nomake tests -nomake examples -sysroot /home/liu/sfw/local/ -v
http://blog.csdn.net/tracing/article/details/49951633
filestringsldd
交叉编译后的 ARM 版程序 在 PC 机上的运行结果
$ ./HelloWorld bash: ./HelloWorld: cannot execute binary file: 可执行文件格式错误$ $ file HelloWorld HelloWorld: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped$ $ ldd HelloWorld 不是动态可执行文件$ $ readelf -d HelloWorld | grep NEEDED 0x00000001 (NEEDED) 共享库:[libQt5Widgets.so.5] 0x00000001 (NEEDED) 共享库:[libQt5Gui.so.5] 0x00000001 (NEEDED) 共享库:[libQt5Core.so.5] 0x00000001 (NEEDED) 共享库:[libpthread.so.0] 0x00000001 (NEEDED) 共享库:[libstdc++.so.6] 0x00000001 (NEEDED) 共享库:[libm.so.6] 0x00000001 (NEEDED) 共享库:[libgcc_s.so.1] 0x00000001 (NEEDED) 共享库:[libc.so.6]$
Qt交叉编译移植问题实例
交叉编译后的 ARM 版程序 移植到 ARM 上的运行结果
root@localhost:/home# ./HelloWorld root@localhost:/home# root@localhost:/home# file HelloWorld HelloWorld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not strippedroot@localhost:/home# root@localhost:/home# root@localhost:/home# readelf -d HelloWorld | grep NEEDED 0x00000001 (NEEDED) Shared library: [libQt5Widgets.so.5] 0x00000001 (NEEDED) Shared library: [libQt5Gui.so.5] 0x00000001 (NEEDED) Shared library: [libQt5Core.so.5] 0x00000001 (NEEDED) Shared library: [libpthread.so.0] 0x00000001 (NEEDED) Shared library: [libstdc++.so.6] 0x00000001 (NEEDED) Shared library: [libm.so.6] 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x00000001 (NEEDED) Shared library: [libc.so.6]root@localhost:/home#
PC 版程序在 PC 上的运行结果
$ ./HelloWorld OK, I'm running in Xilinx Zynq!Hello!Over!OK, I'm running in Xilinx Zynq!---Over!$ $ ldd HelloWorld linux-vdso.so.1 => (0x00007ffe921ec000) libQt5Widgets.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 (0x00007f26d5ef3000) libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f26d584d000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f26d5549000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f26d5333000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f26d4f6e000) libQt5Gui.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 (0x00007f26d4921000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f26d4703000) libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f26d44b2000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f26d41aa000) libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f26d3e75000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f26d3b6f000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f26d3956000) libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007f26d354f000) libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007f26d31d6000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f26d2fd2000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f26d2dca000) /lib64/ld-linux-x86-64.so.2 (0x00007f26d671c000) libpng12.so.0 => /usr/local/lib/libpng12.so.0 (0x00007f26d2ba3000) libharfbuzz.so.0 => /usr/lib/x86_64-linux-gnu/libharfbuzz.so.0 (0x00007f26d294e000) libGL.so.1 => /usr/lib/nvidia-346/libGL.so.1 (0x00007f26d25f6000) libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f26d23ee000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f26d21b0000) libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f26d1f91000) libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007f26d0724000) libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f26d0481000) libgraphite2.so.3 => /usr/lib/x86_64-linux-gnu/libgraphite2.so.3 (0x00007f26d025b000) libnvidia-tls.so.346.82 => /usr/lib/nvidia-346/tls/libnvidia-tls.so.346.82 (0x00007f26d0058000) libnvidia-glcore.so.346.82 => /usr/lib/nvidia-346/libnvidia-glcore.so.346.82 (0x00007f26cd37a000) libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f26cd168000) libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f26ccf64000) libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f26ccd5e000)$ readelf -d HelloWorld | grep NEEDED 0x0000000000000001 (NEEDED) 共享库:[libQt5Widgets.so.5] 0x0000000000000001 (NEEDED) 共享库:[libQt5Core.so.5] 0x0000000000000001 (NEEDED) 共享库:[libstdc++.so.6] 0x0000000000000001 (NEEDED) 共享库:[libgcc_s.so.1] 0x0000000000000001 (NEEDED) 共享库:[libc.so.6]
PC 版程序在 ARM 上的运行结果
root@localhost:/home/c# root@localhost:/home/c# ./HelloWorld -bash: ./HelloWorld: cannot execute binary fileroot@localhost:/home/c# root@localhost:/home/c# file HelloWorld HelloWorld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xa895531919379c0e9430d50d5068677ebd2a774f, not strippedroot@localhost:/home/c# root@localhost:/home/c# root@localhost:/home/c# readelf -d HelloWorld | grep NEEDED 0x0000000000000001 (NEEDED) Shared library: [libQt5Widgets.so.5] 0x0000000000000001 (NEEDED) Shared library: [libQt5Core.so.5] 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6] 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]root@localhost:/home/c#
可是 下面的 led-test
程序运行正常:
root@localhost:/home# ./led-test [usr_led1] Get trigger: 'none'[usr_led1] Set trigger to 'none'[usr_led2] Get trigger: 'none'[usr_led2] Set trigger to 'none'[ led_r] Get trigger: 'heartbeat'[ led_r] Set trigger to 'none'[ led_g] Get trigger: 'heartbeat'[ led_g] Set trigger to 'none'[ led_b] Get trigger: 'heartbeat'[ led_b] Set trigger to 'none'^C[usr_led1] Set trigger to 'none'[usr_led2] Set trigger to 'none'[ led_r] Set trigger to 'heartbeat'[ led_g] Set trigger to 'heartbeat'[ led_b] Set trigger to 'heartbeat'root@localhost:/home# file led-test led-test: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not strippedroot@localhost:/home# ldd led-test not a dynamic executableroot@localhost:/home# readelf -d led-test | grep NEEDED 0x00000001 (NEEDED) Shared library: [libgcc_s.so.1] 0x00000001 (NEEDED) Shared library: [libc.so.6]root@localhost:/home#
目标机上编译动态库
root@localhost:/home/c# gcc -shared -fPIC caculate.c -o libcac.soroot@localhost:/home/c# gcc main.c -o main -L ./ -lcacroot@localhost:/home/c# ./main./main: error while loading shared libraries: libcac.so: cannot open shared object file: No such file or directoryroot@localhost:/home/c# lsHelloWorld caculate.c~ caculate.h~ main main.c~ testgtk.ccaculate.c caculate.h libcac.so main.c mainpcroot@localhost:/home/c# file libcac.so libcac.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x8611c5e0a1dd10e2e05a95b23a840b72c50f45dc, not strippedroot@localhost:/home/c# file mainmain: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, BuildID[sha1]=0xeee4bf52cdf3ec37387ac960b9d0f90313add90c, not strippedroot@localhost:/home/c# ldd main libcac.so => not found libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6e4a000) /lib/ld-linux-armhf.so.3 (0xb6f40000)root@localhost:/home/c# suroot@localhost:/home/c# gcc -shared -fPIC caculate.c -o libcac.soroot@localhost:/home/c# gcc main.c -o main -L ./ -lcacroot@localhost:/home/c# ./main./main: error while loading shared libraries: libcac.so: cannot open shared object file: No such file or directoryroot@localhost:/home/c# lsHelloWorld caculate.c~ caculate.h~ main main.c~ testgtk.ccaculate.c caculate.h libcac.so main.c mainpcroot@localhost:/home/c# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/c/root@localhost:/home/c# lsHelloWorld caculate.c~ caculate.h~ main main.c~ testgtk.ccaculate.c caculate.h libcac.so main.c mainpcroot@localhost:/home/c# ./main20 + 10 = 3020 - 10 = 1020 / 10 = 220 * 10 = 200root@localhost:/home/c# cd ..
0 0
- Ubuntu 14.04 LTS + Qt 5.2.1 源码编译搭建环境
- ubuntu qt编译环境搭建
- ubuntu 14.04 LTS Desktop 搭建LAMP环境
- ubuntu 14.04 lts 搭建android studio 环境
- Ubuntu 14.04 LTS 搭建Swift编程环境
- Ubuntu 14.04 LTS 搭建汇编语言环境
- Ubuntu 14.04 搭建MTK Android源码编译环境搭建
- Ubuntu 14.04 LTS嵌入式交叉编译环境arm-linux-gcc搭建过程图解
- Ubuntu下android源码编译环境搭建
- Ubuntu Android源码编译环境搭建
- Ubuntu+Virtualbox Android源码编译环境搭建
- ubuntu下安卓源码编译环境的搭建
- Ubuntu搭建Android源码编译环境
- Ubuntu 15.10 编译Android源码环境搭建
- Ubuntu android源码编译环境搭建
- ubuntu 安卓源码编译环境搭建
- Ubuntu 14.04 LTS + Qt 4.7.3 交叉编译
- Linux 14.04lts 环境下搭建交叉编译环境arm-linux-gcc-4.5.1
- 嵌入式开发为什么选择C语言
- linux静态ip
- android listView 重要属性
- Layer 一款web弹层组件(弹出层、日期选择、分页、LayIM接口文档)
- 3.redis实战:redis自动备份与备份管理
- Ubuntu 14.04 LTS + Qt 5.2.1 源码编译搭建环境
- <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />是什么意思
- Generic receive offload
- DPM--对象检测开山之作
- java File流使用
- RCNN--对象检测的又一伟大跨越
- ETL数据导入/导出工具 HData
- Git远程操作详解
- SAP 将smartforms的报表转成PDF