# Unable to use absolute file paths in qrc file?

**URL:** https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321
**Category:** Code
**Created:** [March 29, 2022, 7:24pm UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321 "2022-03-29T19:24:57Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [March 29, 2022, 7:24pm UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321/1 "2022-03-29T19:24:58Z")

</div>

This comment applies to Qt5.6.3.

It appears that the quick compiler doesn’t generate proper namespaces when using full paths in a qrc file. I was attempting this because I need to autogenerate a qrc file in the binary folder. The sources are passed to a function to then create the qrc file. The quick compiler runs but produces invalid C++ like this when full paths are used:

Somewhere else in the documentation I thought I saw that colons ‘:’ were translated to underscores ‘\_’ to avoid this. Is this just a case of using a pretty old version of the quick compiler that this happens?

```auto
namespace QtQuickCompilerGeneratedModule
{
    namespace _ImportFiles_C:_Projects_AEPP_eSW_Qt_AEPPApps_ImportFiles_ImportGraphicFileLister_qml
    {
        extern const unsigned char qmlData[];
        extern AOTFunction moduleFunctions[];
        QV4::CompiledData::CompilationUnit *createCompilationUnit() { return ::createCompilationUnit(reinterpret_cast<const QV4::CompiledData::Unit*>(qmlData), moduleFunctions); }
        const QQmlPrivate::CachedQmlUnit unit = {
            reinterpret_cast<const QV4::CompiledData::Unit*>(qmlData), &createCompilationUnit, &::loadQmlIR
        };

}

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [March 29, 2022, 8:45pm UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321/2 "2022-03-29T20:45:21Z")

</div>

This really feels like a Qt bug to me. Is this fixed with newer Qt versions?

---

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [March 29, 2022, 9:00pm UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321/3 "2022-03-29T21:00:44Z")

</div>

I don’t currently have a good version to test this with. I’d need to pull down something late in the Qt5 version series. I currently have 5.6.3 and 6.2.1. With 6.x the means of compiling resources is different with `qt_add_qml_module`.

I’ll try to remember to test on my home machine later today where I have 5.15 installed already.

FWIW I was able to work around the issue by letting CMake calculate the relative paths for me.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [March 30, 2022, 5:20am UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321/4 "2022-03-30T05:20:10Z")

</div>

This does seem to be something for the Qt folks to respond to rather than being anything specifically that CMake is doing. I did cover the new way Qt 6 handles resources in my [Qt World Summit 2021 talk](https://resources.qt.io/on-demand/developing-qt6-projects-with-cmake-tools-qtws21). Not sure if that is directly relevant to your query here, but maybe it provides some ideas. The bit about resources starts around the 11 minute mark or so. You might also be interested in the QML part starting around 19:30.

I suggest you follow up in the Qt forums or their issue tracker if the above talk doesn’t get you there.

---

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [March 30, 2022, 9:53pm UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321/5 "2022-03-30T21:53:58Z")

</div>

Yes, of course. I don’t even know why I came here first. I think because I had CMake on the brain from something else I was figuring out.

---

<div class="post-metadata">

### Author: ![Rich\_von\_Lehe](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rich_von_lehe/32/307_2.png) [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)
#### Post date: [April 1, 2022, 3:49am UTC](https://discourse.cmake.org/t/unable-to-use-absolute-file-paths-in-qrc-file/5321/6 "2022-04-01T03:49:42Z")

</div>

Great talk by the way
