Shared library update - dll

I have my application splited into 4 main parts:
main application (acting like a glue for other parts - load plugins, has linked core and ui libraries)
core (shared library with classes etc., it will be even something like sdk, basically contains all except things related to Ui)
ui (shared library, that contains ui resources, types etc.)
other plugins (shared libraries, loaded by main application, which will use Plugin manager from core
The main reason for this is that i want to have possibility to replace all parts of application just by downloading plugins for my application (through plugin manager window in that application).
Let's say i want to redesign look of my app. In that case i should just release new version of ui shared library/plugin.
I am not sure if it will work, if that ui shared library is linked to my app by linker when application is compiled (core and ui are linked by linker, other shared libraries/plugins are loaded by plugin manager when app is starting).
Question:There will be probably saved some metadata about those libraries in final executable, for instance size?? So i probably can't just replace ui shared library, without need to compile and link my app again?

Generally speaking, you can replace a shared library with an other version of the shared library in distribution (without recompilation of the executable, etc.) in case the original library and the replaced library do have same ABI

Related

Using static library in both App and Cocoa Touch Framework targets

I've created a new "Cocoa Touch Framework" target called MyAppCore in my iPad project called MyApp, with the intention of putting some common code in there. Overall it works great, however, I've encountered problems with adding the static library provided by Google Analytics.
I want to be able to use Google Analytics not only in the MyApp target, but inside of the MyAppCore target as well. In order to make both targets build, I have to link both targets with libGoogleAnalyticsServices.a. That appears to work, but when I run the app, the log is bombarded with messages like these:
Class GAI is implemented in both /path/to/MyAppCore.framework/MyAppCore
and /path/to/MyApp.app/MyApp.
One of the two will be used. Which one is undefined.
How can I share Google Analytics between the two targets in a successful way?
I managed to solve this issue by creating a wrapper class for Google Analytics (which is pretty handy to have, anyways) in the MyAppCore target. All access to Google Analytics will go through this wrapper. That way the only target that will use Google Analytics directly is MyAppCore, so I only have to link that target with Google Analytics.
This does not solve the underlying issue of sharing static libraries between my app target and a Cocoa Touch Framework, but for this purpose it works just as well.
Even if your static library depends on the external static library, don't link against it. Your main app will link against BOTH your library and the 3rd party library. A static library is a bunch of built code so you have two copies of everything doing things the way you are doing now.
You should still be able to reference the headers for the 3rd party library and things should compile on your static library without any warnings.
In my application I have two static libraries. "Wraith" is dependent on "PhilosophersStone" and the app is dependent on both. (Target Dependencies in Build Phases)
"Wraith" does not link against "PhilosophersStone", main app links against both. (Link Binary With Libraries in Build Phases)

Xcode: How to have shared code (i.e. framework) between main project and plugin bundle

In my project I had two targets, 1) The main application which loads 2) a bundle of plugins. I have started to have objects which need to be available in both targets, so naively tried to compile them separately in each target (producing warnings about having different implementations: Class X is implemented in both Y and Z. One of the two will be used. Which one is undefined.)
To solve this I decided to create a framework, so I added a framework, but I don't know how to make it so that a) both the main app and bundle access the framework (via the compiled framework, and not just through the headers in the project), and so the framework is compiled when I run the project.
If you know how to do this, thanks!
Here are the steps I followed:
Create a new framework in the project , copy all the shared code over.
In the main header of the framework, include the headers of all the shared code.
Build the framework to test it builds (e.g. select the scheme of the framework and click play)
Go to the Build Phases of both the Application and the Plugin Bundle and add the framework to ‘target dependencies’ and ‘Link binary with libraries’
To include the frameworks stuff in code in the app and bundle, just use the main header, and use <> rather than “" e.g if your framework was called Foo use #import
When it comes to deploying, there might have to be some fiddling with where the framework gets installed, currently it gets put alongside the app itself, rather than inside, but I will probably fix that later :)

Loading SystemC modules dynamically at run-time

