Project

General

Profile

Use of wt version 3 and version 4 alongside!

Added by suzuki kikamora about 2 months ago

I have a project that uses WT (Widgets Toolkit) for both the DBO (Database Object) and WT. I want to move all my DBO into one library and use the WT3 DBO in this library, while my main app will be in WT4 and will use this library. However, since my changes are significant, I can't move the entire project to WT4. Can I use WT3 and WT4 in a project alongside each other, or should they be separated into a library and an app?


Replies (3)

RE: Use of wt version 3 and version 4 alongside! - Added by Matthias Van Ceulebroeck about 2 months ago

Hey Suzuki!

Wt and Wt::Dbo should be able to operate completely separately from each other. I think the best way around this is to ensure that when you build each library, the projects are named accordingly Wt3 and Wt4.
In your CMake you can then find both packages find_package(wt3 REQUIRED COMPONENTS Dbo) and find_package(wt4 REQUIRED COMPONENTS Wt). The target can then be told to use the specific entries target_link_libraries(yourproject PRIVATE Wt4::Wt Wt3::Dbo).

I have not verified this approach, but this ought to work, as far as I can tell. If it doesn't, you can update this, and I'll take a closer look.

Best,
Matthias

RE: Use of wt version 3 and version 4 alongside! - Added by suzuki kikamora about 2 months ago

I built Wt version 3 and Wt version 4, changing the namespace from Wt to Wt3 in version 3 and updating the include file paths (the header files in the Wt directory for version 3 are now in the Wt3 directory)!

Everything builds and runs properly! However, when I include dbo from version 3 in my project, which is a Wt version 4 web application, I encounter a runtime exception related to the WString destructor.

I figured out that dbo and Widget use WString as a shared utility. When I include dbo from version 3 and use WDateTime to persist a time column in the database and retrieve the current date and time, I get an exception!

So, I need to change the header guards of WString and other shared utilities to be able to include dbo from version 3 and widgets from version 4 because I need to include WString(or other shared utils) from both version, am I right?

Additionally, I am using QMake(.pro), not CMake!

RE: Use of wt version 3 and version 4 alongside! - Added by Matthias Van Ceulebroeck about 1 month ago

Hello Suzuki,

I apologize for the delay. The email with your reply seemed to have gone lost in my inbox!

It does indeed seem, since there are differences their dependencies should be separated.
My first thought is to simply build the libraries statically? So they don't have shared utilities, but include all they require inside the library itself.

Or is it the case that the type (and namespaces) of the two collide during runtime? Such that Wt3 and Wt4 confusingly use each other's dependencies? In that case the solution may be a bit more involved. I think then it's maybe best to do a search and replace on the Wt namespace, and replace that with Wt3 or Wt4 respectively. So they do not confuse their dependencies.

    (1-3/3)