File: README.md

package info (click to toggle)
ecl 21.2.1%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,604 kB
  • sloc: ansic: 146,375; lisp: 67,950; xml: 8,221; asm: 5,551; sh: 3,239; makefile: 1,968; cpp: 190; java: 116
file content (72 lines) | stat: -rw-r--r-- 1,609 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Description
This example shows how to setup CMake to build C++ project which uses ECL library.

In `src/lisp` is definition of `core-lisp` system that's being loaded into C++
program.

Functions defined in `src/lisp/core-lisp.lisp`:
```
(defun hello-world () (format t "Hello World!~%"))
```
are used in `src/cxx/main.cpp`:
```
extern "C" {
  extern void init_lib_CORE_LISP(cl_object);
}

int main(int argc, char** argv) {
  cl_boot(argc, argv);
  ecl_init_module(NULL, init_lib_CORE_LISP);
  cl_eval(c_string_to_object("(hello-world)"));
  cl_shutdown();
  return 0;
}
```

## CMakeLists.txt
For more information about setup read `CMakeLists.txt` comments.

# Build
Run:
```
$ mkdir build
$ cd build
```
If ECL is built and installed with non-default prefix use:

```
$ cmake -DCMAKE_PREFIX_PATH=/home/user/local_prefix/ ..
```

Otherwise you don't have to set `CMAKE_PREFIX_PATH`:
```
$ cmake ..
```

Finally run:
```
$ make
```

It shall produce: `cmake_ecl` executable and `core-lisp.a` static library that
has been linked to executable.


# Run
```
$ ./cmake_ecl
Hello World!
```

# Notes
  1. You don't have to remove `./build` directory if you want to change option
     in `CMakeLists.txt`. Just run `make`.

  2. If you see `undefined reference` errors look at `nm --demangle core-lisp.a`
     output. You may have forgot setting `:init-name` in `CMakeLists.txt`
     
  3. To reuse this example you must copy `cmake` directory to your project. It
     contains `FindECL.cmake`
     
  4. You don't have to have `ecl` executable in `$PATH` environment variable.
     `FindECL.cmake` shall find it.