Registered Member
|
I installed Kdevelop 4.5.1 and tried to open a connection to a Database. But I always get the Error: "undefined reference to `QSqlDatabase::defaultConnection' "
But it should work, as I copied the example code from the QT documentation:
Of course, I added the #include directives: #include <QSqlDatabase> #include <QtGui> I know, that it has something to do with the Included libraries, because after hours of googling and try every possible solution I ended up with editing the "link.txt" file, or the CMakeLists.txt. I don't know it exactly anymore, because it was some time ago and not the real solution. After editing this file to include the mysql library, the code compiled. But it would be very annoying to edit this file again, after every change in the project. So, where can I change something in the project properties, so that the library will be found? And why does it not work out of the box, when I start a new project. Even if all dependencies are installed? I would say, it's a bug in KDevelop, because I have this Problem with a fresh install of KDevelop on SuSE, an install with emerge on Gentoo and even with a manual Installation from the sources for a single User on Gentoo. But if its really a Bug, how can it survive for months? Is there no one who develops something with QT and MySQL? |
Global Moderator
|
It's not a bug in KDevelop. By design, KDevelop will not write your build system for you -- it expects you to do that yourself, by e.g. editing CMakeLists.txt. This also implies that you are responsible to specifiy in your CMakeLists.txt what libraries you want to link against; there's no GUI tools to do that. KDevelop however has code completion support for CMake, which makes it much easier to write CMakeLists.txt files.
This way of doing things is a conscious design decision by KDevelop, and will not change. It has various advantages over the GUI approaches implemented by many other IDEs, including portability and transparency for the user. To clarify the problem you were having again: You need to link against the Qt SQL libraries, that requires a linker flag, and you need to tell your build system (e.g. CMake) to add that flag by editing its configuration file (e.g. CMakeLists.txt). Greetings, Sven
I'm working on the KDevelop IDE.
|
Registered Member
|
Ok, thanks for your answer.
Then I will have to learn, how to provide a correct CMakefile. It was more comfortable with KDevelop 3.x, where I only had to add the correct #includes and KDevelop configured everything else. Greetings, Dirk |
Global Moderator
|
The problem with this approach is that you have some IDE-specific file which contains information on how to build the project, which is absolutely vital for distributing and developing the software. Thus you sort of force everyone who wants to work on it or use it to use your IDE. That's not a good idea. IDE and build system should be completely separate, and the IDE should support the user in dealing with the build system, but not do it automatically (because it can't do it automatically, because there's choices to be made by the user which the IDE can't make).
Besides that, for small projects CMake is so simple that a GUI can't really be much simpler, and for large projects the GUI will get complicated too. Cheers, Sven
I'm working on the KDevelop IDE.
|
Registered users: Bing [Bot], daret, Google [Bot], Sogou [Bot]