This sample shows how to embed ChakraCore with JavaScript Runtime (JSRT) APIs on Linux/OS X, and complete the following tasks:
- Initializing the JavaScript runtime and creating an execution context.
- Running scripts and handling values.
- Printing out script results.
This sample requires Ubuntu 16.04 LTS or OS X 10.9+.
-
Clone and build ChakraCore on designated platform. Do not use
--static
argument while building ChakraCore. You may build ChakraCore using--debug
,--test-build
or release (no argument is needed). This sample, consider using--debug
to match the steps below. -
Copy the files of this sample into
ChakraCore/CrossPlatform
folder. -
cd
intoChakraCore/CrossPlatform
folder, and build the sample withmake BUILD_TYPE=Debug
(for macOS addPLATFORM=darwin
). -
On MacOS, you should copy
libChakraCore.dylib
into/usr/local/lib
-
Run with
./sample.o
.
Help us improve out samples by sending us a pull-request or opening a GitHub Issue.
Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE file in the project root for full license information.