Skip to content

Trying to buld the library with QPBO on a macbook M1  #148

@lutfiorabi

Description

@lutfiorabi

I've been trying to build the library with QPBO enabled for CGC since as far as I understood it, the library needed it for CGC. To start off I did this:

cmake \
  -DCMAKE_PREFIX_PATH=/Users/rop/anaconda3/envs/nifty-dev \
  -DWITH_ZLIB=ON \
  -DBUILD_NIFTY_PYTHON=ON \
  -DWITH_QPBO=ON \
  ..
  
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- NIFTY v1.1.0
CMake Warning (dev) at CMakeLists.txt:158 (find_package):
  Policy CMP0167 is not set: The FindBoost module is removed.  Run "cmake
  --help-policy CMP0167" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /Users/rop/anaconda3/envs/nifty-dev/share/cmake/pybind11/FindPythonLibsNew.cmake:101 (message):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning, or
  preferably upgrade to using FindPython, either by calling it explicitly
  before pybind11, or by setting PYBIND11_FINDPYTHON ON before pybind11.
Call Stack (most recent call first):
  /Users/rop/anaconda3/envs/nifty-dev/share/cmake/pybind11/pybind11Tools.cmake:50 (find_package)
  /Users/rop/anaconda3/envs/nifty-dev/share/cmake/pybind11/pybind11Common.cmake:228 (include)
  /Users/rop/anaconda3/envs/nifty-dev/share/cmake/pybind11/pybind11Config.cmake:250 (include)
  src/python/CMakeLists.txt:4 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found pybind11: /Users/rop/anaconda3/envs/nifty-dev/include (found version "2.13.6")
-- Using c++ 17 for pybind
-- MOD_LIBS
-- HDF5_LIBRARIES
-- Configuring done (0.6s)
-- Generating done (0.2s)
-- Build files have been written to: /Users/rop/PycharmProjects/PythonProject1/nifty/bld

now when I call make the following error occurred:

(nifty-dev) rop@MacBookAir bld % make
[  1%] Building CXX object src/external_libs/qpbo/CMakeFiles/external_qpbo.dir/__/__/__/externals/qpbo/QPBO.cpp.o
In file included from /Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/QPBO.cpp:918:
/Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/instances.inc:14:25: error: explicit specialization of 'get_type_information' after instantiation
   14 |         inline void QPBO<int>::get_type_information(const char*& type_name, const char*& type_format)
      |                                ^
/Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/QPBO.cpp:293:2: note: implicit instantiation first required here
  293 |         get_type_information(type_name, type_format);
      |         ^
In file included from /Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/QPBO.cpp:918:
/Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/instances.inc:21:27: error: explicit specialization of 'get_type_information' after instantiation
   21 |         inline void QPBO<float>::get_type_information(const char*& type_name, const char*& type_format)
      |                                  ^
/Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/QPBO.cpp:293:2: note: implicit instantiation first required here
  293 |         get_type_information(type_name, type_format);
      |         ^
In file included from /Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/QPBO.cpp:918:
/Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/instances.inc:28:28: error: explicit specialization of 'get_type_information' after instantiation
   28 |         inline void QPBO<double>::get_type_information(const char*& type_name, const char*& type_format)
      |                                   ^
/Users/rop/PycharmProjects/PythonProject1/nifty/externals/qpbo/QPBO.cpp:293:2: note: implicit instantiation first required here
  293 |         get_type_information(type_name, type_format);
      |         ^
3 errors generated.
make[2]: *** [src/external_libs/qpbo/CMakeFiles/external_qpbo.dir/__/__/__/externals/qpbo/QPBO.cpp.o] Error 1
make[1]: *** [src/external_libs/qpbo/CMakeFiles/external_qpbo.dir/all] Error 2
make: *** [all] Error 2

Now the issue seems to be that QPBO's implementation has #include "instances.inc" at the end of the file when it should be included earlier. I'm not sure if that's the case or if I'm doing something wrong, but after moving it all the way to the top of the file I get this error instead:

(nifty-dev) rop@MacBookAir bld % make   
[  1%] Building CXX object src/external_libs/qpbo/CMakeFiles/external_qpbo.dir/__/__/__/externals/qpbo/QPBO.cpp.o
[  2%] Linking CXX shared library libexternal_qpbo.dylib
Undefined symbols for architecture arm64:
  "QPBO<double>::InitFreeList()", referenced from:
      QPBO<double>::AllocateNewEnergy(int*) in QPBO_extra.cpp.o
  "QPBO<double>::AddPairwiseTerm(int, int, double, double, double, double)", referenced from:
      QPBO<double>::AllocateNewEnergy(int*) in QPBO_extra.cpp.o
  "QPBO<double>::reallocate_arcs(int)", referenced from:
      QPBO<double>::SetMaxEdgeNum(int) in QPBO_extra.cpp.o
      QPBO<double>::Probe(int*, QPBO<double>::ProbeOptions&) in QPBO_extra.cpp.o
  "QPBO<double>::TransformToSecondStage(bool)", referenced from:
      QPBO<double>::Improve(int, int*, int*) in QPBO_extra.cpp.o
  "QPBO<double>::Solve()", referenced from:
      QPBO<double>::Probe(int*) in QPBO_extra.cpp.o
      QPBO<double>::Probe(int*) in QPBO_extra.cpp.o
  "QPBO<float>::InitFreeList()", referenced from:
      QPBO<float>::AllocateNewEnergy(int*) in QPBO_extra.cpp.o
  "QPBO<float>::AddPairwiseTerm(int, int, float, float, float, float)", referenced from:
      QPBO<float>::AllocateNewEnergy(int*) in QPBO_extra.cpp.o
  "QPBO<float>::reallocate_arcs(int)", referenced from:
      QPBO<float>::SetMaxEdgeNum(int) in QPBO_extra.cpp.o
      QPBO<float>::Probe(int*, QPBO<float>::ProbeOptions&) in QPBO_extra.cpp.o
  "QPBO<float>::TransformToSecondStage(bool)", referenced from:
      QPBO<float>::Improve(int, int*, int*) in QPBO_extra.cpp.o
  "QPBO<float>::Solve()", referenced from:
      QPBO<float>::Probe(int*) in QPBO_extra.cpp.o
      QPBO<float>::Probe(int*) in QPBO_extra.cpp.o
  "QPBO<int>::InitFreeList()", referenced from:
      QPBO<int>::AllocateNewEnergy(int*) in QPBO_extra.cpp.o
  "QPBO<int>::AddPairwiseTerm(int, int, int, int, int, int)", referenced from:
      QPBO<int>::AllocateNewEnergy(int*) in QPBO_extra.cpp.o
  "QPBO<int>::reallocate_arcs(int)", referenced from:
      QPBO<int>::SetMaxEdgeNum(int) in QPBO_extra.cpp.o
      QPBO<int>::Probe(int*, QPBO<int>::ProbeOptions&) in QPBO_extra.cpp.o
  "QPBO<int>::TransformToSecondStage(bool)", referenced from:
      QPBO<int>::Improve(int, int*, int*) in QPBO_extra.cpp.o
  "QPBO<int>::Solve()", referenced from:
      QPBO<int>::Probe(int*) in QPBO_extra.cpp.o
      QPBO<int>::Probe(int*) in QPBO_extra.cpp.o
ld: symbol(s) not found for architecture arm64
c++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/external_libs/qpbo/libexternal_qpbo.dylib] Error 1
make[1]: *** [src/external_libs/qpbo/CMakeFiles/external_qpbo.dir/all] Error 2
make: *** [all] Error 2

I'd appreciate further assistance on where the issue may be

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions