# failure to compile cython .pyx when cimporting some function from sage

Hello,

I am working on a Sage graph project, and for optimization,
I have chosen to move it to Cython.
The code compiles just fine as is, but for further optimization
I will need to use a union find data structure in my `cdef`

function.
So far, I was using `DisjointSet`

from `sage.sets.disjoint_set`

in a separate function: my issue is I do not know
how to `cdef`

such an object.

My initial attempt to solve this was to `cimport`

the disjoint set class from the `sage/sets/disjoint_set.pyx`

file,
and use it to `cdef`

.

This would in summary be something like this :

```
...
from sage.sets.disjoint_set cimport DisjointSet_of_hashables
cdef DisjointSet_of_hashables D
D = DisjointSet(10)
...
```

Though this does not compile : I get an error related to a library (that I assumed was included in the install of Sage). Just in case it was not, I manually installed GAP (which did not solve the problem).

```
/usr/bin/ld : ne peut trouver -lgap
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
```

This message is partly in French but it translates exactly to

```
/usr/bin/ld: cannot find -lgap
```

I believe this is mostly likely due to me misunderstanding how to import a class from the Sage Cython files. I had a similar problem when trying to work with bitsets (although the error was on the library PARI instead of GAP).

In case it is relevant, I am working on Ubuntu 20.04, installed Sage with apt (Sage version is 9.0).

Thank you in advance for any help.

Pierre

Welcome to Ask Sage! Thank you for your question!

On ne peut pas cimporter quelque chose qui est une def. Ca marche seulement pour les cdef.

Merci pour votre réponse Frédéric, effectivement j'ai mal renseigné mon exemple ; mais même si j'utilise ... cimport DisjointSet_Class (qui est bien cdef dans le fichier source) ou DisjointSet_of_hashables j'ai la même erreur.

Est-il possible de cdef un DisjointSet ?