-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Embedding docs out of date #6327
Comments
Maybe at least partly a duplicate of #5834 however following their instructions I still couldn't get |
The embedding.c example is build by running |
Thanks Tobias for your help - I had missed the Makefile in examples. Running
I also had to alter the code:
To get it to run. Basically the issue stands: the docs on embedding are wrong and the solution is not obvious. Either they need to be fixed to use clang, and the right paths; or fixed to use gcc correctly (somehow??), and the right paths. |
yes you are right that docu issues should be fixed. But I am not entirely sure what the issue is. When you compile I am not sure about the other issue though. Maybe this could be solved by #5045. |
Personally all I'm really looking for is an example of how to compile test.c using gcc - eg. without the need to install clang. My eventual aim is to build a python library for calling Julia that does all the grunt work in c. Eg. like pyjulia but written predominently in c not python. For this I need to compile a julia library using setuptools. |
Ok, if you do
you are not linking against libjulia. The original line from the docu was
which links against libjulia and tells it where the header files are and where libjulia is located. It seems that the issue is that there is an
and if this does not work either additionally put |
And just as a side note: When I wrote the embedding docu (which was unitl that point non-existent) I was aware that its quite hard to educate how to compile C code in a cross platform way. Everybody uses a different tool for building C code (Makefile, CMake, Autotools, Visual Studio, ...) and this gcc-comand line I put to the docu was more meant as a example. |
@samuelcolvin are you using Ubuntu by chance? If you are you need to set up the paths differently, search the julia-dev list for details about how link to libjulia in this case. Offtopic, but have yoiu read all the pros/cons about what you intend to do on the julia-users mailing list? This has been brought up multiple times as a GSOC project. |
@jakebolewski good point. Do you know if the directory structure is somehow different for the Ubuntu binaries? In |
Sorry, yes Ubuntu 13.10 64 bit. If I add those two includes I get uv.h is in
And round in circles we go. As reference, the make commands which do work for
@jakebolewski Yes I've read numerous things, I just thought it would be worth trying a julia python lib written in c for the sake of speed. Which pros/cons did you mean exactly? |
Here in the link to the relevant comment https://groups.google.com/d/msg/julia-dev/36fFFLW25uk/MHciMbopHHYJ But it looks like you are not using the Ubuntu binaries, so this is a moot point. |
I am a little suprised that the Makefile uses g++ for linking. But still I do not understand why the |
In the mean time shouldn't someone with such permissions give this labels of |
@samuelcolvin OK, this may help. I'm going to assume
and just to have a specific case to work with, put your
Now you should be able to do
Assuming all went, pause to enjoy the moment. So what's going on here? First, I make no claim that these options should be used in production; they shouldn't be! But this is about as minimal an example as I could create and definitely not optimal in any other sense. (Please, no wagering. It's a demonstration, not a competition.) All I've done is seriously strip down the Specifying the libs (with -L and -l) is enough to let the linker resolve the I'd suggest RTFM, but that would make me a jerk. Instead, you might want to read this blog post which is probably the best discussion I've seen on the topic. One final note... master this example before you try building any shared libs which link with |
Shouldn't it be sufficient to put the libjulia directory to the The three include dirs are really only necessary when trying to compile something against the julia build dir. After installation there is one include folder where all the necessary files are in. |
Yes. LD_LIBRARY_PATH is arguably a brittle solution but I admit to using it Yes. The docs should assume an installation. My impression was that the OP
|
Right, but this bug report is about the docs beeing wrong and I try to find out what we can do to make them more clear. Maybe we should remove the |
I think I agree, provided the docs actually tell the reader what includes
|
When I wrote this I wanted to give this a "hands on" touch to show that it is really no magic to embed Julia. But of course without knowledge of C and how to build C programs in practice the embedding docu is not useful anyway. |
I still think it is useful to show how easy embedding can be, for people
Done. Easy and effortless don't need to mean the same thing. :)
|
Thanks a lot for your help. The key here I think is to make it clear that the process is significantly different for different platforms, and state what files they need to compile/link against. After that I don't see the problem with giving a demonstration for particular OS's; since it won't take long to write, why not give as much guidance as possible? For reference, with
With that |
Turns out it can be put into one command to be even simpler:
In short it was the |
Super! Glad to see the progress. File thus under "easy in retrospect." Maybe you'd be willing to try your hand at adding some helpful notes to the
|
Will do when I'm less manic, might be a couple of weeks but it's on my TODO list. |
With the latest 0.4 release I'm getting similar linker errors gcc -o test -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib/julia -ljulia test.cpp -Wl,-rpath,'$JULIA_DIR/lib/julia' |
@mdcfrancis the link targets need to be after the source file. The following works for me (on Ubuntu 14.04):
|
I think the documentation and example makefiles are up-to-date now with #21299. Leave a comment or reopen if not. |
https://github.com/JuliaLang/julia/blob/master/doc/manual/embedding.rst
The advice on compiling the test:
is wrong. For a start the directory $JULIA_DIR/include/julia doesn't exist.
This also affects the embedding example https://github.com/JuliaLang/julia/blob/master/examples/embedding.c as the manual page above seems to be the goto advice on how to compile it.
See google user group question.
The text was updated successfully, but these errors were encountered: