Dynamic link Supported C/C++ compilers >>

Build C/C++ code on the fly


Build C/C++ code on the fly


Description


Nelson provides a cross-platform command-line tool written in Nelson for compiling native addon modules for Nelson.

It takes away the pain of dealing with the various differences in build platforms.

Example


if ispc() && ~havecompiler()
configuremsvc()
end
C_CONTENT = ["double";
"functionC(double x)";
"{";
"    return x + 8;";
"}"];
DEST_DIR = [tempdir(), 'example_C'];
mkdir(DEST_DIR);
C_DEST_FILE = [tempdir(), 'example_C/demo.c'];
filewrite(C_DEST_FILE, C_CONTENT)

dlgeneratemake(DEST_DIR, 'C_DEMO', {C_DEST_FILE}, {DEST_DIR})
[res, message] = dlmake(DEST_DIR)

lib = dlopen([DEST_DIR, '/C_DEMO', getdynlibext()])
c = dllibinfo(lib)

f = dlsym(lib, 'functionC', 'double', {'double'});
R = dlcall(f, 3) % 8 + 3
dlclose(lib)

See also


configuremsvc, dlgeneratemake, dlmake, dlopen, dllibinfo, dlsym, dlcall.

History


Version Description
1.2.0 initial version

Author


Allan CORNET

Dynamic link Supported C/C++ compilers >>