opengm / opengm

A C++ Library for Discrete Graphical Models
MIT License
411 stars 206 forks source link

can't compile with both of MRF-lib and GCO at the same time #176

Open tttamaki opened 10 years ago

tttamaki commented 10 years ago

Because MRF-lib and GCO has different "GCoptimization.h" (same name, but different), I receive a lot of errors (depending of header path order) when I include the following headers in the same cpp file:

include <opengm/inference/external/gco.hxx>

include <opengm/inference/external/mrflib.hxx>

Possible solutions are:

A patch renaming a file may be too large. Renaming file with a small patch might be better.

opengm commented 10 years ago

Hi! For us it works if MRF is before GCO, but you are right that there are potential pitfalls that we should fix.

As You have seen we already fix these libraries to get them work in a general software framework. However we try to modify as less as possible at the code of others.

The best solution in my mind would be to include

include "GCO-v3.0.src-patched/GCoptimization.h"

instead of

include "GCoptimization.h"

in our wrapper gco.hxx.

Since we are planning to restructure the downloading, compiling, and installing (later does not work yet) for external libraries any way, I would suggest to try the order MRF before GCO for the moment. If this does not work please let me know and I will add an hot-fix.

By the way, a small example would help us. We can add it to the test-suit to check if this is fixed after this re-factoring.

Best Joerg

On 11/27/2013 02:01 AM, Toru Tamaki wrote:

Because MRF-lib and GCO has different "GCoptimization.h" (same name, but different), I receive a lot of errors (depending of header path order) when I include the following headers in the same cpp file:

include

include

Possible solutions are:

  • rename GCO/GCoptimization.h to something
  • rename MRF/GCoptimization.h to something
  • and make a corresponding patch, or write some lines of shell script to add
  • or, do not recommend to use both at the same time

A patch renaming a file may be too large. Renaming file with a small patch might be better.

— Reply to this email directly or view it on GitHub https://github.com/opengm/opengm/issues/176.

tttamaki commented 10 years ago

I'm not sure what "the order MRF before GCO" actually is, so I tried four combinations on my env. In conclusion, the #include order do not matter, but the order of "-I option" does matter: it fails when MRF comes first. Does this contradict with your suggestion?

Here is my small test. compiler version is shown at bottom.

$ make test -k echo "test11" test11 cat -n mrf_vs_gco1.cpp 1 #include <opengm/inference/external/mrflib.hxx> 2 #include <opengm/inference/external/gco.hxx> 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco1.cpp -I/usr/local/include \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int In file included from mrf_vsgco1.cpp:2: /usr/local/include/opengm/inference/external/gco.hxx:75:18: error: use of undeclared identifier 'gcoLib' typedef gcoLib::GCoptimization::EnergyTermType EnergyTermType; ^ /usr/local/include/opengm/inference/external/gco.hxx:85:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGeneralGraph* GCOGeneralGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:86:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGridGraph* GCOGridGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:159:33: error: use of undeclared identifier 'gcoLib' GCOGridGraph = new gcoLib::GCoptimizationGridGraph(sizeX, sizeY, numLabels); ^ /usr/local/include/opengm/inference/external/gco.hxx:163:36: error: use of undeclared identifier 'gcoLib' GCOGeneralGraph = new gcoLib::GCoptimizationGeneralGraph(numNodes, numLabels); ^ 5 errors generated. make: * [test11] Error 1 echo "test12" test12 cat -n mrf_vs_gco1.cpp 1 #include <opengm/inference/external/mrflib.hxx> 2 #include <opengm/inference/external/gco.hxx> 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco1.cpp -I/usr/local/include \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int echo "test21" test21 cat -n mrf_vs_gco2.cpp 1 #include <opengm/inference/external/gco.hxx> 2 #include <opengm/inference/external/mrflib.hxx> 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco2.cpp -I/usr/local/include \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int In file included from mrf_vsgco2.cpp:1: /usr/local/include/opengm/inference/external/gco.hxx:75:18: error: use of undeclared identifier 'gcoLib' typedef gcoLib::GCoptimization::EnergyTermType EnergyTermType; ^ /usr/local/include/opengm/inference/external/gco.hxx:85:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGeneralGraph* GCOGeneralGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:86:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGridGraph* GCOGridGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:159:33: error: use of undeclared identifier 'gcoLib' GCOGridGraph = new gcoLib::GCoptimizationGridGraph(sizeX, sizeY, numLabels); ^ /usr/local/include/opengm/inference/external/gco.hxx:163:36: error: use of undeclared identifier 'gcoLib' GCOGeneralGraph = new gcoLib::GCoptimizationGeneralGraph(numNodes, numLabels); ^ 5 errors generated. make: * [test21] Error 1 echo "test22" test22 cat -n mrf_vs_gco2.cpp 1 #include <opengm/inference/external/gco.hxx> 2 #include <opengm/inference/external/mrflib.hxx> 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco2.cpp -I/usr/local/include \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int make: Target `test' not remade because of errors.

