有人使用 CLI 后端为 gcc 编译器编译 lib x264 吗?
有没有人使用 gcc 的 CLI 后端 编译器编译 lib x264? (将x264编译成.net dll)
Has any one compiled lib x264 using CLI backend for gcc compiler? (Compiled x264 into .net dll)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用 C99 功能吗?如果没有,带有
/clr:pure
选项的 Visual C++ 应该可以解决问题。您将需要混合一点 C++/CLI 来定义其他 .NET 项目可以调用的入口点,但这些可以位于完全独立的文件中(您可以与本机项目共享整个纯 C 源文件)。编辑:完成此工作的基本指南:
/clr:pure
#include
指令想要使用。ref class
中(在上述 .cpp 文件中),添加一些调用 C 库函数的函数(可能是静态函数)。作为提示,您可能希望创建函数,而不是在
ref class
中为库中的每个函数创建转发函数通过调用一堆库函数来完成有用的工作(对于对您的特定项目有用的特定定义)。您可能希望熟悉
marshal_as
模板,该模板非常适合将 .NETSystem::String
转换为 C 字符串,然后再转换回来。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:
/clr:pure
#include
directive for the header files which prototype the functions you want to use.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.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 .NETSystem::String
into C strings and back again.