-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add example of loading at runtime from C #248
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, thanks, Brian. Just a couple of questions.
@@ -28,3 +34,6 @@ example_static$(EXE): example.c ../test_models/$(MODEL)/$(MODEL)_model.a | |||
$(CC) -c -I ../src example.c -o example.o | |||
$(LINK.cpp) -o example_static$(EXE) example.o ../test_models/$(MODEL)/$(MODEL)_model.a $(LDLIBS) $(LIBSUNDIALS) $(MPI_TARGETS) $(TBB_TARGETS) | |||
$(RM) example.o | |||
|
|||
example_runtime$(EXE): runtime_loading.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it reasonable to add ../test_models/$(MODEL)/lib$(MODEL)_model.$(DLL)
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would cause example_runtime
to be re-built more often, which feels like it goes against the pedagogical purpose of the example. Strictly speaking, there is no reason that any bridgestan library needs to have been compiled before this, which is what that dependency would be saying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goes against the pedagogical purpose of the example
Right, good point.
Is it reasonable to leave the code suggestion in the Readme as is, then add a sentence or two explaining that example_runtime
the executable can be compiled, but not run without a .so
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the readme block:
make example_runtime
# unlike above, this did not automatically build a model, since it
# was not needed to _build_, but we still need one to _run_ the program
make ../test_models/full/full_model.so
./example_runtime ../test_models/full/full_model.so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Recently a few requests have come in around using BridgeStan from C/C++, but in a way that is more closely aligned with how it is used in the other languages, e.g. providing a path to the library, rather than re-linking your code.
This adds an alternative example that does just that. It also adds some extra config so we can run some of these examples in the Windows CI -- the statically linked one isn't working for me, so I left it out for now still.