Hello everyone. The solution to this issue might be trivial; however, I haven’t been able to find it, and I have tried several things already. I am constrained to using g++@>=5.
I implemented this example 3 some time ago, and was able to run it with no problems.
Now, due to issues when compiling libtorch with g++-9, I have come back to it, to get it working with this compiler.
My CMakeLists.txt looks as follows:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(LibtorchExample)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
#add_compile_definitions(D_GLIBCXX_USE_CXX11_ABI=1)

set(Torch_DIR /Users/ananias/Developer/libtorch/share/cmake/Torch)
find_package(Torch REQUIRED)
set(CMAKE_CXX_STANDARD 11)

add_executable(LibtorchExample main.cpp discriminator.h generator.h)

target_link_libraries(LibtorchExample "${TORCH_LIBRARIES}")
set_property(TARGET LibtorchExample PROPERTY CXX_STANDARD 11)

I am getting the following kinds of errors:
/usr/local/Cellar/gcc/9.2.0_1/include/c++/9.2.0/x86_64-apple-darwin18/bits/c++config.h:273:27: error: #if with no expression
  273 | #if _GLIBCXX_USE_CXX11_ABI

/usr/local/Cellar/gcc/9.2.0_1/include/c++/9.2.0/x86_64-apple-darwin18/bits/c++config.h:554:3: error: operator '&&' has no right operand
  554 |   && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \

/usr/local/Cellar/gcc/9.2.0_1/include/c++/9.2.0/string:58:53: error: operator '&&' has no right operand
   58 | #if __cplusplus >= 201703L && _GLIBCXX_USE_CXX11_ABI

/usr/local/Cellar/gcc/9.2.0_1/include/c++/9.2.0/stdexcept:236:28: error: operator '||' has no left operand
  236 | #if _GLIBCXX_USE_CXX11_ABI || _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS

I have tried a couple of things, including installing the latest libtorch version, according to this issue 8, to no avail.
I have tried setting the ABI flags in one way or another, but my attempts haven’t had any effect even on the type of error I am getting.
Any recommendations are very welcome.