pmelsted / bifrost

Bifrost: Highly parallel construction and indexing of colored and compacted de Bruijn graphs
BSD 2-Clause "Simplified" License
204 stars 25 forks source link

undefined symbol: KmerIterator::operator*() when using API with conda #57

Closed samhorsfield96 closed 2 years ago

samhorsfield96 commented 2 years ago

Hi, I am getting an error when using the bifrost API during installation of unitig-caller (https://github.com/johnlees/unitig-caller) with conda. The conda package installs without any errors when using conda install unitig-caller, however when I run the unitig-caller binary I get the following error:

undefined symbol: KmerIterator::operator*()

This does not occur when I downgrade my bifrost version to v1.0.5. Would you be able to help with this if possible, please?

GuillaumeHolley commented 2 years ago

Hi @samhorsfield96,

I am not too familiar with conda in general so I am not sure how I can help. undefined symbol is usually a linking problem (during compilation, the compiler first compiles each file individually and then links the compilation units together). The Bifrost binary works fine on my side and I have used its library in another one of my project where everything works fine as well, I think the issue is more on how unitig-caller includes the bifrost library. I have created a new version of Bifrost recently and I see that the conda bot automatically updated the bifrost recipe to the latest version (1.0.6). Is it be possible that this is a cache issue with conda? Somehow, unitig-caller now uses the latest Bifrost (1.0.6) but the library file happens to still be 1.0.5? Did you "upgrade" the current conda recipe or did you make a fresh new install?

GuillaumeHolley commented 2 years ago

I might have found the issue, working on it.

GuillaumeHolley commented 2 years ago

Hi Sam,

I think I have found what the issue is. The way I see things, you probably have Bifrost installed twice on your computer:

Now the problem is that when unitig-caller imports the header file of Bifrost in its own code, it uses the following code:

#include <bifrost/ColoredCDBG.hpp>

The usage of <> tells the compiler to search for the header file in the global install. The global install being in version 1.0.5 while the Bifrost library compiled locally being in version 1.0.6, there is a clash of symbols and this is how you end up with undefined symbol. This is also why, if you downgrade Bifrost to 1.0.5 in conda, the issue doesn"t occur anymore: you still have the same issue but this time, both Bifrost versions are the same so no symbol clash.

The solution for this is for unitig-caller to use the local conda install which is probably going to be with:

#include "bifrost/ColoredCDBG.hpp"

or

#include "ColoredCDBG.hpp"

Let me know if this helps. Guillaume

samhorsfield96 commented 2 years ago

Hi Guillaume,

Thanks for your reply. I followed your guidance, as well as reinstalling the global version of Bifrost as version 1.0.6.2. This worked when I installed unitig-caller from source, however the problem persists when using unitig-caller from conda. I noted that the correct bifrost shared object (one installed in the conda environment, not the global install) is being linked when using ldd on the compiled unitig-caller object, although the linkage paths are different when installing via conda/source. I think this is an issue on our end/the conda end so will look into this further. Thank you very much for your help.

Sam