Qt的sysroot和prefix选项的实用示例 [英] What would be a pratical example of sysroot and prefix options for Qt

查看:1315
本文介绍了Qt的sysroot和prefix选项的实用示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看Qt随附的配置脚本可以运行的所有选项。 (特别是qt-everywhere-opensource-src-5.2.0)。



经过大量搜索之后,我确定这些东西充其量是文献记录不足的,所以我希望可以获得一些帮助。当我查看前缀 sysroot 配置选项的描述时:


〜/ qt-everywhere-opensource-src-5.2.0 $ ./configure -help | grep sysroot

-extprefix < dir> ...使用-sysroot时,将所有内容安装到< dir>

-sysroot < dir> ......设置< ; dir> 作为目标编译器和qmake的sysroot,还设置pkg-config路径。

-no-gcc-sysroot .....使用-sysroot时,它将禁用--sysroot传递给编译器


〜/ qt-everywhere-opensource-src-5.2.0 $ ./configure -help | grep prefix

-prefix < dir> ......这将安装与相关的所有内容。 dir>

-extprefix < dir> ...使用-sysroot时,将所有内容安装到< dir>

-hostprefix [dir] ..开发时所需的工具和库


所以我以前用过-前缀,它的功能完全符合所述。它将所有内容放置在提供的< dir> 中,然后当我使用< prefix_dir> / bin / qmake 并将其安装在目标平台上,它想在< prefix_dir> / lib 中找到所有共享库。



我的印象是,如果我使用 -sysroot ,它将安装所有内容到< sysroot_dir> 然后,当我在目标平台上安装应用程序时,它将在 / lib 中搜索。至少我希望这是真的。



现在,如果我的假设是正确的...那么 -extprefix ?他们是说如果我同时使用 -sysroot -extprefix 可以重定向到哪里好吗?



为什么我要使用 -no-gcc-sysroot 是什么原因?如果我希望将Qt库安装在 sysroot上,为什么我不希望 gcc 使用/知道相同的sysroot?



其中一些解释将是很好的,如果我能得到一些如何正确使用这些选项的实际例子,那就更好了。

解决方案

这些是在构建嵌入式平台时使用的选项。
是的,它们是一团糟。因此,这里只是部分答案:



前缀




  • 尝试并证明了方式在为Qt的当前运行平台构建Qt时,对整个Qt安装说/ usr / lib而不是/ usr / local / lib或类似版本




-sysroot / path




  • 打算为未安装在/

  • 上的系统构建Qt,例如-sysroot〜/ mysystem,其中〜/ myssytem包含
    / lib / bin等...

  • 将--sysroot传递给其他工具,例如gcc和pkg-config,因此它们将在〜/ mysystem / lib而不是/ lib中搜索其依赖项



-extprefix / b




  • 使用-sysroot / a时,不要t实际上写到/ a

  • 写qt到/ b代替

  • 这旨在针对只读sysroots进行交叉编译



-no-gcc-sysroot




  • 非常对于无法在--sysroot

  • 中找到自己的crt的编译器的特定黑客,将sysroot传递给pkgconfig和其他人,而不传递给gcc

  • so可以使用-L / sysroot / lib /正确地调用gcc,但不会在此处尝试找到隐式路径(crt)。



< h3> -hostprefix / path


  • 在为与我们当前运行的目标不同的目标进行编译时

  • qmake将是主机体系结构(例如x86),而qt本身将是目标体系结构(让我们说arm)

  • 因此将qmake放在/ path而不是-指定的目标系统中sysroot。在目标系统上没有任何作用



要增加混乱:



-R / path




  • 设置链接程序运行路径-例如QtGui查找QtCore的位置-与其他所有路径无关options



在为目标而不是主机进行编译时要使用的标志取决于configure内的大量硬编码假设。 / p>

通常-sysroot加-prefix在大多数情况下都可以使用。



ie当您拥有以下内容时:

  $ ls〜/ mytarget 
lib bin share dev

您可以只使用-sysroot〜/ mytarget -prefix /


I'm looking at all the options that can be run for the configure script provided with Qt. (specifically qt-everywhere-opensource-src-5.2.0).

After considerable searching, I've determined this stuff is poorly documented at best so I was hoping I could get some help. When I look at the descriptions for prefix and sysroot configuration options:

~/qt-everywhere-opensource-src-5.2.0$ ./configure -help | grep "sysroot"
-extprefix <dir> ... When -sysroot is used, install everything to <dir>,
-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

~/qt-everywhere-opensource-src-5.2.0$ ./configure -help | grep "prefix"
-prefix <dir> ...... This will install everything relative to <dir>
-extprefix <dir> ... When -sysroot is used, install everything to <dir>,
-hostprefix [dir] .. Tools and libraries needed when developing

So I've used -prefix before, and it did exactly as described. It placed everything at the provided <dir>, then when I built my application using <prefix_dir>/bin/qmake and installed that on my target platform it wanted to find all the shared object libraries at <prefix_dir>/lib.

I'm under the impressions that if I use -sysroot it will install everything at <sysroot_dir> then when I install my application on the target platform it will search in /lib. At least I hope that's true.

Now if my assumption is correct... then what's the point of -extprefix? Are they saying that if I can redirect where things good if I use both -sysroot and -extprefix?

And what would be a reason why I would want to use -no-gcc-sysroot? If I wanted my Qt libs to be installed at "sysroot" why wouldn't I want gcc to use/know the same sysroot?

An explanation of some of these would be great, even better if I can get some practical examples of how to correctly use these options.

解决方案

These are options that are used when building embedded platforms. Yes they are a royal mess. So here's only a partial answer:

-prefix

  • tried and proven way to say /usr/lib instead of /usr/local/lib or similar for the entire installation of Qt
  • when Qt is built for the platform it is currently running on (typical for desktop)

-sysroot /path

  • intends to build Qt for a system which isn't installed at /
  • for example -sysroot ~/mysystem where ~/myssytem contains /lib /bin etc...
  • will pass --sysroot to other tools, like gcc and pkg-config, so they will search for their dependencies in ~/mysystem/lib rather than /lib

-extprefix /b

  • when using -sysroot /a, don't actually write to /a
  • write qt to /b instead
  • this is intended for cross-compiling against read-only sysroots

-no-gcc-sysroot

  • very specific hack for compilers that can't find their own crt inside --sysroot
  • passes sysroot to pkgconfig and others, but not to gcc
  • so that gcc will be called with -L/sysroot/lib/ correctly, but doesn't try to find implicit paths (crt) here.

-hostprefix /path

  • when compiling for a different target than we are currently running on
  • qmake will be the host architecture (for example x86) and qt itself will be the target architecture (lets say arm)
  • so put qmake in /path instead of the target system specified by -sysroot. it won't be any useful on the target system

To add to the confusion:

-R /path

  • sets the linkers runpath - which is where QtGui finds QtCore for example - independant of all the other options

Which flags you want to use when compiling for a target not your host, depends on a boatload of hardcoded assumptions inside configure.

generally -sysroot plus -prefix should work for most use cases.

i.e. when you have:

 $ ls ~/mytarget
 lib bin share dev

you could just use -sysroot ~/mytarget -prefix /

这篇关于Qt的sysroot和prefix选项的实用示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