Re: [Qt-creator] Link errors when building on linux

2017-10-31 Thread Frank Miller
> > 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
>
> If you had to do that, then your Qt installation is broken. Calling
> qmake should work out of the box, with no such constructs necessary (in
> fact, as you have noticed, they overwrite lots of predefined stuff that
> might even be necessary).

It's not clear to me that my Qt installation is broken. I think I have
either discovered a bug in qmake, a bug in the qt-creator qmake based
build system, or a very unexpected feature of one or the other. One
thing I didn't mention previously (because I assumed it was irrelevant)
is that the installation prefix of Qt was the same as that of the
compiler used to build it. This turns out to be important. If I use a
different prefix for Qt and gcc, then qt-creator builds out of the box.
If I use the same prefix for Qt and gcc then the link commands are
missing the necessary -L/path/to/the/Qt/libs switch.

Here is what I'm doing in more detail in case there are other things
that I am assuming are irrelevant. First I build gcc-7.2.0 and install
it into $gccPrefix like this:

$ mkdir -p $gccBuildDir
$ cd $gccBuildDir
$ $gccSrcDir/configure \
  --prefix=$gccPrefix \
  --enable-languages=c,c++ \
  --disable-multilib
$ make -j20
$ make install

Then I build qt-5.9.2 and install it into $qtPrefix like this:

$ mkdir $qtBuildDir
$ cd $qtBuildDir
$ $qtSrcDir/configure \
-prefix $qtPrefix \
-opensource \
-confirm-license \
-nomake examples \
-skip qt3d \
-skip qtactiveqt \
-skip qtandroidextras \
-skip qtcanvas3d \
-skip qtcharts \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtdoc \
-skip qtgamepad \
-skip qtgraphicaleffects \
-skip qtimageformats \
-skip qtlocation \
-skip qtmacextras \
-skip qtmultimedia \
-skip qtnetworkauth \
-skip qtpurchasing \
-skip qtremoteobjects \
-skip qtscxml \
-skip qtsensors \
-skip qtserialbus \
-skip qtserialport \
-skip qtspeech \
-skip qtsvg \
-skip qttranslations \
-skip qtvirtualkeyboard \
-skip qtwayland \
-skip qtwebchannel \
-skip qtwebengine \
-skip qtwebsockets \
-skip qtwebview \
-skip qtwinextras \
-skip qtx11extras \
-skip qtxmlpatterns
$ make -j20
$ make install

Then I build qt-creator like this:

$ mkdir $qtcreatorBuildDir
$ cd $qtcreatorBuildDir
$ $qtPrefix/qmake -r $qtcreatorSrcDir
$ make -j20

If $gccPrefix is a different path than $qtPrefix, then qt-creator builds
just fine. However, if $gccPrefix is not the same path as $qtPrefix,
then the build of qtcreator fails to link because it finds my system
installed Qt rather than the one installed in $qtPrefix. This is because
the link command is missing a "-L$qtPrefix/lib" in the second case.

