1

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
coolaj86
  • 74,004
  • 20
  • 105
  • 125

2 Answers2

3

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.

Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • Thank you so much! I hadn't yet heard of `xbuild`. I haven't tested the code completely, but I was able to import the fastJSON namespace without errors so I'm pretty sure it worked. – coolaj86 Dec 15 '11 at 08:36
  • How do I get it to build the "Production" version rather than the "Debug" version? – coolaj86 Dec 15 '11 at 08:48
  • Use "xbuild /property:Configuration=Release fastJSON.csproj" to build the release version instead. – Rolf Bjarne Kvinge Dec 15 '11 at 13:27
0

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

gmcs -r ~/fastJSON/fastJSON.dll main.cs
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758