musyoku / chainer-gqn

Neural scene representation and rendering (GQN)
MIT License
182 stars 25 forks source link

gcc 4.8.4 three make #1

Closed ArashHosseini closed 6 years ago

ArashHosseini commented 6 years ago

hey @musyoku, my env is g ++ 4.8.4 on Ubuntu 14.04 LTS, so I used -std =c++1y, can you give a hint what it could be, thanks

three$ make
g++ -O3 -DNDEBUG -Wall -Wformat -march=native -shared -std=c++1y -fPIC -pthread -I./external `pkg-config --cflags glfw3` `python3.5 -m pybind11 --includes` ./external/gl3w/*.c ./core/base/*.cpp ./core/camera/*.cpp ./core/renderer/*.cpp ./core/scene/*.cpp `pkg-config --static --libs glfw3` -lGL pybind/three.cpp -o ../generative_query_network/gqn/three`python3-config --extension-suffix`
./core/base/object.cpp: In member function ‘void three::base::Object::reserve(int, int)’:
./core/base/object.cpp:8:18: error: ‘make_unique’ is not a member of ‘std’
         _faces = std::make_unique<glm::vec3i[]>(num_faces);
                  ^
./core/base/object.cpp:8:45: error: expected primary-expression before ‘[’ token
         _faces = std::make_unique<glm::vec3i[]>(num_faces);
                                             ^
./core/base/object.cpp:8:46: error: expected primary-expression before ‘]’ token
         _faces = std::make_unique<glm::vec3i[]>(num_faces);
                                              ^
./core/base/object.cpp:9:21: error: ‘make_unique’ is not a member of ‘std’
         _vertices = std::make_unique<glm::vec3f[]>(num_vertices);
                     ^
...
                                                               ^
./core/scene/object.cpp:32:90: error: expected primary-expression before ‘[’ token
         std::unique_ptr<glm::vec3f[]> vertex_normal_vectors = std::make_unique<glm::vec3f[]>(_num_vertices);
                                                                                          ^
./core/scene/object.cpp:32:91: error: expected primary-expression before ‘]’ token
         std::unique_ptr<glm::vec3f[]> vertex_normal_vectors = std::make_unique<glm::vec3f[]>(_num_vertices);
                                                                                           ^
make: *** [make] Error 1
musyoku commented 6 years ago

Hi. std::make_unique is a C++14 feature and c++1y doesn't support in some environments. But it is possible to implement it. https://stackoverflow.com/a/24609331

musyoku commented 6 years ago

I recommend updating to gcc6. https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91

ArashHosseini commented 6 years ago

i have implemented it as suggested by You. it was pretty straight forward. wherever make_unique occurred by adding the following lines solved the compiling stage for three and imgplot

    modified:   imgplot/core/data/image.cpp
    modified:   imgplot/core/data/object.cpp
    modified:   imgplot/core/view/image.cpp
    modified:   imgplot/core/view/object.cpp
    modified:   imgplot/core/window.cpp
    modified:   three/core/base/object.cpp
    modified:   three/core/renderer/renderer.cpp
    modified:   three/core/scene/cornell_box.cpp
    modified:   three/core/scene/object.cpp
namespace std {
    template<class T> struct _Unique_if {
        typedef unique_ptr<T> _Single_object;
    };

    template<class T> struct _Unique_if<T[]> {
        typedef unique_ptr<T[]> _Unknown_bound;
    };

    template<class T, size_t N> struct _Unique_if<T[N]> {
        typedef void _Known_bound;
    };

    template<class T, class... Args>
        typename _Unique_if<T>::_Single_object
        make_unique(Args&&... args) {
            return unique_ptr<T>(new T(std::forward<Args>(args)...));
        }

    template<class T>
        typename _Unique_if<T>::_Unknown_bound
        make_unique(size_t n) {
            typedef typename remove_extent<T>::type U;
            return unique_ptr<T>(new U[n]());
        }

    template<class T, class... Args>
        typename _Unique_if<T>::_Known_bound
        make_unique(Args&&...) = delete;
}

*also including system_error to window.cpp file thx again