elbamos / largeVis

An implementation of the largeVis algorithm for visualizing large, high-dimensional datasets, for R
340 stars 62 forks source link

installation error when compiling cpp code #20

Closed sparktsao closed 8 years ago

sparktsao commented 8 years ago
In file included from denseneighbors.cpp:5:0:
neighbors.h: In instantiation of ‘AnnoySearch<M, V>::AnnoySearch(const M&, Progress&) [with M = arma::Mat<double>; V = arma::Col<double>]’:
denseneighbors.cpp:55:76:   required from here
neighbors.h:137:75: error: invalid initialization of non-const reference of type ‘Progress&’ from an rvalue of type ‘<brace-enclosed initializer list>’
  AnnoySearch(const M& data, Progress& p) : data{data}, N(data.n_cols), p{p} { }
                                                                           ^

change p{p} to p(p) can fix the compilation error, but the code crash when i do randomProjectionTreeSearc in R.

elbamos commented 8 years ago

What compilation environment and system is this happening on?

From googling the error, it looks like you may be using a very old version of gcc with a bug in it: http://stackoverflow.com/questions/10509603/why-cant-i-initialize-a-reference-in-an-initializer-list-with-uniform-initializ

On Aug 20, 2016, at 8:41 AM, Spark Tsao notifications@github.com wrote:

In file included from denseneighbors.cpp:5:0: neighbors.h: In instantiation of ‘AnnoySearch<M, V>::AnnoySearch(const M&, Progress&) [with M = arma::Mat; V = arma::Col]’: denseneighbors.cpp:55:76: required from here neighbors.h:137:75: error: invalid initialization of non-const reference of type ‘Progress&’ from an rvalue of type ‘’ AnnoySearch(const M& data, Progress& p) : data{data}, N(data.n_cols), p{p} { } ^ change p{p} to p(p) can fix the compilation error, but the code crash when i do randomProjectionTreeSearc in R.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

sparktsao commented 8 years ago

my environment is 4.8, do i need to upgrade to 4.9?

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-amazon-linux/4.8.3/lto-wrapper
Target: x86_64-amazon-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,fortran,ada,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-amazon-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-amazon-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-amazon-linux
Thread model: posix
gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
elbamos commented 8 years ago

Could you try 4.9 and see what happens?

If you look at the travis results, you'll see that the code compiles without error on a variety of Linux and Mac OS X and Windows environments.

I would like to try to fix this, but since I don't have your environment, I need to rely on you to try things. I would really appreciate your help so we can resolve it.

On Aug 20, 2016, at 6:25 PM, Spark Tsao notifications@github.com wrote:

my environment is 4.8, do i need to upgrade to 4.9?

gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-amazon-linux/4.8.3/lto-wrapper Target: x86_64-amazon-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,fortran,ada,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-amazon-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-amazon-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-amazon-linux Thread model: posix gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

sparktsao commented 8 years ago

seems it's the compiler's issue, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50025 we can repeat the compilation error by the following simple code at https://gcc.godbolt.org/, 4.8.2 with error, but 4.9.2 is ok, i will update my compiler, thank you for answering!

class B
{
public:
    int i;
};
class C
{
public:
    int i;
};
class A
{
public:
    A(B& b, C& c): _b{b}, _c{c}
    {
    }  
public:
    B& _b;
    C& _c;
}; 
elbamos commented 8 years ago

Thank you for following up!