pmelsted / bifrost

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

Compilation fails on Mac OSX #77

Closed lrvdijk closed 10 months ago

lrvdijk commented 10 months ago

Hi,

I'm trying to compile the latest Bifrost on Mac OS X (MacBook M1 pro, OS X 13.4), but for some reason I get the error it is unable to find the function mkdtemp

/Users/ldijk/Library/Mobile Documents/com~apple~CloudDocs/programming/bioinformatics/gatk-bacteria/bifrost/src/CompactedDBG.tcc:2801:17: error: use of undeclared identifier 'mkdtemp'
/Users/ldijk/Library/Mobile Documents/com~apple~CloudDocs/programming/bioinformatics/gatk-bacteria/bifrost/src/CompactedDBG.tcc:2801:17:             if (mkdtemp(tmp_dir) == nullptr) {error:
                ^use of undeclared identifier 'mkdtemp'

            if (mkdtemp(tmp_dir) == nullptr) {

I am a bit suprised by this, because I see that unistd.h gets included (which is where that function is defined on OS X). I also tried to run with cmake .. -D_DARWIN_C_SOURCE to no avail (a suggestion I found by googling a bit).

Full compilation log using a cmake generated verbose makefile: log.txt

Any ideas how to fix this?

GuillaumeHolley commented 10 months ago

Hi @lrvdijk,

I appreciate the feedback, thanks. I also thought that mkdtemp was part of unistd.h (and of course it compiles just fine on UNIX platforms) but a bit of googling indicates that it is actually part of stdlib.h (see here). So this might be the issue?

I don't have a Mac OS X machine to try this, would you mind giving it a shot? Just add #include <stdlib.h> at the top of CompactedDBG.hpp with the other includes, rerun cmake with a new build directory and hopefully this should work.

Crossing my fingers but in any case, let me know if it worked. Guillaume

lrvdijk commented 10 months ago

Just tried it, but no luck unfortunately. I'd also have assumed the #include <cstdlib> would have provided that function in that case.

GuillaumeHolley commented 10 months ago

Good point, #include <cstdlib> should be enough. I was just hoping this could have been something as simple to fix as a missing include since the clang error message was kind of hinting in that direction. To be honest, I have no idea what is going on right now. I'll try to find a Macbook asap and install Bifrost on it to see what's wrong.

GuillaumeHolley commented 10 months ago

Hi again @lrvdijk,

@pmelsted worked his magic and made a fix for MacOS. Furthermore, the Cmake files shouldn't give any troubles to MacOS anymore. The fix is on the mac_fix branch, could you give it a shot first on your side? I'll try it on my side as well tonight and merge with main if we both green light this.

Guillaume

lrvdijk commented 10 months ago

I successfully compiled Bifrost! Thanks for the quick response!

GuillaumeHolley commented 9 months ago

@lrvdijk Compilation fix for MacOS fully integrated in v1.3.1 release :)