PDA

View Full Version : I'm having a hard time wrapping my head around Projects.



jeffadams78
15th March 2009, 17:49
Can someone please translate how to do this for me? My goal is "to build a standalone app from a group of semi-independent modules."

I'll compare with Visual Studio .NET because that's what I've been using at work for the last few years, so that process is fresh in my mind.

In .NET, I can build assemblies into DLLs, and when you build an app that depends on your other assemblies, all the necessary DLLs get copied into the output along with the produced EXE.

What is the way to do this in Qt (or perhaps more accurately, using qmake)?

Let's say I have a structure that looks like this:

/dev/strutils/*.cpp, *.h - a utility library for string parsing.
/dev/intutils/*.cpp, *.h - a utility library for printing formatted numbers.

/dev/myapp/data/*.cpp, *.h - all the database access classes for MyApp.
/dev/myapp/widgets/*.cpp, *.h, *.ui - all the custom widgets I wrote for MyApp.

/dev/myapp/myapp.pro, *.cpp, *.h, *.ui - a gui app that I want to distribute.

In VS.NET, I would have assemblies for strutils, intutils, and myapp. If data and widgets were very large, I might make them separate assemblies too. Everything but myapp would be a DLL project, myapp would be an EXE project. When I built myapp, strutils.dll, intutils.dll, etc would all wind up in my /build/release dir and I could bundle all those binaries together and distribute them.

It seems like (and please correct me if I'm not thinking of things the "qmake" way) I should have .PRO files for strutils, intutils, and possibly data and widgets if they were large. But after that I'm kind of stumped... how do I make myapp.pro "reference" the output from the other projects in a way that says "I need to include that output along with my own"?

P.S. I guess I should say, my question is slightly different for dynamic vs. static linking. If we're talking static linking, I just need to know how to make the reference at all, because with static linking the output of myapp would be a single file containing everything from all dependencies. Dynamic linking is when I'd actually need the output from the other libraries. Correct? I also need to do some research on static vs. dynamic linking, of late I've always done dynamic (I.E. DLLs) without really knowing the rationale for choosing one over the other.

wysota
15th March 2009, 20:01
What is the way to do this in Qt (or perhaps more accurately, using qmake)?
It's the same. The "assemblies" are called libraries (hence the name DLL with the last "L" meaning "library"), by the way.


It seems like (and please correct me if I'm not thinking of things the "qmake" way) I should have .PRO files for strutils, intutils, and possibly data and widgets if they were large.
Yes, that's correct.


But after that I'm kind of stumped... how do I make myapp.pro "reference" the output from the other projects in a way that says "I need to include that output along with my own"?
You use the LIBS qmake variable. Possibly some other as well.


P.S. I guess I should say, my question is slightly different for dynamic vs. static linking. If we're talking static linking, I just need to know how to make the reference at all, because with static linking the output of myapp would be a single file containing everything from all dependencies. Dynamic linking is when I'd actually need the output from the other libraries. Correct?
Static and dynamic linking are practically the same. The only difference is that with static linking you get one file to deploy at the cost of bigger memory footprint and with dynamic linking you may have to deploy more than one file. There are of course other differences and reasons for using one over another but that's a different issue.