[Qt-creator] Link errors when building on linux
Frank Miller
cfrankmiller at gmail.com
Thu Oct 26 17:08:29 CEST 2017
Thanks Christian!
> As to why the build breakage does not seem to occur to anyone else:
> I'd assume the compiler optimizes out the code paths where the Msvc* is
> accessed, as it can determine statically that the conditions evaluate to
> false. No idea why it doesn't do that on your system, though.
That it! Turns out that I was building without any optimization flags.
This was not my intention so I'm glad to become aware of it. Thanks!
I'm not much of a qmake user so I don't really know what I'm doing. I'm
building qt-creator against a build of qt installed in $prefix and in
order to get it to work I had to call qmake like this:
$prefix/bin/qmake -r \
QMAKE_CFLAGS_RELEASE="-I$prefix/include" \
QMAKE_CXXFLAGS_RELEASE="-I$prefix/include" \
QMAKE_LFLAGS_RELEASE="-L$prefix/lib" \
$srcDir
I guess this is incorrect. Perhaps, setting the *_RELEASE flags like
this replaces all the flags (unlike cmake which has a generic CXXFLAGS
that has the -O flags). If I add -02 like so:
$prefix/bin/qmake -r \
QMAKE_CFLAGS_RELEASE="-O2 -I$prefix/include" \
QMAKE_CXXFLAGS_RELEASE="-O2 -I$prefix/include" \
QMAKE_LFLAGS_RELEASE="-L$prefix/lib" \
$srcDir
then it builds without any changes to the code. I'm happy now.
> Yes, you are right. It seems commit 4b8564cb42 introduced this issue.
> Note that that commit is also conceptually wrong, as the target system
> is relevant for the choice which functionality to include, not the host.
> For instance, if you built Creator with mingw on Linux (which we don't
> do), then MSVC support would be missing from the resulting binaries.
> Any chance for you to push it to gerrit?
I have never used gerrit before but I would be willing. I don't really
intend to do much hacking on qt-creator but you never know. However, I
agree with your assessment that commit 4b8564cb42 is conceptually wrong
and the same argument applies to my change (which looks to be
essentially undoing that change).
How does one determine the target system?
Frank
On Thu, Oct 26, 2017 at 3:10 AM, Christian Kandeler <
christian.kandeler at qt.io> wrote:
> On Wed, 25 Oct 2017 22:06:10 -0500
> Frank Miller <cfrankmiller at gmail.com> wrote:
>
> > I'm new to qt-creator and would like to build from the source on linux
> > but I am experiencing a curious linker error. I get the same error on
> > the 4.3, 4.4, 4.5, and master git branches. The error message looks like
> > this:
> >
> > .obj/release-shared/projectexplorer.o: In function
> > `ProjectExplorer::ProjectExplorerPlugin::initialize(QStringList const&,
> > QString*)':
> > projectexplorer.cpp:(.text+0x216f): undefined reference to
> > `ProjectExplorer::Internal::WinDebugInterface::
> WinDebugInterface(QObject*)'
> > projectexplorer.cpp:(.text+0x2196): undefined reference to
> > `ProjectExplorer::Internal::MsvcToolChainFactory::
> MsvcToolChainFactory()'
> > collect2: error: ld returned 1 exit status
> >
> > I would be happy to provide the usual system details like OS, compiler,
> > Qt version, and so on but I don't think its relevant. The error is quite
> > easy to understand. The projectexplorer.pro file lists cpp files that
> > are only built on windows
>
> ... or if the TEST environment variable is set.
>
> > but code from the corresponding headers is referenced on any OS.
>
> Yes, you are right. It seems commit 4b8564cb42 introduced this issue. Note
> that that commit is also conceptually wrong, as the target system is
> relevant for the choice which functionality to include, not the host. For
> instance, if you built Creator with mingw on Linux (which we don't do),
> then MSVC support would be missing from the resulting binaries.
> As to why the build breakage does not seem to occur to anyone else: I'd
> assume the compiler optimizes out the code paths where the Msvc* is
> accessed, as it can determine statically that the conditions evaluate to
> false. No idea why it doesn't do that on your system, though.
>
> > Here is a change that I made to fix the issue.
>
> Any chance for you to push it to gerrit?
>
>
> Christian
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20171026/3b1aeef1/attachment.html>
More information about the Qt-creator
mailing list