I'm working on software for an embedded system that uses GStreamer 0.10.36. My goal is to keep the software as small as possible in terms of Flash memory space, so I'd like to statically linking the GStreamer plugins I need. According to the Core Reference Manual:
"There are options to statically link plugins to an app or even use
GStreamer without a plugin repository in which case gst_plugin_load()
can be needed to bring the plugin into memory. "
Unfortunately, it's not clear to me exactly what I need to do to bring the plugin into memory such that a subsequent call to gst_element_factory_make() completes successfully.
I'm doing the following:
Building GStreamer with --enable-static and --disable-registry set.
Linking the static library into my application
Call gst_element_factory_make() to create an element
Right now I'm only doing this for one plugin (tcpclientsink) out of several as an experiment. I had to edit the Makefile for that plugin to remove a --disable-static statement to get the libgsttcp.a file to build. I assume the library is good, but I'm not sure if there is a good way to verify that. gst-inspect does not appear to work on static libraries.
Note: If I call load_gst_plugin(/path/to/libgsttcp.a), GStreamer fails to load the plugin because of an invalid ELF header.
How does one load a statically linked GStreamer library?
I made an app in which all plugins are compiled inside the app (so it is self-containing)... Maybe this is another option for you, or do you really need to link to the library?
I got my usual code (plugin.c and plugin.h) that I used to compile the plugins in a shared library. I add an extra wrapper header that containts static registration code
static gboolean myplugin_init(GstPlugin * plugin)
{
gboolean ret;
gst_controller_init(NULL, NULL);
GST_DEBUG_CATEGORY_STATIC (gst_myplugin_debug);
GST_DEBUG_CATEGORY_INIT(gst_myplugin_debug, "myplugin", 0, "description");
ret = gst_element_register(plugin, "myplugin", GST_RANK_NONE, GST_TYPE_MECIMOTION);
return ret;
}
void gstmyplugins_register_static()
{
gst_plugin_register_static(
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"myplugin",
"description",
myplugin_init,
"0.0.1",
"LGPL",
"myplugins",
"GStreamer",
"http://gstreamer.net/");
gst_plugin_register_static(
...
}
then inside the code for my app i call this registration:
gstmyplugins_register_static();
then continue with
gst_element_factory_make("myplugin", NULL);
hope this helps.
With some help from the GStreamer developers I found the answer.... don't use version 0.10.36. :)
Basically the ability to build static plugin libraries was added/fixed in later versions. To get it to work in 0.10.36, I've had to back port changes from the GStreamer SDK and GStreamer 1.x into 0.10.36. Things are still a work in progress, but I am able to build libgstcoreelements.a and statically link with it. If I wasn't already building a modified version of 0.10.36, I probably would have just used the SDK.
Update
I created static versions of all of the libraries I'm using. My GStreamer library is now a bit of a hybrid between 0.10.36, the SDK, and 1.2.2, but it works. I wouldn't recommend this solution for anyone though. Use the SDK or version 1.x.
Related
We're developing an SDK for our technology for iOS, the sdk is delivered in a static framework. Our code uses openCV and we link OpenCV into the delivered framework binary.
This normally works well but we're having an issue with a client which is indirectly using a different version of openCV in another framework.
This is causing a conflict and the clients app crashes.
Beside switching to the same version of openCV, removing our openCV dependency or switching to a dynamic library (which allows to hide open CV inside), is there an another option to fix this?
I tried to compile our lib using "Perform Single-Object Prelink and add the openCV libs in "Prelink libraries" but this produced link error when I tried to integrate it and it looks as if it ignored "Prelink libraries", maybe I'm doing something wrong here.
Any thoughts or ideas on the matter would be much appreciated.
I have succeeded in creating a statically linked version of an app in Windows. I have (1) compiled Qt statically and (2) compiled my application with the static version of Qt using the Qt Creator (see the documentation, and more in detail the steps I followed). This works great, and I'm able to distribute the app.
Now I'm trying to compile a different app, with the same compiler and settings in Qt Creator, but somehow the .exe ends up dynamically linked....?? Note that I have statically compiled both applications successfully on macOS.
What is going wrong?
I realize that this remains a wide question, but any suggestions are very much welcome.
I have tried so far to add CONFIG+=static to the .pro file (although that was not needed for the first app). Also here this had no effect.
Now I am trying to develop a browser plugin with firebreath on mac os.
Although I managed to generate a project and eveything went just fine, but
once I move the project generated with the fbgen.py procedure to somewhere
else, it doesn't work any more. Is there any way for me to take use of
firebreath as a static library like many other third party frameworks? Thus
I can link my project to any other library. Someone managed to do this on
windows platform but I failed to get contact with him.
Any kind of advice would be appreciated.
Regards,
Jordan
All the libraries are statically linked to generate the plugin. The project generated by fbgen.py compiles into static libraries from the source which are then linked to for the plugin. You just have to keep your source files for the plugin with you. You can generate the project anywhere you want using the prep** scripts.
I am on Mac.
I have a bunch of C source code (.c and .h).
I have a static library (.a).
I want to use that .a library from within Unity.
I looked into Unity's documentation for plug-ins (http://unity3d.com/support/documentation/Manual/Plugins.html), which says for PC and Mac stand alones, .bundle files seem to be the only solution. All example plugin-in projects that Unity give have .bundle plugins.
But I have seen prime31 plugins using .a library in Unity!
Anyone has a clue how they did that?
Here is all that I can tell from analyzing prime31 plugin:
(1) they put their .a library in Unity's Editor folder
(2) they have a C# script which contains lots of [DllImport ("__Internal")]
I tried to do the same:
(1) I wrote a simple hello_world.c in Xcode and built a .a library. I put the libhelloworld.a in Asset/Editor
(2) I then wrote a C# script that looks like this:
using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;
public class testlib : MonoBehaviour {
[DllImport ("libhelloworld")]
static public extern System.String helloworld();
}
(3) Then I wrote a test script:
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
// Use this for initialization
void Start () {
print(testlib.helloworld());
}
}
(4) By doing so I get a runtime error:
DllNotFoundException: libhelloworld
test.Start () (at Assets/Script/test.cs:8)
Many, many thanks!
PS: In case some of you wonder why I have the source code but not the bundle. I am trying to build a bundle from those .c and .h but hasn't succeeded yet. The source code was compiled with make tools, but I don't know anything else that could build a bundle except for Xcode. So I guess I have to use Xcode to build my bundle. My problem is when I tried to build it with Xcode I get millions of errors saying that I have duplicate main entries. I checked the source code and found that it does have duplicate main()s because the source code has lots of utilities that come with it. I tried deleting those utilities but the same error doesn't go away...
I am planning to ask this question somewhere else because this does not seem very Unity-related. But if someone here happens to know the answer, please don't hesitate -- let me know!
Okay I got an email from the prime31 people. It's impossible to do that.
Unity does not build an Xcode project for OSX, so you can't link a static library. Unity does build an Xcode project for iOS, that's how the prime31 developers could use the .a library(in Xcode, not in Unity)
To sum up, to use unmanaged code in Unity on MacOS, the only correct way is to build a bundle from your source code and then import it to Unity. Just like their documentation said!
I think I will try to build a bundle from source code or try to build a bundle from the .a library that I am now able to build, though Mac OS documentation says it's pointless:
Note: Some Xcode targets (such as shell tools and static libraries) do
not result in the creation of a bundle or package. This is normal and
there is no need to create bundles specifically for these target
types. The resulting binaries generated for those targets are intended
to be used as is.
I may post another question and if that question got answered, I will include a link here...
Alright I am coming back to edit:
Finally I built a bundle from a .a static library and was able to call functions of the library from Unity. Here is how I did: How to organize C source file previously compiled by GCC Make and build them into an Xcode bundle? I have a Duplicate Symbol _main Error
I am using my own library for an iOS project and it works fine. I don't use Unity3D's mechanism of copying from plugins folder but set it up completely in XCode. In the above HelloWorld example try [DllImport("__Internal")].
Follow the links in my previous answer How to use an xcode game on unity3d look at my blog posting, it deals exactly with this problem.
There are appear to be methods of creating a fat static library ala "http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4". Is this recommended? Any special steps (i.e., disabling thumb)
Also, if I do use the fat static library, will monotouch/xcode clear out any unused code in the final product?
You definitely need to turn Thumb code off so you can link properly against the library. As far as creating the fat static library goes, I can only say that anecdotally I've done this for a few third-party libraries that I've used and haven't run into issues.
I assume you already know that you need to create the bindings necessary to make calls to the objective-c library from your MonoTouch code and add extra gcc flags in the project properties to link in the static lib. If not, you can get that information on how to do that from the MonoTouch website.