epfml / sent2vec

General purpose unsupervised sentence representations
Other
1.19k stars 256 forks source link

Error when running "make" #54

Closed Meng-37 closed 4 years ago

Meng-37 commented 5 years ago

Hello! When I try to compile the library as Setup & Requirements suggests by running make command, errors pop up as below:

c++ -pthread -std=c++0x -O3 -funroll-loops -c src/dictionary.cc In file included from src/dictionary.cc:10: src/dictionary.h:55: error: ISO C++ forbids initialization of member ‘pruneidxsize’ src/dictionary.h:55: error: making ‘pruneidxsize’ static src/dictionary.h:55: error: ISO C++ forbids in-class initialization of non-const static member ‘pruneidxsize’ src/dictionary.cc: In member function ‘void fasttext::Dictionary::threshold(int64_t, int64_t)’: src/dictionary.cc:261: error: expected primary-expression before ‘[’ token src/dictionary.cc:261: error: expected primary-expression before ‘]’ token src/dictionary.cc:261: error: expected primary-expression before ‘const’ src/dictionary.cc:261: error: expected primary-expression before ‘const’ src/dictionary.cc:265: error: expected primary-expression before ‘[’ token src/dictionary.cc:265: error: expected primary-expression before ‘]’ token src/dictionary.cc:265: error: expected primary-expression before ‘const’ src/dictionary.cc:269: error: ‘class std::vector<fasttext::entry, std::allocator >’ has no member named ‘shrink_to_fit’ src/dictionary.cc: In member function ‘std::vector<long int, std::allocator > fasttext::Dictionary::getCounts(fasttext::entry_type) const’: src/dictionary.cc:292: error: expected initializer before ‘:’ token src/dictionary.cc:295: error: expected primary-expression before ‘return’ src/dictionary.cc:295: error: expected ‘;’ before ‘return’ src/dictionary.cc:295: error: expected primary-expression before ‘return’ src/dictionary.cc:295: error: expected ‘)’ before ‘return’ src/dictionary.cc: In member function ‘void fasttext::Dictionary::addNgrams(std::vector<int, std::allocator >&, int32_t, int32_t, std::minstd_rand&) const’: src/dictionary.cc:322: error: ‘uniform_int_distribution’ is not a member of ‘std’ src/dictionary.cc:322: error: expected primary-expression before ‘>’ token src/dictionary.cc:322: error: ‘uniform’ was not declared in this scope src/dictionary.cc: In member function ‘int32_t fasttext::Dictionary::getLine(std::istream&, std::vector<int, std::allocator >&, std::vector<int, std::allocator >&, std::vector<int, std::allocator >&, std::minstd_rand&) const’: src/dictionary.cc:357: error: ‘uniform_real_distribution’ is not a member of ‘std’ src/dictionary.cc:357: error: expected primary-expression before ‘>’ token src/dictionary.cc:357: error: ‘uniform’ was not declared in this scope src/dictionary.cc: In member function ‘void fasttext::Dictionary::save(std::ostream&) const’: src/dictionary.cc:426: error: expected initializer before ‘:’ token src/dictionary.cc:430: error: expected primary-expression before ‘}’ token src/dictionary.cc:430: error: expected ‘;’ before ‘}’ token src/dictionary.cc:430: error: expected primary-expression before ‘}’ token src/dictionary.cc:430: error: expected ‘)’ before ‘}’ token src/dictionary.cc:430: error: expected primary-expression before ‘}’ token src/dictionary.cc:430: error: expected ‘;’ before ‘}’ token src/dictionary.cc: In member function ‘void fasttext::Dictionary::prune(std::vector<int, std::allocator >&)’: src/dictionary.cc:474: error: expected initializer before ‘:’ token src/dictionary.cc:478: error: could not convert ‘((std::vector<int, std::allocator >)idx)->std::vector<_Tp, _Alloc>::insert [with _InputIterator = __gnu_cxx::__normal_iterator<int, std::vector<int, std::allocator > >, _Tp = int, _Alloc = std::allocator](((std::vector<int, std::allocator >*)idx)->std::vector<_Tp, _Alloc>::end [with _Tp = int, _Alloc = std::allocator](), ngrams.std::vector<_Tp, _Alloc>::begin [with _Tp = int, _Alloc = std::allocator](), ngrams.std::vector<_Tp, _Alloc>::end [with _Tp = int, _Alloc = std::allocator]())’ to ‘bool’ src/dictionary.cc:479: error: expected primary-expression before ‘}’ token src/dictionary.cc:479: error: expected ‘)’ before ‘}’ token src/dictionary.cc:479: error: expected primary-expression before ‘}’ token src/dictionary.cc:479: error: expected ‘;’ before ‘}’ token make: *** [dictionary.o] Error 1

