QueTwo's Blog

thouoghts on telecommunications, programming, education and technology

Creating a Windows AIR Native Extension with Eclipse – Part 1

The second I heard about Adobe giving us the ability to create our own extensions to the Flash Platform in AIR 3.0, I was smitten.  It was finally a way that we could add our own features and do the things that were high priorities on our lists, but not on Adobe’s.  I knew I was looking for features that were one-offs (how many people today really need access to the COM ports), but they were forcing me to do all sorts of weird workarounds like launching proxy applications to do seemingly simple tasks.

AIR 3.0 got released a few weeks ago and I’ve jumped in head first into creating some ANEs (AIR Native Extensions).  For those of you who don’t know, ANEs are packaged extensions that contain operating-system specific code (DLLs for Windows, Libraries for MacOS, Java classes for Android and Objective-C for iOS), that allow you to do things that the Flash Player wasn’t able to do. 

Unfortunately, Adobe assumed that if you were developing DLLs for Windows, you were going to be using Visual Studio and nothing more.  This didn’t make a whole lot of sense in my mind as they’ve been leveraging Eclipse for all of their tooling, and Eclipse does offer some great C/C++ addins.  Now, that being said, Visual Studio is by far the more feature-full and hands-down the best editor for enabling these kinds of workflows on Windows.  It is, however, very costly and even though Microsoft offers a free versions, it takes over your computer by installing debug versions of most of Microsoft’s shared libraries making your computer slower and more crash prone.

I wanted to use Eclipse’s CDT addin with the standard GCC tooling that is available on pretty much every operating system.  By using GCC, I was able to make very portable code that with minimal effort was able to compile on all three of the major OSs (Windows, Mac, Linux). Adobe’s documentation was little help in getting this going (even if you were coding in Visual Studio, there is very little guidance on how to get things setup).  I do have to note that with my setup there is one distinct disadvantage — the lack of ability to debug the DLL when it is launched from AIR.  You will have to write your own C/C++ harness to do testing on your code in order to test it.  If you use the Visual Studio tooling, you CAN debug any DLL while it is running (this is why Microsoft replaces the shared libraries on your system to allow that debugging).

I’ve created a four part video series documenting how to get going creating ANEs.  Part 1 covers setting up your environment, including installing CDT, the compiler, and getting Eclipse setup to do your programming.  Part 2 covers actually coding the C/C++ code for your Windows DLL.  Part 3 covers creating your ANE, and packing up all the stuff needed to make it work.  And Part 4 covers how to use your new ANE in an AIR project.

Advertisements

12 responses to “Creating a Windows AIR Native Extension with Eclipse – Part 1

  1. Pingback: Creating a Windows AIR Native Extension with Eclipse – Part 2 « QueTwo's Blog

  2. Pingback: Creating a Windows AIR Native Extension with Eclipse – HackIX: Small Hacks for a Large World

  3. Pingback: Creating a Windows AIR Native Extension with Eclipse – Part 3 « QueTwo's Blog

  4. Pingback: #FollowFridayLinks S01E03 | AS_Blog

  5. tutorialhelp November 11, 2011 at 2:23 pm

    I would happy if you post your content file of source.

  6. mmx November 18, 2011 at 1:40 pm

    Nice, but the sentence

    >> It is, however, very costly and even though Microsoft offers a free versions, it takes over your computer by installing debug versions of most of Microsoft’s shared libraries making your computer slower and more crash prone.

    Is completely false and misleading. Debug DLLs have different names, and are not used by default in any executable.

    • quetwo November 19, 2011 at 8:31 am

      While that is true, the debug DLLs are registered, sometimes as the default handlers. For example, if are running an app as Administrator and it stops running normally, the debugger will automatically launch and will attempt to pull in the symbols (or ASM) for debugging. This actually adds a lot of weight to the OS (I have run tests on my own installs, pre-VS2005 and post-VS2005) and noted a noticable decrease in performance for other OS functions.

      Normally, that is not a huge deal when the benifits outweigh the cons (for example, if you are using Visual Studio as your day job and need the debugging toolset). For as little native coding as I do, and the fact that I really only have one machine which I do everything on, I didn’t feel like that was the case for me.

  7. James Ong November 29, 2011 at 1:47 am

    When I want to add 2 c/c++ development tool, it show me this error in Flash Builder 4, does it mean I need to install Eclipse CPP Indigo?

    Cannot complete the install because one or more required items could not be found.
    Software being installed: C/C++ Development Tools 8.0.0.201109151620 (org.eclipse.cdt.feature.group 8.0.0.201109151620)
    Missing requirement: C/C++ Development Tools UI 5.3.1.201109151620 (org.eclipse.cdt.ui 5.3.1.201109151620) requires ‘bundle org.eclipse.core.runtime [3.7.0,4.0.0)’ but it could not be found
    Cannot satisfy dependency:
    From: C/C++ Development Tools 8.0.0.201109151620 (org.eclipse.cdt.feature.group 8.0.0.201109151620)
    To: org.eclipse.cdt.platform.feature.group [8.0.0.201109151620]
    Cannot satisfy dependency:
    From: C/C++ Development Platform 8.0.0.201109151620 (org.eclipse.cdt.platform.feature.group 8.0.0.201109151620)
    To: org.eclipse.cdt.ui [5.3.1.201109151620]

  8. James Ong November 29, 2011 at 3:24 am

    Opp, I understand why, Eclipse indigo is not for FB4. Has able to update with Galieo respository.

  9. Dmitry April 4, 2012 at 10:28 pm

    Hi Nick,
    I’ve followed the first video and after removing #ifdef WIN32 block and saving the file I got bunch of red lines in the header file. For instance:

    uint8_t and uint32_t are highlighted in:

    typedef void (*FREContextInitializer)(
    void* extData ,
    const uint8_t* ctxType ,
    FREContext ctx ,
    uint32_t* numFunctionsToSet,
    const FRENamedFunction** functionsToSet

    Any ideas why and how to fix this?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: