alecjacobson / computer-graphics-shader-pipeline

Computer Graphics Assignment about the Shader Pipeline
14 stars 22 forks source link

Missing includes in header files #45

Open Dxyk opened 4 years ago

Dxyk commented 4 years ago

Hi, the build is failing under MacOS.

Reproduction steps:

  1. clone directory
  2. run mkdir build; cd build; cmake ..; make
  3. build fails

Can be fixed by adding the following include statements in the header files

abhimadan commented 4 years ago

Thanks for pointing this out, though it's strange, as it's worked fine for me on both Mojave and Catalina. What were the build errors you were getting before your fixes?

Dxyk commented 4 years ago

Ignoring the 20+ish warning messages, here are the errors. Let me know if you need the full stacktrace.

[ 95%] Building CXX object CMakeFiles/shaderpipeline.dir/main.cpp.o
In file included from ./main.cpp:9:
In file included from ./include/create_shader_program_from_files.h:34:
./include/print_program_info_log.h:32:10: error: 
      no member named 'cerr' in namespace 'std'
    std::cerr << log << std::endl;
    ~~~~~^
In file included from ./main.cpp:9:
In file included from ./include/create_shader_program_from_files.h:35:
./include/print_shader_info_log.h:40:10: error: 
      no member named 'cerr' in namespace 'std'
    std::cerr << REDRUM("ERROR") << ": f...
    ~~~~~^
./include/print_shader_info_log.h:48:10: error: 
      no member named 'cerr' in namespace 'std'
    std::cerr << log << std::endl;
    ~~~~~^
In file included from ./main.cpp:9:
./include/create_shader_program_from_files.h:57:23: error: 
      implicit instantiation of undefined
      template 'std::__1::basic_ifstream<char,
      std::__1::char_traits<char> >'
        std::ifstream t(path);
                      ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:145:32: note: 
      template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_ifstream;
                               ^
4 errors generated.
make[2]: *** [CMakeFiles/shaderpipeline.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/shaderpipeline.dir/all] Error 2
make: *** [all] Error 2
abhimadan commented 4 years ago

Oh I think I see your problem now. It looks like you've rearranged the include order at the top of main.cpp, as in the repo we have #include "read_json.h" at line 9 (which includes fstream) and not create_shader_program_from_files.h. It also looks like this happened in create_shader_program_from_files.h, which should include iostream before print_shader_info_log.h.

That being said, you're right that this is still a problem on our end, as our header files shouldn't be flaky with include order. I'll make the changes you suggested. Thanks!