$ g++ -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin12.5.0 Thread model: posix

joergkappes commented 10 years ago

Hi, I suggest to use the linking order GCO, MRF as a hot-fix. We will fix this in a clean way when re-factoring the external-library framework.

Best Joerg

On 11/28/2013 04:01 PM, Toru Tamaki wrote:

I'm not sure what "the order MRF before GCO" actually is, so I tried four combinations on my env. In conclusion, the #include order do not matter, but the order of "-I option" does matter: it fails when MRF comes first. Does this contradict with your suggestion?

Here is my small test. compiler version is shown at bottom.

$ make test -k echo "test11" test11 cat -n mrf_vs_gco1.cpp 1 #include 2 #include 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco1.cpp -I/usr/local/include \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int In file included from mrf_vsgco1.cpp:2: /usr/local/include/opengm/inference/external/gco.hxx:75:18: error: use of undeclared identifier 'gcoLib' typedef gcoLib::GCoptimization::EnergyTermType EnergyTermType; ^ /usr/local/include/opengm/inference/external/gco.hxx:85:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGeneralGraph* GCOGeneralGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:86:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGridGraph* GCOGridGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:159:33: error: use of undeclared identifier 'gcoLib' GCOGridGraph = new gcoLib::GCoptimizationGridGraph(sizeX, sizeY, numLabels); ^ /usr/local/include/opengm/inference/external/gco.hxx:163:36: error: use of undeclared identifier 'gcoLib' GCOGeneralGraph = new gcoLib::GCoptimizationGeneralGraph(numNodes, numLabels); ^ 5 errors generated. make: * [test11] Error 1 echo "test12" test12 cat -n mrf_vs_gco1.cpp 1 #include 2 #include 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco1.cpp -I/usr/local/include \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int echo "test21" test21 cat -n mrf_vs_gco2.cpp 1 #include 2 #include 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco2.cpp -I/usr/local/include \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int In file included from mrf_vsgco2.cpp:1: /usr/local/include/opengm/inference/external/gco.hxx:75:18: error: use of undeclared identifier 'gcoLib' typedef gcoLib::GCoptimization::EnergyTermType EnergyTermType; ^ /usr/local/include/opengm/inference/external/gco.hxx:85:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGeneralGraph* GCOGeneralGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:86:10: error: use of undeclared identifier 'gcoLib' gcoLib::GCoptimizationGridGraph* GCOGridGraph; ^ /usr/local/include/opengm/inference/external/gco.hxx:159:33: error: use of undeclared identifier 'gcoLib' GCOGridGraph = new gcoLib::GCoptimizationGridGraph(sizeX, sizeY, numLabels); ^ /usr/local/include/opengm/inference/external/gco.hxx:163:36: error: use of undeclared identifier 'gcoLib' GCOGeneralGraph = new gcoLib::GCoptimizationGeneralGraph(numNodes, numLabels); ^ 5 errors generated. make: * [test21] Error 1 echo "test22" test22 cat -n mrf_vs_gco2.cpp 1 #include 2 #include 3 int main (){return 0;} g++ -o mrf_vs_gco mrf_vs_gco2.cpp -I/usr/local/include \ -I../opengm/src/external/GCO-v3.0.src-patched/ \ -I../opengm/src/external/MRF-v2.1.src-patched/ \ -DMRFCOSTVALUE=double -DMRFENERGYVALUE=double -DMRFLABELVALUE=int \ -DGCOENERGYVALUE=double -DGCOLABELVALUE=int make: Target `test' not remade because of errors.

$ g++ -v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin12.5.0 Thread model: posix

— Reply to this email directly or view it on GitHub https://github.com/opengm/opengm/issues/176#issuecomment-29468821.