mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.87k stars 1.18k forks source link

build error for Ubuntu 16.04 #200

Closed krumo closed 5 years ago

krumo commented 5 years ago

When I tried compiling pbrt project, I encountered the following error:

In file included from /home/squall/master/computer_graphics/pbrt-v3/src/ext/glog/src/stl_logging_unittest.cc:63:0:
/home/squall/master/computer_graphics/pbrt-v3/src/ext/glog/src/googletest.h:500:8: error: redefinition of ‘struct google::FlagSaver’
 struct FlagSaver {
        ^
In file included from /home/squall/anaconda3/include/glog/logging.h:86:0,
                 from /home/squall/master/computer_graphics/pbrt-v3/src/ext/glog/src/stl_logging_unittest.cc:61:
/home/squall/anaconda3/include/gflags/gflags.h:278:23: error: previous definition of ‘struct google::FlagSaver’
 class GFLAGS_DLL_DECL FlagSaver {
                       ^
cc1plus: warning: unrecognized command line option ‘-Wno-unnamed-type-template-args’
src/ext/glog/CMakeFiles/stl_logging_unittest.dir/build.make:62: recipe for target 'src/ext/glog/CMakeFiles/stl_logging_unittest.dir/src/stl_logging_unittest.cc.o' failed
make[2]: *** [src/ext/glog/CMakeFiles/stl_logging_unittest.dir/src/stl_logging_unittest.cc.o] Error 1
CMakeFiles/Makefile2:989: recipe for target 'src/ext/glog/CMakeFiles/stl_logging_unittest.dir/all' failed
make[1]: *** [src/ext/glog/CMakeFiles/stl_logging_unittest.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

My cmake version is 3.5.1 and I installed pbrt according to the instructions in the readme.md file. Is there anyone help me to build this project? Thanks in advance!

mmp commented 5 years ago

Strange. I just tried with ubuntu 16.04 (and cmake 3.5.1, gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609), and it builds fine--I didn't get that error.

Based on your error message, it looks like it may be finding the glog/logging.h #include file from the wrong place--not from the version of glog that is included with pbrt. I'm not sure why that would happen, however.

As a workaround, you might try deleting the 35 or so lines starting at line 463 of src/ext/glog/CMakeLists.txt that refer to stl_logging_unittest. There's no need to build that for pbrt anyway.