sweeneychris / TheiaSfM

An open source library for multiview geometry and structure from motion
Other
904 stars 281 forks source link

error related with gflags #244

Closed AIBluefisher closed 5 years ago

AIBluefisher commented 5 years ago

Hi, @sweeneychris I found an error when compiling theia that related with gflags. But I don't know how to solve it. May you help me?

/home/chenyu/Projects/TheiaSfM/src/theia/io/write_calibration_test.cc:45:14: error: expected constructor, destructor, or type conversion before ‘(’ token
 DEFINE_string(json_file, "io/write_calibration_test.json",
              ^
/home/chenyu/Projects/TheiaSfM/src/theia/io/write_calibration_test.cc:51:65: error: ‘FLAGS_json_file’ was not declared in this scope
 std::string json_filepath = THEIA_DATA_DIR + std::string("/") + FLAGS_json_file;
                                                                 ^
src/theia/CMakeFiles/write_calibration_test.dir/build.make:86: recipe for target 'src/theia/CMakeFiles/write_calibration_test.dir/io/write_calibration_test.cc.o' failed
sweeneychris commented 5 years ago

Looks like we may have forgotten to add the gflags headers in that file. Could you submit a patch where you add the gflags header around here? https://github.com/sweeneychris/TheiaSfM/blob/master/src/theia/io/write_calibration_test.cc#L38

AIBluefisher commented 5 years ago

I have submitted the patch. But it seems gflags itself has some internal issues with DEFINE_xxx. I installed gflags under the fix-gflags-define branch and fixed this issue.

Besides, I record the script for installing theia, maybe useful for someone that get trouble with using theia

## GLOG, GFlags, GTest
#sudo apt-get install libgoogle-glog-dev libgflags-dev

git clone https://github.com/google/glog.git
cd glog 
mkdir build && cd build
cmake ..
make -j8
sudo make install

git clone https://github.com/AIBluefisher/googletest.git
cd googletest
mkdir build
cd build
cmake ..
make -j8
sudo make install

git clone https://github.com/gflags/gflags
cd gflags
git checkout fix-gflags-define
mkdir build && cd build
make -j8
sudo make install

## openimageio, opengl, et.
sudo apt-get install libopenimageio1.6 libopenimageio-dev
sudo apt-get install freeglut3 freeglut3-dev libglew-dev
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install libopenexr-dev

## Eigen 3
hg clone https://bitbucket.org/eigen/eigen
mkdir eigen_build && cd eigen_build
cmake . ../eigen
make && sudo make install
cd ..

## Ceres-Solver
sudo apt-get install libatlas-base-dev libsuitesparse-dev
git clone https://github.com/ceres-solver/ceres-solver.git
cd ceres-solver
git checkout $(git describe --tags) # Checkout the latest release
mkdir build
cd build
cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF
make -j8
sudo make install

## install rocksdb(required by TheiaSfM)
git clone https://github.com/facebook/rocksdb
cd rocksdb
git checkout v5.9.2
make -j8 shared_lib
sudo make install
sudo cp /usr/local/lib/librocksdb.* /usr/lib

## install rapidjson
git clone https://github.com/Tencent/rapidjson.git
cd rapidjson
git submodule update --init
mkdir build && cd build
cmake ..
make -j8
sudo make install

## build && install TheiaSfM
git clone https://github.com/sweeneychris/TheiaSfM.git
cd TheiaSfM
mkdir build && cd build
cmake ..
make -j8
make test
sudo make install