Question

[FYI: I've got the answer, and I'm in process of writing the solution. This post is only for reference for others with similar problem]


I'm working on some small application on Symbian-Belle platform. Everything was doing well until I've hit a place where I had to parse a few JSON files. I've found a QJson library, which seemed very relevant and easy to use (although it seems to return everything as QVariantMap, which probalby is not that lightweight..).

This library is however not provided in a precompiled form. It is source-only. Fortunatelly, it is prepared to compile under QtCreator's Symbian projects.

After some initial setups and minor fixes, everything ran smoothly on the Simulator, so, the next step was to run it on the real device. Here some problems began. After building, linking, deploying and installing, the IDE told me:

Launch failed: Command answer [command error], 1 values(s) to request: 'C|4|Processes|start|""|"MyApp.exe"|[""]|[]|true'
#0 {"Code":-46,Format="Failed to create the process (verify that the executable and all required DLLs have been transferred and that the process is not already running) (permission denied)"}
Error: 'Failed to create the process (verify that the executable and all required DLLs have been transferred and that the process is not already running) (permission denied)' Code: -46

The launch process instantly was aborted. Of course the application was launching properly back when the json-related code and library was not yet added to the project..

I've checked the suggested thing and the QJson library was indeed properly installed on the device, so it was not about missing files. Also, the application it self has been properly installed too: I could even try to run it manually. Doing that resulted in an error:

Unable to execute file for security reasons

What is going on? How to fix it?

Was it helpful?

Solution

The problem really lies in the security features of the Symbian platform. It turns out to be not related to Qt at all.

You see, both EXE and DLL projects may be marked with 'Capabilities' that specify what special platform features are used by the code. For example, if you try to read device-specifi data, you need ReadDeviceData capability.

Capabilities are embedded into the binary files that are installed on the device. The Symbian build system requires them to be defined in a .PKG file, but if you use current Nokia/Qt tools, all those files are autogenerated by the build process. For Qt projects, the capabilities are specified in the .pro file, for example:

TARGET.CAPABILITY += ReadDeviceData

Now, the trick is that the while EXE and DLL use the exactly same Capability flags, then for EXE and DLL the same capabilities mean something else.

  • for an EXE, they mean "What the Application is allowed to use?"
  • for a DLL, they mean "What applications are safe to use this DLL?"

It is quite tricky to see the difference at the first time you think about it.

  • if EXE has flag X, then the OS grants this application the access to some X API
  • if DLL has flag X, that means that it may be safely used by applications that have X flag

Please note that for DLLs the meaning is somewhat turned the other way round: applications that user some hyper-secure flags like AllFiles cannot use DLLs which does not have those flags.

The reasoning is simple: if I use XYZ flag, and if the DLL is not marked as safe-to-use with this flag, then I'm not safe to use that DLL and I cannot load it.

Here's this even written on Nokia's Symbian documentation:
http://www.developer.nokia.com/Community/Wiki/Shared_Library_DLLs_on_Qt_for_Symbian#Capabilities

This means that you must ensure that all DLLs (that are used by your app) have at least as wide Capabilities as your app.

For my problems with QJson library, the solution was to simply add NetworkServices to the QJson/src/src.pro file. My application was using this flag, because it downloaded some data from the internet. Thus, the library has to be marked as safe-to-use with network. I cannot fanthom why it wasn't marked with that flag in the first place. Probably the authors simply forgot, as it is quite obvious that JSON-parser will be used in network-enabled applications.. I'm going to drop them a note.


This concludes my problem-solution case I wanted to write about. I've posted a longer version with a bit broader explanations at: http://quetzalcoatl-pl.blogspot.com/2012/10/notes-on-symbian-qt-qjson-dlls-and.html

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