[Qt-creator] Link errors when building on linux
Frank Miller
cfrankmiller at gmail.com
Thu Oct 26 05:06:10 CEST 2017
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20171025/cfa32b1b/attachment.html>
More information about the Qt-creator
mailing list