libmx3 / mx3

a sample project showcasing/collecting cross platform techniques on mobile
MIT License
1.17k stars 146 forks source link

Integrate prebuilt libraries #40

Open daviswalker opened 9 years ago

daviswalker commented 9 years ago

It would be great to have a pattern for integrating prebuilt static libraries. Sometimes there are libraries where the configuration and build scripts are complex and not easily convertible to gyp. Pointing to them is a problem especially for Android, for which there will be multiple copies of the binary for the different target architectures.

skabbes commented 9 years ago

Yes, totally agree. The gyp documentation shows how to do something similar, but I could add an example. Do you have a library in mind perhaps?

tanaka-de-silva commented 9 years ago

Microsoft’s cross-platform C++ REST SDK (Casablanca) is probably a good candidate for a monolithic library that could be of use for a number of apps that would benefit from the use of prebuilt binaries.

daviswalker commented 9 years ago

I'm currently playing with openh264 (https://github.com/cisco/openh264), which has just enough in its Makefile that I don't really want to take on converting it to gyp.

Btw my current solution to this is to point a gyp file at one of the Android architecture library files. e.g.:

'conditions': [ ['OS=="ios"', { "libraries": [ '../prebuilt/ios/libopenh264.a' ] },'OS=="mac"', { "libraries": [ '../prebuilt/osx/libopenh264.a' ] }, 'OS=="android"', {

This generates a reference to the lib without referencing the

                # architecture. Gyp doesn't support specifying multi-architecture
                # files, so are added with a hand-written Android.mk.
                "libraries": [
                    '../prebuilt/android/x86/libopenh264.a'
                ]
            }],
        ]

This generates a line like: LOCAL_STATIC_LIBRARIES := libopenh264 in target.mk. Then in a hand-written Android.mk I include GypAndroid.mk and specify the real path to the architecture-specific library like:

include $(CLEAR_VARS) LOCAL_PATH := $(PREBUILTS)/$(TARGET_ARCH_ABI) LOCAL_MODULE := openh264 LOCAL_SRC_FILES := libopenh264.a include $(PREBUILT_STATIC_LIBRARY)

It works. Something tells me this pattern could be cleaner, though...

P.S. I'm using fat binaries on darwin to avoid this problem.

skabbes commented 9 years ago

^ I've actually seen this pattern for Android several times now - the wrapper "root makefile". The libraries don't even have to be pre-built, they can even be dependencies that have their own (android) Makefiles.

I think Casablanca would be a more general example than h264 - thanks for the idea @tanaka-de-silva

AraHaan commented 8 years ago

I am happy that Android and Apple Support C/C++ because I plan to make a Application that helps to prevent the phones that are made by Samsung from overheating. (they have tiny cheep processors)

My Plan: Use C++.

Drawbacks: With me having years of experiance of Visual Basic under windows Only I got no idea what API Headers I need to maske this work. I have some knowlege on C and C++ but that is from places of open source games/code made in C/C++. A perfect Example is Doom or even Duke Nukem 3D.

At least I know namespaces, classes, defines, structs, functions, exports, includes, defines, while loops, for loops, if, else, else if blocks, and breaks for loops.

Although I think there is a lot more things the most funniest thing I found in C and C++ when I first seen them before was things like. #define WIN32_LEAN_AND_MEAN