carlonluca / docker-qt

Collection of data to create docker images with Qt support.
GNU General Public License v3.0
34 stars 7 forks source link

How does one inject and configure project into the image for compilation? #5

Closed Statixcinder closed 5 months ago

Statixcinder commented 5 months ago

Hello, this might be a skill issue for sure, but I'm not super familiar with docker images - also If this isn't the right way to request help, feel free to laugh at me.

I have a project which I'd like to use (qmake based) referenced from a local linux system with an aarch64 + android tool chain of which I have no idea how was created. Ideally I would want to use this toolchain which I've build using the scripts to create a build for 5.15.10 as a basis to verify the code still produces artifacts, but also to then port it to 6.6.3.

It is unclear on what should be done here since the qmake project.pro.user files all reference the old qt installation paths and have the targets 'ie - amd64, aarch64, android pre-set'? Also I'm targeting Android 10 specifically for that deployment, and was wondering if there was a means to select that specific SDK, is that something that happens when building the builder image? I could usually figure this out with qtcreator, but that part isn't compiled in (or should need to be), curious if there are some other variables that would be required for such a feat.

My goal is to take the current qmake based project which has specific target names per arch, and have it build for all arch so I can pull the artifacts if that helps clear up anything, but you know, .user file -> mapping to those specific compilers/crosscompile chain.

It sounds... like I just need to look at my local dev from qtcreator to see what commands it is calling and redirect them to the /opt/Qt installation path, but I noticed the 6.6.3 is using symlinks around, so unsure if I need to alter the links, or if they work with every compiler definition for the project (like how creator would assign them)?

It is awesome that this image cross compiles for everything I would need, truly impressive.

Any help would be appreciated, or direction on what I should look at to figure it out, thanks :)

carlonluca commented 5 months ago

pro.user files are typically personal user files, not to be versioned. Qmake project files are typically .pro files. The SDK is typically selected from the command line and the gradle build files, if present.

You shouldn't need to use the scripts in this repo, 5.15.10 is available in docker hub (not well tested though). You shouldn't need to change any symlink. Use the qmake binary present in the container to build your qmake project file.

Statixcinder commented 5 months ago

pro.user files are typically personal user files, not to be versioned. Qmake project files are typically .pro files. The SDK is typically selected from the command line and the gradle build files, if present.

You shouldn't need to use the scripts in this repo, 5.15.10 is available in docker hub (not well tested though). You shouldn't need to change any symlink. Use the qmake binary present in the container to build your qmake project file.

For our current setup we have some things like NDK_VERSION set to 29 to target the lower version for android (I think this is the only real deviation) but it exists in the user file. Our qmake .pro file setup is to detect target arch and do various things, but it is still up to the defined compiler via user file (ie, dumb qt creator setup). I see there is a cmake based .build file, but unsure what the qmake equivalent of that would be, or should I just sift around in the qmake equivalents?

carlonluca commented 5 months ago

I think you can build with cmake as well if your project is cmake based.

Statixcinder commented 5 months ago

Sorry to bother you again, but I don't have some non public means of requesting assistance, been trying to get this working for awhile, multiple builds etc.

My goal is to import a qmake based project into the image (which i have been able to do successfully and build with amd64 version of Qt), however I also need to utilize the arm64 and android toolchain that was used to cross compile the Qt libraries.

My environment : amd64 build host, trying to get the toolchain setup to where I can build the app for arm and android from that same image using all toolchains - doesn't matter if the image is huge (both of these work in their respective environments which I'm try to replace because they are a major hassle to maintain, but I'm running docker solely on amd64.

The dev image seems to only have the x86_64 compilers available, for example if i run qmake from /opt/Qt-arm64../bin/qmake It will correctly generate the expected makefiles however I do not have /bin/aarch64_gcc_compiler available, only the x86_64 versions? Is there a part of the build image that is removing the latent parts of that toolchain after it compiles Qt?

Would it be this? RUN \ apt-get -y autoremove \ && apt-get -y autoclean \ && apt-get -y clean \ && rm -rf /var/lib/apt/lists/*

Goal: /opt/qt-arm64/bin/qmake -recursive (project) make (with the arm cross-compiler) within the amd64 image.

Is this possible with the current setup or am i missing something or perhaps a way to merge all of them into the same image for use, I can build it here, just kind of oblivious as to what i'd need to do? Thanks you for your help :)

carlonluca commented 5 months ago

Are you trying to build for Android or for Linux arm64? The Linux arm64 cross-compiler may not be installed. You can install it from the official Ubuntu repo:

apt-get install g++-aarch64-linux-gnu

The Android arm64 cross-compiler, instead, is included in the Android ndk, which is in:

/opt/android-sdk/ndk/21.4.7075529/

Statixcinder commented 5 months ago

Ah okay, I'll give that a shot, thank you, technically I'm compiling the app for everything, I currently have 3 different VM's which is obviously annoying. The app itself will compile to whatever assuming the deps are there, but yeah, I was wondering where the compiler vanished in the dev image. I did notice that the target arch for android (armv8) looked to be building to armv8-i686 which i'm not sure is what i'd need. I plan to try to target armv7a for the android I mentioned before. But anyway i'll give that apt-get toolchain a shot :)

Statixcinder commented 5 months ago

/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: cannot find -lz /usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: cannot find -lGL Excellent! this is getting closer to working, should I just yank a bunch of the deps from the apt-get setup required?

I think if I can figure out how to pull/build these from the aarch64 repo i'd be set (apt-get noob, generally familiar with gentoo heh)

carlonluca commented 5 months ago

For the Linux arm64 deps, you can look at how the builder is created: https://github.com/carlonluca/docker-qt/blob/master/builder/Dockerfile_jammy.

Statixcinder commented 5 months ago

Everything is working great now! Thank you for your extended support, android was getting a little weird so I had to also add in jdk8 because my original arch was Qt 5.14.2/android-29 and gradle was complaining. A few environment variables later in the local build script and good to go. I'm using focal atm, but I figure the mod to jammy will be just as easy (if I even need it for the Qt update to 6.x).

Thanks again :D