mardi 23 juin 2015

How to solve dylib type mismatch?

In my XCode project I have build targets to build my main application + a number of dylibs with C++ code. All pretty standard and the app builds and runs fine. Now I added a new terminal app that runs some unit tests on the main app (or rather on many of the dylibs). So, what I do is to link against the build targets for the libraries I'm actually testing.

The problem now is that some types (or maybe all types, haven't come to test much yet) seem to be different in the dylib and in the test application. For instance I have a class base::file_error derived from std::runtime_error. However I cannot catch this exception when thrown in the library. If I throw this exception in the test code, it works however. Another example is where I unserialize xml data and have to compare types that are instantiated. They mismatch and I get errors. I'm using dynamic_cast<> to see if a class is of a given type. The same type casting and checks are used in the main app too where they work flawlessly.

It appears as if the type system is different in the terminal app and the dylibs. I double checked all project settings. Most of them are inherited from the XCode project and those that differ do not seem to be related. What am I missing that produces such type problems?

I guess posting the code, e.g. from the file_error class won't help, as it works well in the main app. It's only the terminal app that makes trouble.

Aucun commentaire:

Enregistrer un commentaire