简体   繁体   English

如何在ac#(gmcs)项目中包含库(例如fastJSON)

[英]How to include libraries (such as fastJSON) in a c# (gmcs) project

Disclaimer: I just made by hello world with gmcs yesterday 免责声明:我昨天刚刚用gmcs用hello world gmcs

Problem 问题

I want to use fastJSON in my project using gmcs. 我想用FASTJSON使用的GMC在我的项目。

How do I 我如何

  1. compile the project, consisting of 10 or so files into a library? 编译项目,由10个左右的文件组成一个库?
  2. statically link against that library with my 1-file project? 与我的1文件项目静态链接到该库?
  3. "install" the library on my system? 在系统上“安装”该库?

Imagined Solution 想象的解决方案

cd ~/fastJSON
gmcs --blahblah=fastJSON.csproj
cd ~/myProject
gmcs --yadayada=static ~/fastJSON/fastJSON.lib main.cs

The easiest solution is to use xbuild to build the fastJSON project: 最简单的解决方案是使用xbuild构建fastJSON项目:

cd path/to/fastJSON
xbuild fastJSON.csproj

This will build a library (.dll) somewhere (typically in the bin/Debug subdirectory, but it can be changed in the project file so it may be somewhere else for fastJSON). 这将在某处构建一个库(.dll)(通常在bin / Debug子目录中,但它可以在项目文件中更改,因此它可能在fastJSON的其他位置)。

Now you have the library, and you reference it like this when compiling your code: 现在你有了库,在编译代码时你会像这样引用它:

gmcs -r:path/to/fastJSON.dll mycode.cs

You don't need to install the fastJSON library on your system, just put it next to your executable. 您不需要在系统上安装fastJSON库,只需将其放在可执行文件旁边即可。

根据手册页 ,您需要使用-r命令行选项:

gmcs -r ~/fastJSON/fastJSON.dll main.cs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM