tags:

views:

45

answers:

1

Has any one compiled lib x264 using CLI backend for gcc compiler? (Compiled x264 into .net dll)

+1  A: 

Are you using C99 features? If not, Visual C++ with the /clr:pure option should do the trick. You will need a little bit of C++/CLI mixed in to define your entrypoints that other .NET projects can call, but those can be in completely separate files (you can share entire C-only source files with native projects).

EDIT: Basic guide to making this work:

  • In Visual Studio, create a C++/CLI Class Library project
  • Add all your C source files to the project
  • In Project Configuration, set the include path so your headers are found
  • In Project Configuration, also set "Use of Common Language Runtime" to /clr:pure
  • In the .cpp file created by the new project wizard, add #include directive for the header files which prototype the functions you want to use.
  • In the ref class created by the new project wizard (in the aforementioned .cpp file), add some functions (maybe static functions) which call your C library functions.
  • Compile, add this .DLL as a reference of your C# project, and enjoy

As a hint, instead of creating a forwarding function in the ref class for every function in the library, you may want to make functions that do useful work (for the particular definition of useful for your particular project) by calling a bunch of library functions.

You'll probably want to get comfortable with the marshal_as template which is good for converting .NET System::String into C strings and back again.

Ben Voigt
Could you provide us with a sample for such thing - looks grate for me
Blender
For this, a snippet of example code wouldn't be very helpful. But I've edited my answer to describe the procedure.
Ben Voigt