Commit ec94cd5b authored by Kunshan Wang's avatar Kunshan Wang

Fixes for Linux.

`cbinding/refimpl2-config` now puts `libmurefimpl2start.so` on the
"rpath" of the binary.
parent bc6c4d55
......@@ -21,13 +21,14 @@ endif
ifeq ($(OS),OSX)
CFLAGS += -I $(JAVA_HOME)/include/darwin
LDFLAGS += -L $(JAVA_HOME)/jre/lib/server -l jvm -rpath $(JAVA_HOME)/jre/lib/server
endif
ifeq ($(OS),LINUX)
CFLAGS += -I $(JAVA_HOME)/include/linux
LDFLAGS += -L $(JAVA_HOME)/jre/lib/amd64/server -l jvm -Wl,-rpath,$(JAVA_HOME)/jre/lib/amd64/server
endif
LDFLAGS += -L $(JAVA_HOME)/jre/lib/server -l jvm -rpath $(JAVA_HOME)/jre/lib/server
.PHONY: all
all: libs tests
......@@ -48,7 +49,7 @@ classpath.h: classpath.txt
tests: test_client
test_client: test_client.c libmurefimpl2start.so
$(CC) $(CFLAGS) `./refimpl2-config --istart --cflags --libs` -o $@ $<
$(CC) `./refimpl2-config --istart --cflags --libs` -o $@ $<
.PHONY: clean veryclean
......
......@@ -11,9 +11,13 @@ compile`. Then come here and type `make JAVA_HOME=/path/to/the/java/home`.
This will produce the `libmurefimpl2start.so` dynamic library that contains code
that starts the JVM and creates the MuVM instance for your client written in C.
This library will **hard code the classpath and the JVM path** into the shared
object, so it only works for this particular `microvm-refimpl2` repository you
cloned.
This library will **hard code the classpath and the JVM library path** into the
shared object, so it only works for this particular `microvm-refimpl2`
repository you cloned. This is because as this reference implementation is a
research project, it is unlikely to install it into any well-known places such
as `/usr`. Hard-coding the JVM's `libjvm.so` path using "rpath" eliminates the
need to put the JVM library path to `LD_LIBRARY_PATH`, since JVM is seldom
installed into `/usr/lib`.
## Usage
......@@ -36,7 +40,10 @@ function provides more options.
Use the `refimpl2-config` script with the `--istart` flag to indicate your
program will create the Mu reference implementation instance. Such clients need
to link against `libmurefimpl2start.so`.
to link against `libmurefimpl2start.so`, and it will **hard-code its location
using rpath** for the same reason why it hard-codes the classpath and JVM
locations, otherwise your executable file will require `libmurefimpl2start.so`
to be on the `LD_LIBRARY_PATH` to execute.
For example:
......
......@@ -27,7 +27,8 @@ if '--istart' in args:
if '--cflags' in args:
print("-I {} ".format(whereami), end="")
if '--libs' in args:
print("-L {} -l murefimpl2start ".format(whereami), end="")
print("-L {} -l murefimpl2start -Wl,-rpath,{}".format(
whereami, whereami), end="")
else:
if '--cflags' in args:
print("-I {} ".format(whereami), end="")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment