D
D
dalbio2022-03-17 17:32:26
Qt
dalbio, 2022-03-17 17:32:26

Error D8021 invalid numeric argument "/Wno-error=invalid-offsetof" where does this problem come from and how to solve it?

There is a project using qt libraries. Before that, it ran smoothly under visual studio (19/22 preview). But yesterday for some reason it stopped, help solve the problem.
Expanded version of the error (build output):

/nologo /TP -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN32_WINNT=0x0601 -D_WIN64 -ID:\fictional-system\out\build\x64-Debug -ID:\fictional-system -ID:\fictional-system\out\build\x64-Debug\fict_autogen\include -external:I C:\Qt\6.1.3\mingw81_64\include\QtWidgets -external:I C:\Qt\6.1.3\mingw81_64\include -external:I C:\Qt\6.1.3\mingw81_64\include\QtCore -external:I C:\Qt\6.1.3\mingw81_64\mkspecs\win32-g++ -external:I C:\Qt\6.1.3\mingw81_64\include\QtGui -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -Wno-error=invalid-offsetof -std:c++17 /showIncludes /FoCMakeFiles\fict.dir\main.cpp.obj /FdCMakeFiles\fict.dir\ /FS -c D:\fictional-system\main.cpp

All that brought the build window:
>------ Сборка запущено: проект: CMakeLists, конфигурация: Debug ------
  [1/3] Building CXX object CMakeFiles\fict.dir\main.cpp.obj
  FAILED: CMakeFiles/fict.dir/main.cpp.obj 
  C:\PROGRA~1\MICROS~2\2022\Preview\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\cl.exe  /nologo /TP -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN32_WINNT=0x0601 -D_WIN64 -ID:\fictional-system\out\build\x64-Debug -ID:\fictional-system -ID:\fictional-system\out\build\x64-Debug\fict_autogen\include -external:I C:\Qt\6.1.3\mingw81_64\include\QtWidgets -external:I C:\Qt\6.1.3\mingw81_64\include -external:I C:\Qt\6.1.3\mingw81_64\include\QtCore -external:I C:\Qt\6.1.3\mingw81_64\mkspecs\win32-g++ -external:I C:\Qt\6.1.3\mingw81_64\include\QtGui -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -Wno-error=invalid-offsetof -std:c++17 /showIncludes /FoCMakeFiles\fict.dir\main.cpp.obj /FdCMakeFiles\fict.dir\ /FS -c D:\fictional-system\main.cpp
D:\fictional-system\out\build\x64-Debug\cl : командная строка error D8021: недопустимый числовой аргумент "/Wno-error=invalid-offsetof"
  [2/3] Building CXX object CMakeFiles\fict.dir\fict_autogen\mocs_compilation.cpp.obj
  FAILED: CMakeFiles/fict.dir/fict_autogen/mocs_compilation.cpp.obj 
  C:\PROGRA~1\MICROS~2\2022\Preview\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\cl.exe  /nologo /TP -DMINGW_HAS_SECURE_API=1 -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN32_WINNT=0x0601 -D_WIN64 -ID:\fictional-system\out\build\x64-Debug -ID:\fictional-system -ID:\fictional-system\out\build\x64-Debug\fict_autogen\include -external:I C:\Qt\6.1.3\mingw81_64\include\QtWidgets -external:I C:\Qt\6.1.3\mingw81_64\include -external:I C:\Qt\6.1.3\mingw81_64\include\QtCore -external:I C:\Qt\6.1.3\mingw81_64\mkspecs\win32-g++ -external:I C:\Qt\6.1.3\mingw81_64\include\QtGui -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MDd -Wno-error=invalid-offsetof -std:c++17 /showIncludes /FoCMakeFiles\fict.dir\fict_autogen\mocs_compilation.cpp.obj /FdCMakeFiles\fict.dir\ /FS -c D:\fictional-system\out\build\x64-Debug\fict_autogen\mocs_compilation.cpp
D:\fictional-system\out\build\x64-Debug\cl : командная строка error D8021: недопустимый числовой аргумент "/Wno-error=invalid-offsetof"
  ninja: build stopped: subcommand failed.


CMake:
cmake_minimum_required(VERSION 3.19)
project(FictionalSystem)
set(username $ENV{USERNAME})

#set(CMAKE_CXX_COMPILER "C:/Program Files/JetBrains/CLion 2021.3.3/bin/mingw/bin/g++.exe")

if (WIN32)
    if (username MATCHES "Вячеслав")
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(CMAKE_PREFIX_PATH "C:\\Qt\\6.1.3\\mingw81_64\\lib\\cmake")
    set(EXECUTABLE_OUTPUT_PATH "..\\..\\..\\release")
    endif (username MATCHES "Вячеслав")
    message("check")
else()
    set(CMAKE_PREFIX_PATH "~/Qt/6.1.3/mingw81_64/lib/cmake")
endif (WIN32)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt6Widgets REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Build and link
add_library (
    PICS 
    "src/pics/set/pics.h"
    "src/pics/set/lbp.h"
)

add_library (
    NET
    #"src/net/templates/algen.h"
    #"src/net/countmask.h"
    #"src/net/structure/prefim.h"
    #"src/net/templates/create_w.h"
)
add_library(
    LEARNING
    "src/learning/adaboost.h"
  #  "src/learning/countmask.h"
   # "src/learning/create_w.h"
)
add_library(
    STRUCT
    "src/struct/algen.h"
    "src/struct/prefim.h"
    "src/struct/shab.h"
    "src/struct/sigmoid.h"
)

add_library(
    SRC
    "src/learning.h"
    "src/net.h"
    "src/pics_get.h"
    "src/pics_set.h"
)
add_executable(fict main.cpp ${SRC})

target_link_libraries(fict Qt6::Widgets)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ariox41, 2022-03-18
@Ariox41

Line

set(CMAKE_PREFIX_PATH "C:\\Qt\\6.1.3\\mingw81_64\\lib\\cmake")

hints that you are trying to include binaries compiled with mingw into a project built with msvc. This won't work anyway, the ABIs are incompatible.
In this case, this can also be the cause of the error, since you include cmake configuration files that contain compiler flags that were listed as a public dependency when built. Flags from mingw are, of course, invalid for msvc.
Simply put, either install the version of Qt that matches your compiler, or install msys2 and use mingw + Qt from the packages (but there is no QWebEngine for mingw).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question