In my simulator framework, the HW/SW modules are implemented in SystemC and pre-built. The platform to be simulated is described in XML. The simulator core parses the XML, determines the modules used and corresponding libraries files (e.g. dlls in Windows), and loads these modules dynamically at run-time. But I found no sample code of SystemC loading modules dynamically.
How can I do this in SystemC?
Because you said the example in DLLs of Windows, I assume you are doing so in Windows platform. So I suggest you can read the article and example in MSDN http://msdn.microsoft.com/en-us/library/windows/desktop/ms686944(v=vs.85).aspx .
If you are using unix platform, you could use dlopen and dlsym to load the corresponding shared libraries and retrieve the function address to be called from your main program.

Understanding bundles frameworks and libraries

I'm developing ios B2B app and I have several questions regarding app modularization.
Firstly i need to understand main difference between bundles and frameworks. When to use bundles and when frameworks.
Another question is. Is it possible for bundle to contain a .framework inside in it and vice versa.
Is it possible to create a plugins for ios app and load them dynamically, if yes then what it should be? bundle framework or library?
Is it possible for library to contain a resource files ?
Is it possible to create a resource bundle and dynamic library and then load them dynamically at runtime.
Is it possible to create a plugins for ios app and load them
dynamically, if yes then what it should be? bundle framework or
library?
No
Is it possible for library to contain a resource files ?
No
Is it possible to create a resource bundle and dynamic library and
then load them dynamically at runtime.
No
A Bundle is a type of Directory, a folder. A Framework is a bundle. So is an Application and so is a Plugin.
A Static Library is a single file code archive you can compile into your app at build time
A Dynamic Library is a single file code archive you can load at Runtime
A Framework is a Dynamic library in a Bundle with other things
A Plugin is a Dynamic library in a Bundle with other things
The Xcode build option 'Bundle' means 'Place the compiled Dynamic Library in a Bundle' - this is what you do when you want to create a Plugin.
Static libraries are the only option for modularising your code on iOS.
On the desktop..
Typically a Framework is for sharing code and resources between multiple apps. You want your app to behave as though the code was actually compiled into it. You want loading to happen transparently and you don't want to do anything special to use the methods, functions, etc. contained in it.
A Plugin (a Bundle containing compiled code and resources) is for optional, dynamically loaded code, e.g. a software extension that you can choose to load or not. You want to carefully architect your app so that it isn't dependent on the Plugin but acquires new behaviour if you manually locate and load it at Runtime.
A Framework and a Plugin are very similar, but a Framework has a strict file layout to facilitate locating and loading code and resources. With a plugin, these jobs are your responsibility so you can structure the Bundle contents however you want.
Because loading code is so easy in Cocoa on OSX (but not iOS) Frameworks can contain Plugins which contain Frameworks which contain more Frameworks, etc.
On iOS some people put Static Libraries in Bundles with resources and call them Frameworks. This has none of the benefits and all of the drawbacks of a real framework.

Problems using dynamic linked libraries (wxWidgets) from a DLL

We created a plugin; it is a DLL (Run-Time Dynamic Linking) which uses a 3rd party library (wxWidgets) and also links dynamically to that. The host software seems to scan our plugin, but exported functions are not called. We checked all dependencies with DependencyWalker.
We see in the debugger that the plugin is loaded, but the DllMain is not called, and the plugin is unloaded.
We tried loading our plugin from a simple test application using LoadLibrary and GetProcAddress which recognized and called the exported functions.
Having wxWidgets linked statically worked fine, though.
Does anyone have an idea why the exported function, respectively DllMain are not called, or can point out a tool which is capable to monitor the whole DLL loading process?
If wxWidgets is loaded already into the process address space before your plugin is loaded (the host app could do that, or there might be another plugin linking to wxWidgets which is loaded before yours), then there might be a chance that it is another version, missing some of the entry points that your plugin needs. Running the host app under DependencyWalker or WinDbg should show you which wxWidgets DLL is loaded, and you could try to load your plugin from your test app using exactly the same wxWidgets DLL. That should reveal whether there are missing dependencies.
Perhaps the host software does some funky things when loading the plugin and doesn't like wxWindows.
Anyways, try using the ProcessExplorer from the SysInternals suite to check what the process is doing.