I've created resource file in Qt, and I try to access those resources from my application but I'm getting an error:
:-1: error: [debug/qrc_Resources.cpp] Error 2
Where my resource file is called Resource.qrc. Any ideas how to overcome it?
This error can be caused by a lot of different things. It's a stupid error because it just tells you there is an error without telling you directly what the error is. But you can find out what caused the error by going to the Compile Output tab. Usually the cause of the error is the first thing in red. This is what I had in my case:
Here the first thing in red (which I circled in orange to make it visible) says "virtual memory exhausted: Cannot allocate memory" which means that the compiler was out of memory (which makes sense because my qrc_resource.cpp file was 33MB large).
What you should do to solve the problem depends on what the cause of the error is. In my case, since the compiler was out of memory, the solution was to allow my virtual machine to use more memory. But if the cause of your error is different, the solution for you might completely different.
It's really stupid that it just says "error 1" and nothing else and you have to look at the compile output to find out what the error actually is. I wish they will fix that in a future version of GCC. In the mean time, you can see what the error is in the Compile Output tab.
It may be a syntax error - check that Resource.qrc
is not referencing any invalid files and there are no typos.
I received "Error 1" when I was having this problem because I deleted one of the resources without editing my resource.qrc
.
Also it is suspicious that the .cpp is called qrc_Resources
plural, but the .qrc is called Resource
singular.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With