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 to use --d4? #247

Open
LudvigOlsen opened this issue Jan 17, 2025 · 5 comments
Open

How to use --d4? #247

LudvigOlsen opened this issue Jan 17, 2025 · 5 comments

Comments

@LudvigOlsen
Copy link
Contributor

Would it be possible to add a bit more information to the readme about how to use --d4? Maybe I'm missing something, but I'm failing to get the argument to show up.

I've tried installing d4tools via conda and nimble install https://github.com/brentp/d4-nim.git and then installing the current master branch. And the --d4 argument is still missing. Do I need to add something to the $PATH or something? I feel like I got it to work a year ago or something, so I'm a bit confused :D

I assume, the when defined(d4): means it only adds the argument when d4 is available. Wouldn't it be better not to hide it?

@brentp
Copy link
Owner

brentp commented Jan 17, 2025

you need to compile with nim c -d:d4 ... mosdepth.nim

@LudvigOlsen
Copy link
Contributor Author

Does d4 need to be specified further with a path or something?

CC: mosdepth.nim
/home/user/.cache/nim/mosdepth_d/@[email protected]@[email protected]@sd4.nim.c:8:10: fatal error: d4.h: No such file or directory
    8 | #include <d4.h>
      |          ^~~~~~
compilation terminated.
Error: execution of an external compiler program 'gcc -c  -w -fmax-errors=3   -I/home/user/.choosenim/toolchains/nim-1.6.14/lib -I/home/user/mosdepth -o /home/user/.cache/nim/mosdepth_d/@[email protected]@[email protected]@sd4.nim.c.o /home/user/.cache/nim/mosdepth_d/@[email protected]@[email protected]@sd4.nim.c' failed with exit code: 1
                                

@LudvigOlsen
Copy link
Contributor Author

I tried the following:

nim c -d:d4 --passC:"-I$HOME/.nimble/pkgs/d4-0.0.5/include" --passL:"-L$HOME/.nimble/pkgs/d4-0.0.5/lib" mosdepth.nim

But the d4.h file is not located in any of those folders, so it's the same error.

@brentp
Copy link
Owner

brentp commented Jan 17, 2025

it is dynamically linking d4 so you need to build and install that.

@LudvigOlsen
Copy link
Contributor Author

LudvigOlsen commented Jan 17, 2025

Okay, that was a lot of trial and error. Here's what I ended up with (since I don't have sudo permissions):

cd ~/
git clone https://github.com/38/d4-format
cd d4-format
cargo build --release --package d4binding

# Make dirs for the relevant files (could probably skip this and point directly to d4-format/)
mkdir -p ~/local/d4/lib
mkdir -p ~/local/d4/include

cp ~/d4-format/target/release/libd4binding.* ~/local/d4/lib/
cp ~/d4-format/d4binding/include/d4.h       ~/local/d4/include/

cd ../mosdepth/
nim c -d:d4 -d:release --passC:"-I$HOME/d4-format/d4binding/include" --passL:"-L$HOME/d4-format/target/release" mosdepth.nim

I added the following to .bashrc:

# d4tools
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/d4/lib/
export LIBRARY_PATH=$LIBRARY_PATH:$HOME/local/d4/lib/
export C_INCLUDE_PATH=$C_INCLUDE_PATH:$HOME/local/d4/include/

Now the --d4 argument is finally there :-)

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

2 participants