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

Add function to get libjulia path at runtime #5045

Closed
wants to merge 2 commits into from

Conversation

tknopp
Copy link
Contributor

@tknopp tknopp commented Dec 7, 2013

This adds a function "jl_get_libjulia_path" that gives the path of the libjulia library at runtime.

I would propose that this path should be the first location where the sys.ji (or sys.so in the future) is searched (in jl_init and repl.c). Once the static compilation branch is merged I can make a PR for changes in jl_init and repl.c

In this PR only the addition of the function is included.

@tknopp
Copy link
Contributor Author

tknopp commented Dec 20, 2013

just rebased this. Just to clarify this: Are there situations where the system image is not located in the libjulia path? (maybe @vtjnash)

@vtjnash
Copy link
Member

vtjnash commented Dec 20, 2013

I believe the current default is for it to be at usr/lib/libjulia.so and usr/lib/julia/sys.dll

@tknopp
Copy link
Contributor Author

tknopp commented Dec 20, 2013

ah ok thanks. I thought that I have seen these files in the same directory on the windows installation.
Anyway, it might make sense to use jl_get_libjulia_path to look in that path and "jl_get_libjulia_path() /julia/" for the system image.

@ViralBShah
Copy link
Member

This generally seems to be useful to have.

@staticfloat
Copy link
Member

So this is pretty old, but I wanted to point out that you can get this from julia very easily via Sys.dlpath("libjulia") or Sys.dlpath("sys"), which is kind of neat.

@tknopp
Copy link
Contributor Author

tknopp commented Jun 4, 2014

@staticfloat: Yes, this PR was not intended to provide the location of libjulia from Julia itself. It is more about the location of the system image and making it more robust when embedding Julia in C. At the time where I came up with the PR I was trying to embed Julia into an MSVC application on Windows and had issues to automatically detect the system image. I had to use an absolute path in julia_init to make it work.

If I recall correctly the system image is detected relative to the julia_home_dir. With this PR one could alternatively or additionally look if the system image is located in the same directory as libjulia or a subfolder julia.

@jakebolewski
Copy link
Member

@tknopp could you update this PR? This would be useful to have in 0.4.

@tknopp
Copy link
Contributor Author

tknopp commented Sep 1, 2014

@jakebolewski: done. But I am not entirely sure how useful this change alone is. My idea behind this was to change the system image lookup to use a relative path to libjulia.dll

@JeffBezanson
Copy link
Member

Please update the indenting and brace placement style to match the rest of our code.

fix coding style
@tknopp
Copy link
Contributor Author

tknopp commented Dec 8, 2014

@JeffBezanson: Alright Jeff. I have updated the code, hopefully it is now conform with the style guide. Do you want to merge/use this?

@vtjnash
Copy link
Member

vtjnash commented Dec 9, 2014

FWIW #9266 will allow for directly retrieving the location of the sys.ji file used to launch julia. i don't think that affects this pull request, however, which is more about retrieving the location of libjulia.dll (and potentially using that to find the sys.ji image in the first place)

@tknopp
Copy link
Contributor Author

tknopp commented Dec 9, 2014

@vtjnash Yes this was the motivation when I wrote this. At that time I tried to get embedded Julia running in MSVC and it seemed that JULIA_HOME was not properly set so that the path finding code in julia_init failed. And for this reason I thought it would be more clever to say that sys.so is in a relative path to libjulia.

@stevengj
Copy link
Member

stevengj commented Jan 9, 2015

@JeffBezanson's comment in #7801 seems relevant here. If Julia can tell you the path you need, why not just fix it so that jl_init finds the correct image file using this path, rather than exporting something?

@vtjnash
Copy link
Member

vtjnash commented Jan 9, 2015

This is about finding libjulia, not sys.ji

@stevengj
Copy link
Member

stevengj commented Jan 9, 2015

Yes, but the whole point of this patch, as I understand it, is to use the libjulia path to find sys.jl and other files. i.e. it is not the libjulia path itself that is desired or useful. If the goal is to set JULIA_HOME correctly or to locate sys.jl correctly, then we should do that directly.

@tknopp
Copy link
Contributor Author

tknopp commented Jan 9, 2015

both is true. This is only about libjulia and was meant as a utility function with the motivation to fix jl_init. And #9691 shows that this is still not fixed. If Steven has a better fix this is great. IMHO jl_init should not have an argument.

@stevengj
Copy link
Member

stevengj commented Jan 9, 2015

@tknopp, I'm not saying that we shouldn't use the libjulia location to fix jl_init. I'm saying that if we want to fix jl_init, we should fix jl_init. We can still use this code internally, but I don't see why we should export it if there is no need for it outside of jl_init.

@tknopp
Copy link
Contributor Author

tknopp commented Jan 9, 2015

Yes this function does not have to be exported. The jl_init fix can be made on top of this PR though.

@ihnorton
Copy link
Member

Closing as fixed by #21299 (jl_init can now find libjulia automatically). Please comment or re-open if further discussion needed.

@ihnorton ihnorton closed this Jul 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedding Embedding Julia using the C API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants