Error Cmake build together with the program include .h

alex290: <p>Help. I can’t figure out what the reason is.When inserting a project in a class .H when building, I get these errors<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/0/d0d6712ab839ba84d4262b9c49dc086861a78468.png" data-download-href="https://discuss.pytorch.org/uploads/default/d0d6712ab839ba84d4262b9c49dc086861a78468" title="123"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0d6712ab839ba84d4262b9c49dc086861a78468_2_690x345.png" alt="123" data-base62-sha1="tNsKJM7KJK4wbhOhmOAm7z7o2yk" width="690" height="345" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0d6712ab839ba84d4262b9c49dc086861a78468_2_690x345.png, https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0d6712ab839ba84d4262b9c49dc086861a78468_2_1035x517.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/d/0/d0d6712ab839ba84d4262b9c49dc086861a78468_2_1380x690.png 2x" data-dominant-color="4C4B4B"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">123</span><span class="informations">1384×693 140 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<blockquote>
<p>In file included from /usr/local/include/wx-3.2/wx/intl.h:18,<br>
from /usr/local/include/wx-3.2/wx/wx.h:22,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/filesetting.h:6,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/setting.h:5,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:4,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:<br>
/usr/local/torch/libtorch/include/ATen/core/function_schema.h: In constructor ‘c10::Argument::Argument(std::string, c10::TypePtr, c10::TypePtr, std::optional, std::optional<a>c10::IValue</a>, bool, std::optional<a>c10::AliasInfo</a>)’:<br>
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:49:9: error: anachronistic old-style base class initializer [-fpermissive]<br>
49 |         N_(N),<br>
|         ^~<br>
In file included from /usr/local/torch/libtorch/include/ATen/core/op_registration/infer_schema.h:8,<br>
from /usr/local/torch/libtorch/include/torch/library.h:61,<br>
from /usr/local/torch/libtorch/include/torch/csrc/autograd/autograd_not_implemented_fallback.h:3,<br>
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/autograd.h:4,<br>
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/all.h:7,<br>
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,<br>
from /home/alex/devel/ScalpByBit/include/nn/nnlibtrade.h:3,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/nn/nntrade.h:4,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:13,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:<br>
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:48:61: error: unnamed initializer for ‘c10::Argument’, which has no base classes<br>
48 |         real_type_(real_type ? std::move(real_type) : type_),<br>
|                                                             ^<br>
In file included from /usr/local/include/wx-3.2/wx/intl.h:18,<br>
from /usr/local/include/wx-3.2/wx/wx.h:22,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/filesetting.h:6,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/setting/setting.h:5,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:4,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:<br>
/usr/local/torch/libtorch/include/ATen/core/function_schema.h: In copy constructor ‘c10::Argument::Argument(const c10::Argument&amp;)’:<br>
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:64:9: error: anachronistic old-style base class initializer [-fpermissive]<br>
64 |         N_(rhs.N_),<br>
|         ^~<br>
In file included from /usr/local/torch/libtorch/include/ATen/core/op_registration/infer_schema.h:8,<br>
from /usr/local/torch/libtorch/include/torch/library.h:61,<br>
from /usr/local/torch/libtorch/include/torch/csrc/autograd/autograd_not_implemented_fallback.h:3,<br>
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/autograd.h:4,<br>
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/all.h:7,<br>
from /usr/local/torch/libtorch/include/torch/csrc/api/include/torch/torch.h:3,<br>
from /home/alex/devel/ScalpByBit/include/nn/nnlibtrade.h:3,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/nn/nntrade.h:4,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/…/data/dataglobal.h:13,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.h:3,<br>
from /home/alex/devel/ScalpByBit/src/cashbackbot/cashbackitems.cpp:1:<br>
/usr/local/torch/libtorch/include/ATen/core/function_schema.h:63:35: error: unnamed initializer for ‘c10::Argument’, which has no base classes<br>
63 |         real_type_(rhs.real_type_),</p>
</blockquote>
<p>Cmake</p>
<pre><code class="lang-auto">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)
</code></pre>

BiggestZocker: <p>Are your includes correct? They may be tricky. Can you show them please?</p>

alex290: <p>And so on in order.<br>
I found out that this error occurs if I connect wxwidgets.<br>
It appears if you just paste the <span class="hashtag-raw">#include</span> &lt;torch/torch.h&gt; .h file.<br>
If you insert <span class="hashtag-raw">#include</span> &lt;torch/torch.h&gt; into .cpp, there will be no error.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/4/a407e536dddcda41b1ccf3232532e8cd5e9a0750.png" data-download-href="https://discuss.pytorch.org/uploads/default/a407e536dddcda41b1ccf3232532e8cd5e9a0750" title="123"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a407e536dddcda41b1ccf3232532e8cd5e9a0750_2_690x453.png" alt="123" data-base62-sha1="np5dH9g1C5R5ZgIiGGuITfzt3pe" width="690" height="453" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a407e536dddcda41b1ccf3232532e8cd5e9a0750_2_690x453.png, https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a407e536dddcda41b1ccf3232532e8cd5e9a0750_2_1035x679.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/a/4/a407e536dddcda41b1ccf3232532e8cd5e9a0750_2_1380x906.png 2x" data-dominant-color="292929"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">123</span><span class="informations">1485×977 210 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
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.</p>
<p><a href="https://drive.google.com/file/d/15U2mJcTsAPlOeTp3o3zja30HcEVaWpW7/view?usp=sharing" rel="noopener nofollow ugc">archive</a><br>
Here I’m throwing off the archive of an empty Cmake project</p>

alex290: <p>I tried using <strong>QT</strong> instead of <strong>wxWidgets</strong>, and also got a bunch of errors during assembly… It’s very strange.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/9/9/99972829dde1e6b2a729156104e550e7b4d1c2d6.png" data-download-href="https://discuss.pytorch.org/uploads/default/99972829dde1e6b2a729156104e550e7b4d1c2d6" title="123"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/9/9/99972829dde1e6b2a729156104e550e7b4d1c2d6_2_690x381.png" alt="123" data-base62-sha1="lUIU7hj2GyEF31qWRlTC1o0GtuK" width="690" height="381" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/9/9/99972829dde1e6b2a729156104e550e7b4d1c2d6_2_690x381.png, https://discuss.pytorch.org/uploads/default/optimized/3X/9/9/99972829dde1e6b2a729156104e550e7b4d1c2d6_2_1035x571.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/9/9/99972829dde1e6b2a729156104e550e7b4d1c2d6_2_1380x762.png 2x" data-dominant-color="A0CADF"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">123</span><span class="informations">1477×816 135 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

BiggestZocker: <p>Some Libtorch or Cuda versions only allow older standarts than 17. Maybe try 11. On <a href="https://quasar.ugent.be/files/doc/cuda-msvc-compatibility.html" class="inline-onebox" rel="noopener nofollow ugc">cuda-msvc-compatibility</a> you can see which CUDA works with which Microsoft Visual C++ and based on this, you can look here <a href="https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170" class="inline-onebox" rel="noopener nofollow ugc">Microsoft C/C++ language conformance | Microsoft Learn</a> to see which C++ standarts are usable.<br>
You then would have to make sure to install that VSC++ version with the correct C++ Standart enabled</p>

alex290: <p>I am writing in Linux GCC 13. I’ve already tried my standard, it doesn’t work.</p>