Error Cmake build together with the program include .h

Help. I can’t figure out what the reason is.When inserting a project in a class .H when building, I get these errors

In file included from /usr/local/include/wx-3.2/wx/intl.h:18,
from /usr/local/include/wx-3.2/wx/wx.h:22,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/filesetting.h:6,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/setting.h:5,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:4,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:
/usr/local/torch/libtorch/include/ATen/core/function_schema.h: In constructor ‘c10::Argument::Argument(std::string, c10::TypePtr, c10::TypePtr, std::optional, std::optionalc10::IValue, bool, std::optionalc10::AliasInfo)’:
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:49:9: error: anachronistic old-style base class initializer [-fpermissive]
49 | N_(N),
| ^~
In file included from /usr/local/torch/libtorch/include/ATen/core/op_registration/infer_schema.h:8,
from /usr/local/torch/libtorch/include/torch/library.h:61,
from /usr/local/torch/libtorch/include/torch/csrc/autograd/autograd_not_implemented_fallback.h:3,
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/autograd.h:4,
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/all.h:7,
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
from /home/alex/devel/ScalpByBit/include/nn/nnlibtrade.h:3,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/nn/nntrade.h:4,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:13,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:48:61: error: unnamed initializer for ‘c10::Argument’, which has no base classes
48 | real_type_(real_type ? std::move(real_type) : type_),
| ^
In file included from /usr/local/include/wx-3.2/wx/intl.h:18,
from /usr/local/include/wx-3.2/wx/wx.h:22,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/filesetting.h:6,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/setting.h:5,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:4,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:
/usr/local/torch/libtorch/include/ATen/core/function_schema.h: In copy constructor ‘c10::Argument::Argument(const c10::Argument&)’:
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:64:9: error: anachronistic old-style base class initializer [-fpermissive]
64 | N_(rhs.N_),
| ^~
In file included from /usr/local/torch/libtorch/include/ATen/core/op_registration/infer_schema.h:8,
from /usr/local/torch/libtorch/include/torch/library.h:61,
from /usr/local/torch/libtorch/include/torch/csrc/autograd/autograd_not_implemented_fallback.h:3,
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/autograd.h:4,
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/all.h:7,
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,
from /home/alex/devel/ScalpByBit/include/nn/nnlibtrade.h:3,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/nn/nntrade.h:4,
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:13,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:63:35: error: unnamed initializer for ‘c10::Argument’, which has no base classes
63 | real_type_(rhs.real_type_),

Cmake

cmake_minimum_required(VERSION 3.20.0)
project(ScalpByBit  VERSION 0.1.0)

set(FileNAME scalp)

set(CMAKE_CXX_STANDARD 17) 
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_PREFIX_PATH "/usr/local/torch/libtorch")
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-12.4/bin/nvcc")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
find_package(Torch REQUIRED)

find_package(wxWidgets REQUIRED COMPONENTS aui html net core base)
include(${wxWidgets_USE_FILE})

file(GLOB project
    src/*
    src/data/*
    src/data/bybit/*
    src/data/setting/*
    src/data/nn/*
    src/res/*
    src/setting/*
    src/kline/*
    src/orderbook/*
    src/cashbackbot/*
    src/wsuser/*
    src/wsuser/*
    src/trade/*
)

add_executable(${FileNAME} ${project})

if(wxWidgets_FOUND)

    target_link_libraries(${FileNAME} ${wxWidgets_LIBRARIES})

    message(STATUS "Found wxWidgets ${wxWidgets_VERSION_STRING}")
else()
    message(STATUS "wxWidgets Not Found")
endif()

target_link_libraries(${FileNAME} "${TORCH_LIBRARIES}")
set_property(TARGET ${FileNAME} PROPERTY CXX_STANDARD 17)

Are your includes correct? They may be tricky. Can you show them please?

And so on in order.
I found out that this error occurs if I connect wxwidgets.
It appears if you just paste the #include <torch/torch.h> .h file.
If you insert #include <torch/torch.h> into .cpp, there will be no error.


That’s how it works like in the picture… But this creates problems. For example, every time a neural network is activated, it needs to be loaded with a trained model every time. Which is inconvenient.

archive
Here I’m throwing off the archive of an empty Cmake project

I tried using QT instead of wxWidgets, and also got a bunch of errors during assembly… It’s very strange.

Some Libtorch or Cuda versions only allow older standarts than 17. Maybe try 11. On cuda-msvc-compatibility you can see which CUDA works with which Microsoft Visual C++ and based on this, you can look here Microsoft C/C++ language conformance | Microsoft Learn to see which C++ standarts are usable.
You then would have to make sure to install that VSC++ version with the correct C++ Standart enabled

I am writing in Linux GCC 13. I’ve already tried my standard, it doesn’t work.