Results 1 to 9 of 9

Thread: Creator - Building Libraries?

  1. #1
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Creator - Building Libraries?

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creator - Building Libraries?

    Quote Originally Posted by SixDegrees View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Creator - Building Libraries?

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Creator - Building Libraries?

    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)

  5. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Creator - Building Libraries?

    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Creator - Building Libraries?

    Quote Originally Posted by SixDegrees View Post
    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.

  7. #7
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Creator - Building Libraries?

    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.

  8. #8
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Creator - Building Libraries?

    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.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Creator - Building Libraries?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Building an application using static QT libraries on Linux openSuse 10.2
    By mmeerten in forum Installation and Deployment
    Replies: 1
    Last Post: 1st July 2010, 21:35
  2. Building Boost libraries for QT
    By nhs_0702 in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2010, 09:54
  3. Qt 4.6 with VS 2008 Express: Linker error when building libraries
    By scrontch in forum Installation and Deployment
    Replies: 9
    Last Post: 10th January 2010, 15:25
  4. Building application with static Qt libraries
    By nedlab in forum Installation and Deployment
    Replies: 1
    Last Post: 28th December 2008, 20:07
  5. Replies: 2
    Last Post: 8th March 2007, 22:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.