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

How are we supposed to build a project? #60

Open
nlw0 opened this issue Jun 22, 2020 · 5 comments
Open

How are we supposed to build a project? #60

nlw0 opened this issue Jun 22, 2020 · 5 comments

Comments

@nlw0
Copy link

nlw0 commented Jun 22, 2020

How exactly am I supposed to build a project using this library, only installing CxxWrap from Pkg?

So far I have been installing CxxWrap, then libcxxwrap from the repo, and then I also buid my own libcxxwrap just for the sake of linking it. Of course this cannot be the proper way.

I am not interested at all in using any special versions of libcxxwrap. I just want to be a user of this library, and link to whatever the latest release of the CxxWrap package requires.

How do I find out what is the directory I need to feed to cmake via JlCxx_DIR=...?

Right now I think I have only installed CxxWrap, and then I try to build my project using cmake .. -DJlCxx_DIR=$HOME/.julia/packages/CxxWrap/lDNAy/deps/usr/lib/cmake/JlCxx. Everything seems to go well, but then I try using my package and I hit some god-awful runtime error. Right now I'm getting

undefined symbol: _ZN5jlcxx19FunctionWrapperBase19set_pointer_indicesEv

which looks to me like I'm linking to the wrong library. What am I doing wrong?

@jstrube
Copy link
Contributor

jstrube commented Jun 28, 2020

The easiest way is to use a BinaryBuilder script. For example, here is what I do for development:
I have a build script in my .ci folder, e.g. https://github.com/jstrube/LCIO_Julia_Wrapper/blob/main/.ci/build_tarballs.jl
You can see that this just defines a dependency on libcxxwrap. It should use the same version that is already downloaded by CxxWrap.

The script part defines how you build your library. What I do to test this is then to run julia LCIO_Julia_Wrapper/.ci/build_tarballs.jl --deploy=jstrube/LCIO_Julia_Wrapper_jll.jl --register.
This builds the project, packs it into an artifact, puts a copy in my github repo, and registers it in ~/.julia/dev. From there my julia project can just pick it up (provided the versions in Project.toml of the julia project match).

@barche
Copy link
Contributor

barche commented Jul 3, 2020

I am not interested at all in using any special versions of libcxxwrap. I just want to be a user of this library, and link to whatever the latest release of the CxxWrap package requires.

The CxxWrap binaries are built using BinaryBuilder, which means that they are almost always incompatible for linking against using the native development tools on users' machines. The only possible options are to either build libcxxwrap-julia yourself and use Overrides.toml, or use BinaryBuilder even for local development, as suggested by @jstrube (which seems like a pretty nice way, actually, I should try it ;)

@cfitz25
Copy link

cfitz25 commented Feb 5, 2021

How would i go about using the BinaryBuilder to build CxxWrap with this? I read the example @jstrube wrote and it appears id modify that file to produce CxxWrap correct?
Im very new to this sorry.

@jstrube
Copy link
Contributor

jstrube commented Feb 5, 2021

I usually deal with this in three pieces:

  1. One file on Yggdrasil for the C++ code, i.e. the code that I want to wrap. This creates binary artifacts.
  2. One repository that contains the wrapper code. This code depends only on libcxxwrap-julia and contains only C++ code, no Julia. I write a build script on Yggdrasil that depends on the output of step 1 and in turn creates a new artifact.
  3. One repository containing the Julia package. This depends on the Julia CxxWrap.jl package, and the artifact created in step 2.

@barche
Copy link
Contributor

barche commented Feb 6, 2021

Another option now is to use Docker, see the first part of the workshop here:

https://live.juliacon.org/talk/NNVQQF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants