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

1.9k Views Asked by At

Disclaimer: I just made by hello world with gmcs yesterday

Problem

I want to use fastJSON in my project using gmcs.

How do I

  1. compile the project, consisting of 10 or so files into a library?
  2. statically link against that library with my 1-file project?
  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
2

There are 2 best solutions below

3
On BEST ANSWER

The easiest solution is to use xbuild to build the fastJSON project:

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).

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.

0
On

according to the man page, you need to use the -r command line option:

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