Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Bundling Visual C++ dlls along with ClearScript

0
0
Hi i2infinity,

First, we encourage you to build ClearScript yourself via the walkthrough in the ReadMe. That way there'll be no confusion about which libraries to include with your SDK, and you'll get newer and faster versions of ClearScript and V8.

Next, since you wish to bundle the Visual C++ libraries with your SDK rather than install the redistributable packages, you'll have to deal with the platform issue (32-bit vs. 64-bit), as the files for both platforms are named identically.

Here's one way to do it. Have your SDK set up the following directory structure on the target machine:
YourSDK.dll
ClearScript.dll
32\
    ClearScriptV8-32.dll
    v8-ia32.dll
    concrt140.dll
    msvcp140.dll
    vccorlib140.dll
    vcruntime140.dll
64\
    ClearScriptV8-64.dll
    v8-x64.dll
    concrt140.dll
    msvcp140.dll
    vccorlib140.dll
    vcruntime140.dll
The 32-bit and 64-bit versions of the Visual C++ libraries (concrt140.dll, msvcp140.dll, vccorlib140.dll, and vcruntime140.dll) can be found in your Visual C++ installation directory. Some typical paths:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT\
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x64\Microsoft.VC140.CRT\
Finally, to ensure proper loading of the platform-specific ClearScript and V8 libraries, add the following code to your SDK and invoke it before creating your first V8 runtime or engine instance:
privatestaticvoid InitClearScript() {
    AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
        if (args.Name != "ClearScriptV8")
            returnnull;
        var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        var bits = Environment.Is64BitProcess ? "64" : "32";
        return Assembly.LoadFrom(Path.Combine(path, bits, "ClearScriptV8-" + bits + ".dll"));
    };
}
Of course you can customize this hook to load the libraries from any desired location.

Good luck!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images