verne.freenode.net changed the topic of #mlpack to: http://www.mlpack.org/ -- We don't respond instantly... but we will respond. Give it a few minutes. Or hours. -- Channel logs: http://www.mlpack.org/irc/
nckswt has joined #mlpack
< nckswt>
Hi - I'm having trouble getting MLpack up and running on OS X. I'm using XCode, I've installed mlpack and its dependencies using homebrew, I believe I've properly linked all the dynamic libraries and specified the library search paths, but I get a bunch of un-google-able errors whenever I try to #include <mlpack/core.hpp>
< nckswt>
I think it might be related to boost, but I'm not sure. A bunch of the errors are something like, "Use of undeclared identifier 'nullptr_t'; did you mean nullptr?" and "No member named 'memcpy' in namespace std::__1'; did you mean simply 'memcpy'?"
< rcurtin>
hi nckswt, are you specifying -std=c++11 in your compiler options?
< rcurtin>
(just a first guess. not sure if that's what's going on here)
< nckswt>
yeah - that's one of the things I played with
< nckswt>
sadly, no change at all
< nckswt>
could it be because I'm linking against .dylib files instead of against .so files?
< rcurtin>
no, that shouldn't be the issue
< rcurtin>
can you possibly paste the compilation output to pastebin or something?
< rcurtin>
that might be helpful in figuyring out what is going on
< rcurtin>
since it's C++, it's probably like ten thousand lines long :)
< nckswt>
I'm just getting back into C++ after several years of python, so it's taking me a bit to get used to the Xcode interface =p
< rcurtin>
hmm... so I am not an OS X expert, but I do have a couple ideas at least
< rcurtin>
so you installed xcode, and then installed mlpack through homebrew?
< nckswt>
yup
< rcurtin>
where did boost come from? xcode/homebrew?
< nckswt>
homebrew - my header search path is configured as "/usr/local/Cellar/boost/1.60.0_1/include"
< rcurtin>
okay
< nckswt>
library search paths are /usr/local/Cellar/mlpack/1.0.12_2/lib and /usr/local/Cellar/boost/1.60.0_1/lib
< rcurtin>
can you compile other C++ programs? like some simple int main() { } type thing?
< nckswt>
yup, no problem compiling there
< rcurtin>
hm, okay
< nckswt>
it's only upon including #include <mlpack/core.hpp>, and the errors seem to come from boost files
< rcurtin>
okay; I didn't see any boost errors, just stuff out of stdlib (//Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/exception)
< rcurtin>
part of me wonders, but isn't sure, if there is some incompatibility between the compiler you are using and where it is searching for stdlibc++
< rcurtin>
hm... which compiler are you using to compile your program?
< rcurtin>
is it the XCode compiler or one you got through homebrew?
< nckswt>
XCode
< rcurtin>
hm, so what happens if you install g++ through homebrew and try to compile with that?
< rcurtin>
ah, also, what version of xcode?
< nckswt>
7.2
< nckswt>
I'll try compiling outside of Xcode, see what happens
< rcurtin>
yeah; if that works, I think I might have an idea of which direction to debug in
< nckswt>
gcc main.cpp In file included from main.cpp:3: In file included from /usr/local/include/mlpack/core.hpp:171: /usr/local/include/mlpack/core/util/save_restore_utility.hpp:26:10: fatal error: 'libxml/parser.h' file not found #include <libxml/parser.h> ^ 1 error generated.
< nckswt>
oh, wait, I need to set flags
< rcurtin>
yeah, add -I/path/to/include/libxml2/
< rcurtin>
that libxml2 include path was always irritating to get right because some distributions install to /usr/include/libxml2/, some to /usr/include/
< rcurtin>
fortunately, since 2.0.0 there is no more libxml2 dependency :)
< rcurtin>
(hopefully the homebrew guys will get it updated soon. maybe I should poke them)
< rcurtin>
ah, you'll just need to add -lmlpack to link against mlpack for those, I think
< rcurtin>
also probably -lxml2 and maybe -lboost_program_options
< nckswt>
so, this? gcc main.cpp -I/usr/include/libxml2 -lmlpack -lxml2 -lboost_program_options
< nckswt>
I get the same result
< rcurtin>
so -lmlpack makes no difference?
< rcurtin>
I would think that libmlpack.dylib would already be on the linker search path... you could also try specifying -L/path/to/dir/ where dir/ contains libmlpack.dylib
< nckswt>
not that I can tell - is that definitely linking against mlpack?
< nckswt>
yeah, I'll try that
< nckswt>
nope, same issue
< rcurtin>
sometimes compilers can be finicky... can you try the -L<stuff> before the -lmlpack?
< rcurtin>
or actually I think you can link directly with -L/path/to/libmlpack.dylib
< nckswt>
so, gcc main.cpp -I/usr/include/libxml2 -L/usr/local/lib/libmlpack.dylib -lmlpack ?
< rcurtin>
you should be able to omit the final -lmlpack
< nckswt>
yeah
< nckswt>
still giving me that same error in boost
< nckswt>
do I need to link against boost somehow?
< nckswt>
should I worry about those "... is not a directory" warnings?
< rcurtin>
looks like maybe that particular compiler doesn't like the .dylib at the end of the -L calls... maybe try -L/usr/local/lib -lmlpack -lboost_math_tr1
< rcurtin>
(I'm assuming libboost_math_tr1.dylib is in /usr/local/lib; if not, you'll have to add another directory with -L)
< rcurtin>
compilation with C++ is not always very much fun :(
< rcurtin>
in fact I might consider changing "not always" in my statement to "always not"...
< nckswt>
haha
< nckswt>
yup =)
< nckswt>
libboost_math_tr1.dylib is definitely there
< nckswt>
if I just try to compile it with "#include <boost/filesystem.hpp>" instead of "#include <mlpack/core.hpp>", it still fails
< rcurtin>
at the linking stage?
< nckswt>
yup
< rcurtin>
what's the version of the compiler? (gcc --version)
< nckswt>
Apple LLVM version 7.0.2 (clang-700.1.81) Target: x86_64-apple-darwin14.5.0 Thread model: posix
< rcurtin>
ah also if you use g++ instead of gcc, does this make a difference?
< rcurtin>
are there any other directories than 4.2.1 in /usr/include/c++?
< nckswt>
oh! I got it! I think
< nckswt>
I had to add -lboost_system-mt
< rcurtin>
oh, okay, so now it compiles without issue
< rcurtin>
now if you switch back to the mlpack example and add -lboost_system-mt to the compilation there, is it also successful?
< nckswt>
checking now
< nckswt>
yes! that worked
< nckswt>
haha, finally!
< nckswt>
thanks a lot for helping me out for practically an hour =)
< rcurtin>
okay, so you can compile from the command-line with gcc
< rcurtin>
sure, no problem :)
< rcurtin>
but we still haven't solved your original issue :)
< nckswt>
yup =)
< nckswt>
checking that now
< rcurtin>
I am concerned that XCode, for some reason, is using a very old libstdc++
< rcurtin>
this is supported by the fact that gcc is using "--with-gxx-include-dir=/usr/include/c++/4.2.1"
< rcurtin>
that to me means that the libstdc++ is the one that shipped with gcc 4.2.1, which was like eight years ago and didn't have c++11 support (or even c++0x support as it was called at the time)
< rcurtin>
does "g++ --version" give a different version?
< nckswt>
that gives me:
< nckswt>
Apple LLVM version 7.0.2 (clang-700.1.81) Target: x86_64-apple-darwin14.5.0 Thread model: posix
< nckswt>
so, no
< nckswt>
exact same
< rcurtin>
okay
< rcurtin>
but when I look at the output further, I see that that's the compiler that shipped with XCode, not one from homebrew
< rcurtin>
(given the "--prefix=/Applications/Xcode.app/....")
< rcurtin>
so is it possible that just modifying the compilation configuration in Xcode could fix the original issue?
< rcurtin>
(that is, ensuring that Xcode is running the exact same command for compilation that you just did from the command line)
< nckswt>
yeah, let me try to figure out how to select the other compiler from within xcode
< nckswt>
hmm, interesting - g++ works, but gcc doesn't when compiling from command-line
< rcurtin>
gcc in most cases will be trying to compile the code as C, not C++
< nckswt>
ahh
< rcurtin>
actually sorry I think I misspoke, hang on
< nckswt>
nono, I think you're right - it had been a while, but that's what I remember
< rcurtin>
yeah, I was incorrect; gcc and g++ will both compile as C or C++ (depending on the given code)
< rcurtin>
but the primary difference is that g++ will automatically link against stdlibc++ whereas gcc will not
< rcurtin>
if you run "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --version", do you get the same version as "gcc --version"?
< rcurtin>
and, is it possible to remove the "-std=c++11" option and see if that does anything?
< rcurtin>
I have to step out for a moment... I'll be back in a few
< nckswt>
yup, I get the same version
< nckswt>
and I'll have to head out in about 10 minutes, so I'll look into the problem and, if I can find a good solution, I'll posted it on the github page. looks like it's more related to boost than it is to mlpack, at least!
< nckswt>
I feel like I'm going to miss the days of "pip install PACKAGE" being all I need to do to use a library =p
< nckswt>
alright, I'm logging off IRC now. thanks again for all the help - sorry we didn't track it down yet! you can find me at nckswt@gmail.com if you want to chat more. thanks!