Question

I am in the need to link against a library (written in Qt by myself). Of course this would generate (regardless of the extern "C" and name mangling stuff) a lot of errors during linking because of the C++ dependencies (stdc++ and Qt).

So I have got an idea, but I'm not sure, if I am missing something or if the approach is a realistic solution at all:

Searching some hints on this topic, I have found an article about building static Qt. Without reading all of it in detail I think the solution could be to compile Qt statically and then link my application against this static version of Qt. In my opinion this should lead to a successful build because of the following reasons:

  1. Building my Qt library with the static Qt Library (again as static lib) would resolve all dependencies because they are all in the static lib archive.

  2. Because of the extern "C"d interface functions, that will be accessed by the c application the C compiler (and linker) will also see all dependencies resolved and here is no problem either.

Now before trying the exhausting steps to build Qt statically, I would like to know, whether this approach could solve the problem.

EDIT 1: The alternative solution would be to implement a server-client architecture on top of both the Qt- and the C-part of the application and let them communicate in that way with each other.

EDIT 2: The probably best solution is neither of the both mentioned. Instead I just wrote a dynamically linked boundary (as suggested by Laszlo Papp and dsu) and everything works fine.

Was it helpful?

Solution

Now before trying the exhausting steps to build Qt statically, I would like to know, whether this approach could solve the problem.

Based on the comments where you mention that becoming a commercial client of Digia is a problem, I would say no.

Static linking cannot happen with proprietary software, and based on your comment, your project is not open sourceable.

That being said, you seem to have your own wrapper anyway, and Qt keeps binary compatibility for a given major version the lifecycle of which is usually several years, so I would personally go for dynamic linking and some kind of binding.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top