I assume it's about c++, but I'm not familiar with that, can someone help?

Also I tried running python setup.py build_ext from ./sent2vec/src, but again errors occur:

running build_ext building 'sent2vec' extension gcc -pthread -B /home/python/anaconda3/envs/termExtraction/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/python/anaconda3/envs/termExtraction/lib/python3.6/site-packages/numpy/core/include -I/home/python/anaconda3/envs/termExtraction/include/python3.6m -c sent2vec.cpp -o build/temp.linux-x86_64-3.6/sent2vec.o -std=c++0x -Wno-cpp -pthread -Wno-sign-compare cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++ In file included from /home/python/anaconda3/envs/termExtraction/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1816, from /home/python/anaconda3/envs/termExtraction/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /home/python/anaconda3/envs/termExtraction/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4, from sent2vec.cpp:663: /home/python/anaconda3/envs/termExtraction/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" In file included from sent2vec.cpp:671: fasttext.h:18:18: error: atomic: No such file or directory In file included from fasttext.h:23, from sent2vec.cpp:671: dictionary.h:55: error: ISO C++ forbids initialization of member ‘pruneidxsize’ dictionary.h:55: error: making ‘pruneidxsize’ static dictionary.h:55: error: ISO C++ forbids in-class initialization of non-const static member ‘pruneidxsize’ In file included from qmatrix.h:25, from fasttext.h:25, from sent2vec.cpp:671: productquantizer.h:26: error: ISO C++ forbids initialization of member ‘nbits’ productquantizer.h:26: error: making ‘nbits’ static productquantizer.h:27: error: ISO C++ forbids initialization of member ‘ksub’ productquantizer.h:27: error: making ‘ksub’ static productquantizer.h:28: error: ISO C++ forbids initialization of member ‘max_points_percluster’ productquantizer.h:28: error: making ‘max_points_percluster’ static productquantizer.h:29: error: ISO C++ forbids initialization of member ‘maxpoints’ productquantizer.h:29: error: making ‘maxpoints’ static productquantizer.h:30: error: ISO C++ forbids initialization of member ‘seed’ productquantizer.h:30: error: making ‘seed’ static productquantizer.h:31: error: ISO C++ forbids initialization of member ‘niter’ productquantizer.h:31: error: making ‘niter’ static productquantizer.h:32: error: ISO C++ forbids initialization of member ‘eps’ productquantizer.h:32: error: making ‘eps’ static In file included from sent2vec.cpp:671: fasttext.h:46: error: ISO C++ forbids declaration of ‘atomic’ with no type fasttext.h:46: error: invalid use of ‘::’ fasttext.h:46: error: expected ‘;’ before ‘<’ token cc1plus: warning: unrecognized command line option "-Wno-cpp" error: command 'gcc' failed with exit status 1

Information against the OS is

Linux slaver01 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux``

Thanks in advance!

mpagli commented 5 years ago

Can you check your g++ version ? g++ --version

Meng-37 commented 5 years ago

Thank you for replying! Information against the g++ version is:

g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)

I can tell that 2012 seems out-dated. Do I need to install a newer version, and which version shall I choose if so?

mpagli commented 5 years ago

I have the following: g++ (Ubuntu 7.3.0-16ubuntu3) 7.3.0 Let me know how it goes.

Meng-37 commented 5 years ago

