PDA

View Full Version : Creator - Building Libraries?



SixDegrees
6th November 2010, 12:08
I've been playing with Qt Creator. I have a project built using console-based qmake/Qt under Linux that I'd like to bring under Creator control. It consists of two main parts: the actual application, consisting of a GUI that users interact with; and a small support library that handles details of reading various external file formats.

This is all easily built using project files and qmake by hand, but Creator doesn't seem to have any options for building libraries - only applications.

It looks like I can edit the .pro file Creator generates and make it generate a dynamic library. Is this a sound approach?

The other approach would be to simply dump all of my files into a single directory and build them as one gigantic lump, but this doesn't appeal to me on an aesthetic level. It would probably be OK for this simple project, but for larger projects such an approach is unacceptable.

Am I stuck building only single applications with Creator, or is there a way to have it build libraries, too?

wysota
6th November 2010, 12:26
It looks like I can edit the .pro file Creator generates and make it generate a dynamic library. Is this a sound approach?
Yes. But you can also just open a project file (for instance a subdirs project) you have been using before without Creator.

Zlatomir
6th November 2010, 12:35
Creator can generate .pro file for libraries too, just click Create Project, than at template select Other Project and there you have C++ library (use can select later if you want shared/dynamic or static library)

And also Creator should open .pro file that where generated by running qmake.

tbscope
6th November 2010, 12:37
A project I'm working on contains a plugin and a series of tests. The top most .pro file defines sub dirs. The plugin pro file defines a library and the tests pro file defines an application. This is perfectly possible in Qt Creator.

I even misuse the OTHER_FILES variable to add generic files in the project tree to easily maintain them inside Qt Creator.

When running a plugin you can choose to run the program that contains the plugin so you can test it.

As for regular libraries, this works too, but I guess the program using it will also be included in the project (subdirs). Make sure the subdirs are ordered so the libs get built first and make sure the linker finds the libs in the correct folder (build dir)

SixDegrees
6th November 2010, 12:52
OK, that seems to be working. Next question: my existing project files make use of a couple environment variables; the build is designed to fail when these are not set. I've set them, confirmed that they're set, and launched Creator, opened my project, and...the build fails, claiming the environment variables in question are not set. But I've verified that they are.

I've tried shutting down Creator and restarting it. Same result.

Do I have to set environment variables somewhere within Creator? It's curious that it isn't picking up settings in existence when it is launched.

tbscope
6th November 2010, 13:13
Do I have to set environment variables somewhere within Creator? It's curious that it isn't picking up settings in existence when it is launched.

I guess that Qt Creator launches the program from within a "clean" environment.

Open the projects mode, it's a button on the left toolbar.
From within the build and run settings you can define environment variables.

SixDegrees
6th November 2010, 13:34
Thanks, but it's working now. I did what I always do when I run up against weird problems: reboot, then do the same thing without changing anything.

As happens so often, this worked, and all now seems to be well. I'm able to import a large, multi-level project with several project files into Creator, and the whole thing builds fine, just as it does from the command line.

I can't say I'm crazy about Creator - I generally don't care much for IDEs - but this will greatly simplify porting a simple project from Linux to Windows.

Thanks for the help.

tbscope
6th November 2010, 13:39
I personally like Qt Creator. It's easy to use and doesn't get in the way. I never understood something like Visual Studio, that's way too complex for me.
There are a few little quirks that need improvement though.

One of the reasons I like Qt Creator (or Kate for that matter) is that when using a command line, it's a hassle to switch between files. With Qt Creator you have the whole project tree in plain sight.

wysota
6th November 2010, 15:30
One of the nice things with Qt Creator is that you can do practically everything you need without touching the mouse. Things like the locator, moving whole blocks of code up and down and tracing back your way through the code are really useful. I'm also fond of the way Creator marks the lines of code that were modified during the session (the green thin lines) as well as unsaved modifications (the red thin lines). Creator 2.1 is also a major step forward, I suggest you give it a try (you need to build it from sources) if you haven't done so already.