> > I have never used gerrit before but I would be willing.
>
> This should have the necessary information:
> https://wiki.qt.io/Gerrit_Introduction The procedure is less daunting
> than it looks. If you decide against it after all, please let me know.
>
> > How does one determine the target system?
>
> Using the Q_OS_* macros, as it was before the patch. (Note: It turns out
> that the HostOsInfo class is badly misnamed, as it also uses these
> macros internally. The author simply assumed that Qt Creator would never
> get cross-compiled. But that's not relevant to our problem here.) In
> fact, simply reverting the patch would be perfectly okay, except that it
> doesn't apply anymore, because other things have changed in between.

I'm still planning on making the change discussed but it will not happen
until later this week. I will let you know if that changes.

Thanks again everybody for all your help. I have been impressed by the
level of engagement in this community.

Frank

On Thu, Oct 26, 2017 at 10:51 AM, Christian Kandeler <
christian.kande...@qt.io> wrote:

> On Thu, 26 Oct 2017 10:08:29 -0500
> Frank Miller  wrote:
>
> > 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 thi

Re: [Qt-creator] Link errors when building on linux

2017-10-26 Thread Frank Miller
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.kande...@qt.io> wrote:

> On Wed, 25 Oct 2017 22:06:10 -0500
> Frank Miller  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@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
>
___
Qt-creator mailing list
Qt-creator@qt-project.org
http://lists.qt-project.org/mailman/listinfo/qt-creator


Re: [Qt-creator] Link errors when building on linux

2017-10-25 Thread Frank Miller
Thanks for the quick response. I should have known better...

I'm on CentOS 7.x (I'm not sure exactly. I don't maintain it):
$ uname -a
Linux scone 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24 UTC
2017 x86_64 x86_64 x86_64 GNU/Linux

I'm using gcc-7.2.0 which I built myself.
$ g++ --version
g++ (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

I'm using qtbase, qtdeclarative, qtquickcontrols, qtscript, and qttools.
All from the head revision of their 5.9 git branches and built with
compiler above.
$ qmake --version
QMake version 3.1
Using Qt version 5.9.3 in /opt/segdeps/gcc/lib

I haven't done a git clean but I always do out-of-source builds and the
git clones are recent.

Would any other information be useful?

What version of Qt do you build against?

Frank

On Wed, Oct 25, 2017 at 10:13 PM, Christian Gagneraud 
wrote:

> On 26/10/2017 4:06 PM, Frank Miller wrote:
>
>> Greetings,
>>
>> 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::WinDebugInter
>> face(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 <http://projectexplorer.pro>
>> file lists cpp files that
>> are only built on windows but code from the corresponding headers is
>> referenced on any OS. Here is a change that I made to fix the issue.
>>
>
> But the error could be due to your setup, so tell us about your setup (OS,
> compiler), which git hash are you  at, local modifications, ...
> Did you try a clean rebuild (eg after a git clean -dfx)...
>
> I merely substituted a runtime branch on the OS with a compile time
>> branch on the OS. After this, it builds and runs fine as far as I can
>> tell. I probably should just submit a bug report and be done but the
>> fact that this issue exists for me in all the recent release branches
>> made me want to post a message on this forum and see what people think.
>> I must be doing something unusual right? I can't be the only one who
>> wants to build on linux.
>>
>
> I've built QtC-4.5 from git on Linux very recently and i didn't get this
> build errors.
>
> Chris
>
>
>> Thanks for the great project!
>>
>> Frank
>>
>>
>> ___
>> Qt-creator mailing list
>> Qt-creator@qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/qt-creator
>>
>>
>
___
Qt-creator mailing list
Qt-creator@qt-project.org
http://lists.qt-project.org/mailman/listinfo/qt-creator


[Qt-creator] Link errors when building on linux

2017-10-25 Thread Frank Miller
Greetings,

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 but code from the corresponding headers is
referenced on any OS. Here is a change that I made to fix the issue.

$ git diff
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp
b/src/plugins/projectexplorer/projectexplorer.cpp
index 3b7be3a..ce4386e 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -505,14 +505,17 @@ bool ProjectExplorerPlugin::initialize(const
QStringList &arguments, QString *er
 #endif

 // Add ToolChainFactories:
-if (Utils::HostOsInfo::isWindowsHost()) {
-addAutoReleasedObject(new WinDebugInterface);
-addAutoReleasedObject(new MsvcToolChainFactory);
-} else {
-addAutoReleasedObject(new LinuxIccToolChainFactory);
-}
-if (!Utils::HostOsInfo::isMacHost())
-addAutoReleasedObject(new MingwToolChainFactory); // Mingw
offers cross-compiling to windows
+#ifdef Q_OS_WIN
+addAutoReleasedObject(new WinDebugInterface);
+addAutoReleasedObject(new MsvcToolChainFactory);
+#else
+addAutoReleasedObject(new LinuxIccToolChainFactory);
+#endif
+
+#ifndef Q_OS_MAC
+addAutoReleasedObject(new MingwToolChainFactory); // Mingw offers
cross-compiling to windows
+#endif
+
 addAutoReleasedObject(new GccToolChainFactory);
 addAutoReleasedObject(new ClangToolChainFactory);
 addAutoReleasedObject(new CustomToolChainFactory);

I merely substituted a runtime branch on the OS with a compile time
branch on the OS. After this, it builds and runs fine as far as I can
tell. I probably should just submit a bug report and be done but the
fact that this issue exists for me in all the recent release branches
made me want to post a message on this forum and see what people think.
I must be doing something unusual right? I can't be the only one who
wants to build on linux.

Thanks for the great project!

Frank
___
Qt-creator mailing list
Qt-creator@qt-project.org
http://lists.qt-project.org/mailman/listinfo/qt-creator