Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc for "Build C/C++ code on the fly" #1110

Closed
bardo84 opened this issue Mar 1, 2024 · 7 comments · Fixed by #1111
Closed

Doc for "Build C/C++ code on the fly" #1110

bardo84 opened this issue Mar 1, 2024 · 7 comments · Fixed by #1111
Assignees
Projects
Milestone

Comments

@bardo84
Copy link

bardo84 commented Mar 1, 2024

This
shows a screenshot with command
generatecmake
The doc
does not help.

Awesome work!

@Nelson-numerical-software
Copy link
Collaborator

Nelson-numerical-software commented Mar 1, 2024

I could add this:
image

image

Text or contribution to increase documentation or code is welcome ;) @bardo84

@bardo84
Copy link
Author

bardo84 commented Mar 2, 2024

Hi,
screenshot of proposed solution->ocr->AI prettyprint
-> improve the workflow.

Had to change CDESTFILE -> C_DEST_FILE

[res, message] = dlmake(DEST_DIR);
executes without warning, but no dll file is generated.

@Nelson-numerical-software
Copy link
Collaborator

code is available here:
https://github.com/nelson-lang/nelson/pull/1111/files
or here:
https://nelson-lang.github.io/nelson-website/BUILD_C_CPP_ON_FLY.html

If you have some warnings or trouble, can you tell me more about your configuration

  • windows, linux ?
  • version 1.2.0.0 ?
  • which compiler have you installed on your pc

Thanks for your interest

@bardo84
Copy link
Author

bardo84 commented Mar 2, 2024

Windows
1.2.0.3744 (Fortitude)
Msys2 MINGW64

Merci

@Nelson-numerical-software
Copy link
Collaborator

I suppose that you configure mingw path just before with configuremingw

https://nelson-9.gitbook.io/nelson/en/dynamic_link/configuremingw
what is the outputs (message) of

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)

[res, message] = 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)

@bardo84
Copy link
Author

bardo84 commented Mar 2, 2024

Working now.
[res, message] = configuremingw(mingw_path)
I had to actually use the bin directory, mingw_bin_path?

  • When pasting a code block into the command pane, intermediate errors are not shown.
  • Copying from the command pane via select/CTRL-C does not work. Right mouse click visually unselects, but works.

Would it be possible to generate stand-alone code as well?
(That was what I was downloading Nelson for).

Merci

@Nelson-numerical-software
Copy link
Collaborator

"Would it be possible to generate stand-alone code as well?"
Code generation without dependency to nelson is currently not possible (later)
Currently you need to call nelson as engine (minimal version can be < 11mo, lgpl no trouble to distribute)
You can call nelson as mex engine see example : https://github.com/nelson-lang/nelson/blob/master/modules/mex/examples/mex_engine_demo_1.m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Nelson 2024
DONE (v1.3.0)
Development

Successfully merging a pull request may close this issue.

2 participants