# Cxx.jl, nested includes, error: unknown type name and ERROR: Could not find $class in translation unit

**URL:** https://discourse.julialang.org/t/cxx-jl-nested-includes-error-unknown-type-name-and-error-could-not-find-class-in-translation-unit/4392
**Category:** General Usage
**Tags:** cxx
**Created:** [June 21, 2017, 7:07pm UTC](https://discourse.julialang.org/t/cxx-jl-nested-includes-error-unknown-type-name-and-error-could-not-find-class-in-translation-unit/4392 "2017-06-21T19:07:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)
#### Post date: [June 21, 2017, 7:07pm UTC](https://discourse.julialang.org/t/cxx-jl-nested-includes-error-unknown-type-name-and-error-could-not-find-class-in-translation-unit/4392/1 "2017-06-21T19:07:25Z")

</div>

I am trying to use the C++ library Box2D (forked here simply to have a shared library build): [https://github.com/goretkin/Box2D/tree/master/Box2D](https://github.com/goretkin/Box2D/tree/master/Box2D)

My issue might just be that I do not know how to include a header which includes headers from an include directory.

This is what I tried:

```julia
using Cxx

const path_to_lib = "/Users/goretkin/repos/Box2D/Box2D/Build/gmake/bin/Debug"

addHeaderDir(path_to_lib, kind=C_System)
Libdl.dlopen(path_to_lib * "/libBox2Ddyn.dylib", Libdl.RTLD_GLOBAL)

```

And then run

```julia
julia> cxx"#include \"/Users/goretkin/repos/Box2D/Box2D/Box2D/Box2D.h\""
In file included from :1:
In file included from __cxxjl_12.cpp:1:
/Users/goretkin/repos/Box2D/Box2D/Box2D/Box2D.h:34:10: fatal error: 'Box2D/Common/b2Settings.h' file not found
#include "Box2D/Common/b2Settings.h"
         ^
true

julia> cxx"#include \"/Users/goretkin/repos/Box2D/Box2D/Box2D/Box2D.h\""
true

```

I can’t tell whether it succeeded the second time, or it was quiet about failing. My guess is that it’s quiet about failing. The same behavior is true with `cxxinclude("/Users/goretkin/repos/Box2D/Box2D/Box2D/Box2D.h")`. It seems it doesn’t matter if I try to `addHeaderDir` the directory which contains `Box2D/Common/b2Settings.h`.

I remained hopeful and tried

```julia
julia> @cxxnew b2Vec2()
ERROR: Could not find `b2Vec2` in translation unit

julia> cxx"
              #include \"/Users/goretkin/repos/Box2D/Box2D/Box2D/Box2D.h\"
              b2Vec2 gravity(0.0f, -10.0f); "
__cxxjl_11.cpp:3:8: error: unknown type name 'b2Vec2'
       b2Vec2 gravity(0.0f, -10.0f); 
       ^
true

```

I’m on

```julia
julia> VERSION
v"0.5.2"

julia> Pkg.installed("Cxx")
v"0.1.1"

```

And I think this is not relevant yet, but

```julia
$ nm libBox2Ddyn.dylib | c++filt | grep "b2Vec2("
0000000000001df0 unsigned short b2Vec2::b2Vec2(float, float)
0000000000001fc0 unsigned short b2Vec2::b2Vec2()
0000000000001e20 unsigned short b2Vec2::b2Vec2(float, float)
0000000000001fe0 unsigned short b2Vec2::b2Vec2()

```

Thanks!

---

<div class="post-metadata">

### Author: ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)
#### Post date: [June 21, 2017, 7:19pm UTC](https://discourse.julialang.org/t/cxx-jl-nested-includes-error-unknown-type-name-and-error-could-not-find-class-in-translation-unit/4392/2 "2017-06-21T19:19:40Z")

</div>

> [@goretkin](#):
>
> const path\_to\_lib = “/Users/goretkin/repos/Box2D/Box2D/Build/gmake/bin/Debug”
> 
> addHeaderDir(path\_to\_lib, kind=C\_System)

This doesn’t look right – that’s a build path. You probably need something like `/Users/goretkin/repos/Box2D/Box2D/` (whatever is the parent directory of the `Box2D` directory).

edit: to clarify, `addHeaderDir` does the same thing as `-I` on the command line; the compiler then looks in that path for a sub-path of `Box2D/Common/b2Settings.h` when processing `#include "Box2D/Common/b2Settings.h"`.

---

<div class="post-metadata">

### Author: ![goretkin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goretkin/32/167_2.png) [@goretkin](https://discourse.julialang.org/u/goretkin)
#### Post date: [June 21, 2017, 7:37pm UTC](https://discourse.julialang.org/t/cxx-jl-nested-includes-error-unknown-type-name-and-error-could-not-find-class-in-translation-unit/4392/3 "2017-06-21T19:37:31Z")

</div>

Thanks for confirming that. I thought it was a little fishy and now I realized I generalized incorrectly from the example in the Cxx.jl README.

According to my first post I did try to add the correct header dir

> [@goretkin](#):
>
> It seems it doesn’t matter if I try to addHeaderDir the directory which contains Box2D/Common/b2Settings.h.

but actually I had made a mistake (one too many `Box2D`s), so thank you!