Hi there! Sorry to report this late, but I still encounter problems compiling fasttext.cc even after updating g++ to 7.3.0. Detailed information is as below:

src/fasttext.cc: In member function ‘void fasttext::FastText::printLabelStats(std::istream&, int32_t, fasttext::real) const’: src/fasttext.cc:445:40: warning: ‘void fasttext::FastText::writePerLabelMetrics(std::ostream&, fasttext::Meter&) const’ is deprecated: This function is deprecated and will be removed along with printLabelStats. [-Wdeprecated-declarations] writePerLabelMetrics(std::cout, meter); ^ In file included from src/fasttext.cc:10:0: src/fasttext.h:126:8: note: declared here void writePerLabelMetrics(std::ostream&, Meter&) const; ^~~~~~~~ c++ -pthread -std=c++0x -O3 -funroll-loops args.o dictionary.o productquantizer.o matrix.o qmatrix.o vector.o model.o utils.o fasttext.o src/main.cc -o fasttext src/main.cc: In function ‘void test(const std::vector<std::__cxx11::basic_string >&)’: src/main.cc:159:51: warning: ‘void fasttext::FastText::writePerLabelMetrics(std::ostream&, fasttext::Meter&) const’ is deprecated: This function is deprecated and will be removed along with printLabelStats. [-Wdeprecated-declarations] fasttext.writePerLabelMetrics(std::cout, meter); ^ In file included from src/main.cc:15:0: src/fasttext.h:126:8: note: declared here void writePerLabelMetrics(std::ostream&, Meter&) const; ^~~~~~~~ fasttext.o: In function fasttext::FastText::test(std::istream&, int, float, fasttext::Meter&) const': fasttext.cc:(.text+0x1960): undefined reference tofasttext::Meter::log(std::vector<int, std::allocator > const&, std::vector<std::pair<float, int>, std::allocator<std::pair<float, int> > > const&)' fasttext.o: In function fasttext::FastText::writePerLabelMetrics(std::ostream&, fasttext::Meter&) const': fasttext.cc:(.text+0x261b): undefined reference tofasttext::Meter::precision(int)' fasttext.cc:(.text+0x26ca): undefined reference to fasttext::Meter::recall(int)' fasttext.cc:(.text+0x2811): undefined reference tofasttext::Meter::f1Score(int)' fasttext.o: In function fasttext::FastText::test(std::istream&, int, float)': fasttext.cc:(.text+0x2fb1): undefined reference tofasttext::Meter::recall() const' fasttext.cc:(.text+0x2fc1): undefined reference to fasttext::Meter::precision() const' /tmp/ccvKyczq.o: In functiontest(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > > const&)': main.cc:(.text+0x1278): undefined reference to fasttext::Meter::writeGeneralMetrics(std::ostream&, int) const' /tmp/ccvKyczq.o: In functionquantize(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > > const&)': main.cc:(.text+0x142e): undefined reference to fasttext::Args::parseArgs(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)' /tmp/ccvKyczq.o: In functiontrain(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > >)': main.cc:(.text+0x1999): undefined reference to `fasttext::Args::parseArgs(std::vector<std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::cxx11::basic_string<char, std::char_traits, std::allocator > > > const&)' collect2: error: ld returned 1 exit status make: *** [fasttext] Error 1

Suggestions of possible directions for resolving this problem are appreciated!

hoi-nx commented 5 years ago

When I try to compile the library as Setup & Requirements suggests by running make command, errors pop up as below: c++ -pthread -std=c++0x -O3 -funroll-loops args.o dictionary.o productquantizer.o matrix.o shmem_matrix.o qmatrix.o vector.o model.o utils.o fasttext.o src/main.cc -o fasttext -lrt ld: library not found for -lrt clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [fasttext] Error 1 how to fix on macbook

hovikgas commented 5 years ago

I have the same exact issue as you, @nguyenxuanhoi2903, did you ever get it to work?

guptaprkhr commented 4 years ago

Closing the issue due to lack of activity. Will reopen it if the error still persists with the new versions.