#Sending HTTP request using ASIO in c++

365 messages ยท Page 1 of 1 (latest)

quaint kestrel
#

TITLE

grizzled eagleBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

bronze relic
#

it'll be easier to help if you tell us what your question or issue is

quaint kestrel
#

There is no issue, I simply lack some knowledge. I was under the impression that the tittle was self explanatory. However, I will take the liberty to redefine my thread's context. I want to send a HTTP request using the library ASIO in C++. I want to be able to send HTTP/HTTPS request with more than one method (get, post, put, delete, etc...) and with a body and headers.

#

@bronze relic

pure elbow
#

asio is primarily concerned with sockets, if you don't want to invent HTTP from scratch, boost.beast uses ASIO and has HTTP client code you can use

quaint kestrel
pure elbow
#

oof ๐Ÿ˜›

#

use vcpkg or something to install boost

#

or use your favorite system package manager

quaint kestrel
bronze relic
quaint kestrel
bronze relic
quaint kestrel
#

but I am still super confused

bronze relic
#

you can try something like "how to install boost.beast on windows"

pure elbow
#

what compiler/build system/IDE are you using might also make a difference

bronze relic
quaint kestrel
#

on windows 10

pure elbow
#

alright, then you have a package manager already (msys2's pacman)

#

which should be able to install the entire precompiled boost library suite

quaint kestrel
#

I just installed the raw zip

pure elbow
#

what

pure elbow
#

that's not msys2 then thonk

quaint kestrel
pure elbow
#

you can then also search for boost pacman -Ss boost and install it as well

quaint kestrel
pure elbow
#

but if you don't have msys2 then you don't have a package manager

#

so that doesn't help you

quaint kestrel
#

I have msys2

#
$ pacman -Ss boost
clangarm64/mingw-w64-clang-aarch64-boost 1.84.0-1
    Free peer-reviewed portable C++ source libraries (mingw-w64)
mingw32/mingw-w64-i686-boost 1.84.0-1
    Free peer-reviewed portable C++ source libraries (mingw-w64)
mingw64/mingw-w64-x86_64-boost 1.84.0-1
    Free peer-reviewed portable C++ source libraries (mingw-w64)
ucrt64/mingw-w64-ucrt-x86_64-boost 1.84.0-1
    Free peer-reviewed portable C++ source libraries (mingw-w64)
clang32/mingw-w64-clang-i686-boost 1.84.0-1
    Free peer-reviewed portable C++ source libraries (mingw-w64)
clang64/mingw-w64-clang-x86_64-boost 1.84.0-1
    Free peer-reviewed portable C++ source libraries (mingw-w64)
pure elbow
#

no idea how you installed it then but w/e

#

pick the same prefix as you did for your GCC

#

probably the ucrt64 or mingw64 one

quaint kestrel
#

how do I install it

pure elbow
#

pacman -S <name>

quaint kestrel
#

like pacman install mingw-w64-ucrt-x86_64-boost?

quaint kestrel
#

@pure elbow

pure elbow
#

?

quaint kestrel
#

im not sure tho

#

and I am not sure how to include it

pure elbow
#

#includes should just work, since it was installed to ucrt64/include where your ucrt64/bin/g++ will already look

#

you may need to link some libraries to get it to link, but headers should be found without doing anything else

quaint kestrel
#
PS C:\coding-projects\CPP-Dev\SQS> g++ src/entry_file.cpp src/snbp.cpp -o build/SQS-Alpha-Build-0060 -lws2_32 -lcrypto -lssl
src/entry_file.cpp:11:10: fatal error: boost/http_client.hpp: No such file or directory
   11 | #include <boost/http_client.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
PS C:\coding-projects\CPP-Dev\SQS> ```
pure elbow
#

which g++ is this?

quaint kestrel
#

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     g++.exe                                            0.0.0.0    C:\msys64\ucrt64\bin\g++.exe


PS C:\coding-projects\CPP-Dev\SQS> ```
#
PS C:\coding-projects\CPP-Dev\SQS> g++ --version
g++.exe (Rev3, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

PS C:\coding-projects\CPP-Dev\SQS> 
pure elbow
#

where did you get boost/http_client.hpp from

quaint kestrel
#

idk

#

I thought thats how you incude it

pure elbow
#

look at the example that shows you how to use the library ๐Ÿ˜›

quaint kestrel
#

can you just please tell me the prefix

pure elbow
#

there's a whole example you can copy paste

quaint kestrel
#

welp im a dum dum

untold wraith
#

are you using Windows Subsystem for Linux (WSL)?

untold wraith
#

THEN HOW THE FUCK DID YOU INSTALL A PACKAGE WITH PACMAN WHEN YOU'RE ON WINDOWS

pure elbow
#

msys2 installs a little linux-like environment with pacman, bash, etc.

quaint kestrel
#

@pure elbow

#

'_snwprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW' was not declared in this scope

#
PS C:\coding-projects\CPP-Dev\SQS> g++ src/entry_file.cpp src/snbp.cpp -o build/SQS-Alpha-Build-0061 -lws2_32 -lcrypto -lssl -std=c++20
In file included from C:/coding-projects/CPP-Dev/bassil/src/headers/SNBP.h:16,
                 from src/snbp.hpp:22,
                 from src/entry_file.cpp:13:
C:/msys64/ucrt64/include/boost/asio/detail/impl/win_static_mutex.ipp: In member function 'int boost::asio::detail::win_static_mutex::do_init()':
C:/msys64/ucrt64/include/boost/asio/detail/impl/win_static_mutex.ipp:48: error: '_snwprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW' was not declared in this scope
   48 |   _snwprintf(
      |
C:/msys64/ucrt64/include/boost/static_string/static_string.hpp: In function 'boost::static_strings::static_wstring<N> boost::static_strings::detail::to_static_wstring_float_impl(double)':
C:/msys64/ucrt64/include/boost/static_string/static_string.hpp:660: error: 'swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW' is not a member of 'std'
  660 |     std::swprintf(buffer, N + 1, L"%f", value);
      |
C:/msys64/ucrt64/include/boost/static_string/static_string.hpp:672: error: 'swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW' is not a member of 'std'
  672 |     std::swprintf(buffer, N + 1, L"%.*e", precision, value);
      |
C:/msys64/ucrt64/include/boost/static_string/static_string.hpp: In function 'boost::static_strings::static_wstring<N> boost::static_strings::detail::to_static_wstring_float_impl(long double)':
C:/msys64/ucrt64/include/boost/static_string/static_string.hpp:697: error: 'swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW' is not a member of 'std'
  697 |     std::swprintf(buffer, N + 1, L"%Lf", value);
      |
C:/msys64/ucrt64/include/boost/static_string/static_string.hpp:709: error: 'swprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW' is not a member of 'std'
  709 |     std::swprintf(buffer, N + 1, L"%.*Le", precision, value);
      |
PS C:\coding-projects\CPP-Dev\SQS>
pure elbow
quaint kestrel
pure elbow
#

๐Ÿคท

quaint kestrel
#

๐Ÿ˜ฆ

pure elbow
#

I'm at work and I don't know how to fix it

#

you'd have to read the code that is blowing up and figure out why

#

and then find out how to convince it not to

#

it looks like the code is calling _snwprintf and the standard library is being funny and doing something like

#define _snwprintf(...) _snwprintf_instead_use_StringCbPrintfW_or_StringCchPrintfW()

to let you know this function is crappy and you should use another one

#

find out where it's doing that and see if that crap is guarded by some #ifdefs

#

see if you can define something to make it not do this

quaint kestrel
#

BUT I FIXED IT

pure elbow
#

๐ŸŽ‰

quaint kestrel
#

I needed to change a file from the boost lib and replace _snwprintf with StringCbPrintfW

pure elbow
#

well, that's not what I would have done, since now the code will only work on your machine with the modified file, but it works for now yamikek

quaint kestrel
#

*sent

pure elbow
quaint kestrel
pure elbow
#

you just said it worked thonk

quaint kestrel
#

it showed a response

#

but a response from cloudflare saying it could not understand the request

pure elbow
#

lul

#

doesn't matter, you did HTTP yamikek

quaint kestrel
pure elbow
#

well what kind of request did you try sending

#

e.g. https://httpbin.org/get

#

send a get request, get back a json payload with info about your request

quaint kestrel
#

@pure elbow

#

Hey there

#

im trying to get a window to work with like text display and text entry

#

I dont know of any simple lib to do that

bronze relic
#

Qt has both UI and networking utilities

quaint kestrel
bronze relic
#

no but you can find plenty of tutorials online

quaint kestrel
#

could you? @pure elbow

bronze relic
#

you should at least try a bit by yourself

quaint kestrel
#

it took you guys 1 hour

bronze relic
#

How do you think we learned ^^

#

you don't have to wait a whole week before asking for help if you get stuck but you should at least try

quaint kestrel
#

Well I need to run the QT installer and I cant

#

because it requires Sudo Perms

pure elbow
#

installer? sudo?

quaint kestrel
pure elbow
#

you can install qt libs from msys2's package manager

quaint kestrel
pure elbow
#

if you search for qt6 with pacman -Ss qt6 you should find stuff

#

qt6-base and qt6-tools are probably the minimum you need

quaint kestrel
#

Which one of these do I install?

pure elbow
#

as before, pick the same "prefix" as your gcc toolchain

#

so ucrt64 IIRC

quaint kestrel
pure elbow
#

I mean this bit at the start: clangarm64/

#

IIRC you have the ucrt64/mingw-w64-ucrt64-x86_64-gcc

#

so you use that same prefix for all the libs and tools you install

quaint kestrel
#

ucrt64/mingw-w64-ucrt-x86_64-qt6-5compat 6.6.1-1 (mingw-w64-ucrt-x86_64-qt6)

#

so thisone?

pure elbow
#

if you don't mind downloading a little extra, sure, that should include everything you could possibly need ๐Ÿ˜„

pure elbow
#

now read the qt docs for getting started with cmake

quaint kestrel
#

im not using Cmake

pure elbow
#

RIP

quaint kestrel
pure elbow
#

I guess for basic stuff you won't need the MOC

quaint kestrel
#

so how do I include it and stuff

pure elbow
#

just read about some widgets on the qt docs you need

#

buttons, text input, etc.

#

but you may need to figure out some include paths to tell the compiler yourself

#

because Qt is a rather large library that really kinda needs an actual build system to use

quaint kestrel
#

well its not finding QApplication

pure elbow
#

you might have to search around in <msys2 install dir>/ucrt64/include and see where the Qt headers are at

quaint kestrel
#

I found this dir C:\msys64\ucrt64\include\qt6

#

but I cant find anything in that dir called QApplication

#

maybe its in a sub folder

pure elbow
#

just search for a file called QApplication

#

there shouldn't be that many ๐Ÿ˜„

#

once you have that you'll probably also have to link some qt libs

#

the widget one at least

quaint kestrel
#

yeah

#

its giving a internal lib error

#
PS C:\coding-projects\CPP-Dev\SQS\src> g++ -o terminal_emulator GUI.cpp
In file included from C:/msys64/ucrt64/include/qt6/QtWidgets/QApplication:1,
                 from GUI.cpp:2:
C:/msys64/ucrt64/include/qt6/QtWidgets/qapplication.h:7:10: fatal error: QtWidgets/qtwidgetsglobal.h: No such file or directory
    7 | #include <QtWidgets/qtwidgetsglobal.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
PS C:\coding-projects\CPP-Dev\SQS\src> 
pure elbow
#

you need to add the include path with -I include/qt6

#

so that those headers can include other headers as <QtWidgets/whatever>

quaint kestrel
#
PS C:\coding-projects\CPP-Dev\SQS\src> g++ -o terminal_emulator GUI.cpp -I include/qt6
In file included from C:/msys64/ucrt64/include/qt6/QtWidgets/QApplication:1,
                 from GUI.cpp:2:
C:/msys64/ucrt64/include/qt6/QtWidgets/qapplication.h:7:10: fatal error: QtWidgets/qtwidgetsglobal.h: No such file or directory
    7 | #include <QtWidgets/qtwidgetsglobal.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
PS C:\coding-projects\CPP-Dev\SQS\src> g++ -o terminal_emulator GUI.cpp -Iinclude/qt6
In file included from C:/msys64/ucrt64/include/qt6/QtWidgets/QApplication:1,
                 from GUI.cpp:2:
C:/msys64/ucrt64/include/qt6/QtWidgets/qapplication.h:7:10: fatal error: QtWidgets/qtwidgetsglobal.h: No such file or directory
    7 | #include <QtWidgets/qtwidgetsglobal.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated
pure elbow
#

there may be other include directories you need ๐Ÿคท

#

find where the file it wants is

quaint kestrel
#

I found where it is

#

now what

pure elbow
#

add more include paths with -I

quaint kestrel
#

I am still a bit confused

pure elbow
#

If the #include that's failing specifies <foo/bar.h>, and it's located at whatever/idk/foo/bar.h
Then you need to add -Iwhatever/idk

quaint kestrel
#
#include <qt6/QtWidgets/QApplication>
#include <qt6/QtWidgets/QPushButton>
#include <qt6/QtWidgets/QWidget>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget window;
    window.setWindowTitle("Qt6 Simple Window");
    window.setGeometry(100, 100, 300, 200); 

    QPushButton button("Click Me", &window);
    button.setGeometry(100, 80, 100, 30); 


    window.show();

    return app.exec();
}
#

PS C:\coding-projects\CPP-Dev\jsh\src> g++ -o terminal_emulator GUI.cpp -lC:/msys64/ucrt64/include
In file included from C:/msys64/ucrt64/include/qt6/QtWidgets/QApplication:1,
from GUI.cpp:2:
irectory
7 | #include <QtWidgets/qtwidgetsglobal.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated

#

it is saying that it cant find a file within the lib

#

@pure elbow

pure elbow
#

yes, read again what I wrote

#

the lib requires you to make #include <QtWidgets/qtwidgetsglobal.h> work

#

you made #include <qt6/QtWidgets/QWidget> work

#

not the same thing

quaint kestrel
#

do I include with i or I and do I put a space between the flag and the path or not? @pure elbow

pure elbow
#

-Idir

quaint kestrel
pure elbow
#

so where is this QtGui/qtguiglobal.h

quaint kestrel
#

in C:\msys64\ucrt64\include\qt6

pure elbow
#

then you need to tell your compiler to look there

quaint kestrel
pure elbow
#

you resolved the compiler errors

#

now you have linker errors

#

because you need to link some qt libs I imagine

quaint kestrel
#

damm

#

which ones?

pure elbow
#

the one that has the definitions for the stuff you want to use

#

you're using QApplication or something

#

as you can see here, it's part of the widgets library

#

because you choose to do this all manually, now you have to find out what that library is called exactly on your system

#

maybe qt6-widgets

quaint kestrel
#

Amazing now I have 20 pages of docs and no clue how to make a window

pure elbow
#

idk

quaint kestrel
#

It has a lot of libs

pure elbow
#

and you may need lots of them

#

but you will definitely need the widget one

quaint kestrel
#

C:\msys64\ucrt64\lib\libQt6Widgets.dll.a

#

that is the widgets one

#

how does one link it

pure elbow
#

-lQt6Widgets.dll should work I think

#

maybe the .dll is unnecessary

quaint kestrel
#

it wants ``__imp__Z9qt_assertPKcS0_i'`

#

I tried to link Qt6Widgets but it didnt do anything

pure elbow
#

this assert thing is probably in some other qt library shared by many of them

quaint kestrel
#

but which one do I link?

#

do I link all of them and hope for the best?

pure elbow
#

it's declared here in qtbase

#

so probably in that library

pure elbow
#

you could also try asking pkg-config for linker flags

quaint kestrel
pure elbow
#

I don't see an Ax

quaint kestrel
#

Well I cant find a Qt6Base.dll

#

these are the only QT lib files I could find with b

pure elbow
#

you can ask pacman what files it installed for a given package,
like pacman -Ql mingw-w64-ucrt-x86_64-qt6-base

#

then check or grep for the libs

quaint kestrel
#

what

pure elbow
#

the package includes a Qt6Core.dll

#

that's probably it

quaint kestrel
#

I tried to link it

#

EXACT same error

pure elbow
#

the order matters, too

quaint kestrel
#

AHHH

pure elbow
#

if Qt6Widgets uses Qt6Core you need to link them in that order

quaint kestrel
#

g++ -o terminal_emulator GUI.cpp -IC:\msys64\ucrt64\include\ -IC:\msys64\ucrt64\include\qt6 -LQt6Core -LQt6Widgets -LQt6Assert This is the command im using

pure elbow
#

I think it should be a lowercase -l

#

uppercase is for linker search paths, IIRC

quaint kestrel
#

IT COMPILED

#

MOTHER FUCKER

#

this took me a god damm week

#

I hate myself

pure elbow
#

don't celebrate too early yamikek

quaint kestrel
#

I hate myself

#

I hate myself

pure elbow
#

if you try to run it now it will probably complain about missing DLLs, unless you put that whole ucrt64/bin folder on PATH

quaint kestrel
#

nope

#

it work

pure elbow
#

just be aware if you want anyone else to be able to run it, they need a bunch of those .dll files

#

and technically there's additional qt plugin DLLs you might also need that need to be in specific places and other files...

#

there's a windeployqt program that can copy all that stuff for you

quaint kestrel
#

hmm

#

I just want a window

#

but last issue

#

I am getting Errors within VSC

#

its saying random error everywhere but it works

pure elbow
#

it might not know anything about your mingw installation

#

so it might not know where to find any headers

#

and it certainly doesn't know about the include paths you told the compiler about

quaint kestrel
#

so if I send the EXE to someone it will not work?

pure elbow
#

yup

#

not unless they install msys2 and install the ucrt64 qt stuff and add it to PATH

quaint kestrel
#

whyyyy.s;s,dglomiejhadxb

pure elbow
#

or you give them a nice zip with all the required stuff

quaint kestrel
#

I regret learning C++

#

I like the backend stuff

#

but I dont waant to deal with this shit

#

Maybe in the future but I think its not for me. I will continue working on the back end stuff and completely ignore the QT stuff

#

I will work on the project just not the QT stuff I dont like it

#

lol

bronze relic
# quaint kestrel I regret learning C++

Including library in CPP has a steep learning curve, it's definitely not easy. But to be fair you seem to be trying to brute force it without actually learning or understanding what's going on so that's obviously going to make it much harder

quaint kestrel
#

Yeah

#

I want to use CMake it make my life better

#

however I know im stupid, and I know how much extra effort its going to take to set it up and learn it and change my stuff

#

I am 13 right now. I have been doing a lot on C++ working with the stack, memory management, a bit of network stuff and more but I think I just wanna do more of that for now

#

@pure elbow

quaint kestrel
#

@pure elbow

#

I am having another weird issue

#

I am trying to compile my project and after doing some googling I think I found the issue

#

but I cant find a solution

#

the error is 'StringCbPrintfW' was not declared in scope

pure elbow
#

(why in gods name are you using that notlikethis )

quaint kestrel
#

I already have strsafe.h included

quaint kestrel
pure elbow
quaint kestrel
#

These are good docs (I bookmarked them) but it seems like it has no mention of fixing This error

quaint kestrel
pure elbow
#

"fixed"

quaint kestrel
#

lol

#

But yeah im not sure how to approach this one. I found a few cases of this online (Sadly not related to boost, but still helpful) and they said to include strsafe.h which im already doing and not defining some NO_USE_StringCbPrintfW

#

The error also mentions that its later defined in the translation unit

pure elbow
#

start with the very first error

quaint kestrel
#
PS C:\coding-projects\CPP-Dev\jsh> g++ src/entry_file.cpp src/snbp.cpp -o build/SQS-Alpha-Build-0063 -lws2_32 -lcrypto -lssl -std=c++20 -DSTRSAFE_NO_DEPRECATE
In file included from C:/msys64/ucrt64/include/boost/asio/detail/win_event.hpp:25,
                 from C:/msys64/ucrt64/include/boost/asio/detail/event.hpp:23,
                 from C:/msys64/ucrt64/include/boost/asio/execution/blocking_adaptation.hpp:19,
                 from C:/msys64/ucrt64/include/boost/asio/execution.hpp:22,
                 from C:/msys64/ucrt64/include/boost/asio/system_executor.hpp:20,
                 from C:/msys64/ucrt64/include/boost/asio/associated_executor.hpp:24,
                 from C:/msys64/ucrt64/include/boost/beast/core/detail/bind_handler.hpp:17,
                 from C:/msys64/ucrt64/include/boost/beast/core/bind_handler.hpp:14,
                 from C:/msys64/ucrt64/include/boost/beast/core/async_base.hpp:14,
                 from C:/msys64/ucrt64/include/boost/beast/core.hpp:15,
                 from src/entry_file.cpp:12:
C:/msys64/ucrt64/include/boost/asio/detail/socket_types.hpp:24:2: error: #error WinSock.h has already been included
   24 | #error WinSock.h has already been included
      |  ^~~~~
In file included from C:/msys64/ucrt64/include/boost/asio/detail/socket_types.hpp:33:
C:/msys64/ucrt64/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
   15 | #warning Please include winsock2.h before windows.h
pure elbow
#

lets see your includes in src/entry_file.cpp

quaint kestrel
#
#include "snbp.hpp"

#include <iostream>
#include <string>
#include <unordered_map>
#include <functional>
#include <vector>
#include <filesystem>
#include <cstdlib>

#include <boost/algorithm/string.hpp>
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/version.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>
pure elbow
#

maybe you've included windows.h and broken winsock that way

#

and snbp.hpp's includes?

quaint kestrel
#
#include <algorithm>
#include <stdexcept>
#include <fstream>
#include <limits>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <sstream>
#include <iomanip>
#include <string_view>
#include <regex>

#include <strsafe.h>
#include <io.h>
#include <fcntl.h>
#include <wbemidl.h>
#include <shlobj.h>
#include <comdef.h>

and

#include <algorithm>
#include <stdexcept>
#include <fstream>
#include <limits>
#include <iostream>
#include <string>
#include <vector>
#include <memory>
#include <sstream>
#include <iomanip>
#include <string_view>
#include <regex>

#include <strsafe.h>
#include <io.h>
#include <fcntl.h>
#include <wbemidl.h>
#include <shlobj.h>
#include <comdef.h>
pure elbow
#

yuup

#

bunch of windows includes

#

that'll screw your shit up

quaint kestrel
#

ok

#

so what are the windows includes im looking at

pure elbow
#

either move those after the boost stuff somehow, or see if you can avoid them in your header

#

#include <strsafe.h>
#include <io.h>
#include <fcntl.h>
#include <wbemidl.h>
#include <shlobj.h>
#include <comdef.h>

all of these

quaint kestrel
#

ok

pure elbow
#

unfortunately the windows sdk can be quite prickly when it comes to what order things are included in

quaint kestrel
#
PS C:\coding-projects\CPP-Dev\jsh> g++ src/entry_file.cpp src/snbp.cpp -o build/SQS-Alpha-Build-0063 -lws2_32 -lcrypto -lssl -std=c++20 -DSTRSAFE_NO_DEPRECATE
In file included from C:/msys64/ucrt64/include/boost/asio/detail/win_event.hpp:25,
                 from C:/msys64/ucrt64/include/boost/asio/detail/event.hpp:23,
                 from C:/msys64/ucrt64/include/boost/asio/execution/blocking_adaptation.hpp:19,
                 from C:/msys64/ucrt64/include/boost/asio/execution.hpp:22,
                 from C:/msys64/ucrt64/include/boost/asio/system_executor.hpp:20,
                 from C:/msys64/ucrt64/include/boost/asio/associated_executor.hpp:24,
                 from C:/msys64/ucrt64/include/boost/beast/core/detail/bind_handler.hpp:17,
                 from C:/msys64/ucrt64/include/boost/beast/core/bind_handler.hpp:14,
                 from C:/msys64/ucrt64/include/boost/beast/core/async_base.hpp:14,
                 from C:/msys64/ucrt64/include/boost/beast/core.hpp:15,
                 from src/entry_file.cpp:12:
C:/msys64/ucrt64/include/boost/asio/detail/socket_types.hpp:24:2: error: #error WinSock.h has already been included
   24 | #error WinSock.h has already been included
      |  ^~~~~
In file included from C:/msys64/ucrt64/include/boost/asio/detail/socket_types.hpp:33:
C:/msys64/ucrt64/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
   15 | #warning Please include winsock2.h before windows.h
      |  ^~~~~~~
PS C:\coding-projects\CPP-Dev\jsh> g++ src/entry_file.cpp src/snbp.cpp -o build/SQS-Alpha-Build-0063 -lws2_32 -lcrypto -lssl -std=c++20 -DSTRSAFE_NO_DEPRECATE
In file included from C:/msys64/ucrt64/include/boost/asio/detail/win_event.hpp:25,
                 from C:/msys64/ucrt64/include/boost/asio/detail/event.hpp:23,
                 from C:/msys64/ucrt64/include/boost/asio/execution/blocking_adaptation.hpp:19,
                 from C:/msys64/ucrt64/include/boost/asio/execution.hpp:22,
                 from C:/msys64/ucrt64/include/boost/asio/system_executor.hpp:20,
                 from C:/msys64/ucrt64/include/boost/asio/associated_executor.hpp:24,
                 from C:/msys64/ucrt64/include/boost/beast/core/detail/bind_handler.hpp:17,
                 from C:/msys64/ucrt64/include/boost/beast/core/bind_handler.hpp:14,
                 from C:/msys64/ucrt64/include/boost/beast/core/async_base.hpp:14,
                 from C:/msys64/ucrt64/include/boost/beast/core.hpp:15,
                 from src/entry_file.cpp:12:
C:/msys64/ucrt64/include/boost/asio/detail/socket_types.hpp:24:2: error: #error WinSock.h has already been included
   24 | #error WinSock.h has already been included
      |  ^~~~~
In file included from C:/msys64/ucrt64/include/boost/asio/detail/socket_types.hpp:33:
C:/msys64/ucrt64/include/winsock2.h:15:2: warning: #warning Please include winsock2.h before windows.h [-Wcpp]
   15 | #warning Please include winsock2.h before windows.h
      |  ^~~~~~~
pure elbow
#

how did you change your #includes now

quaint kestrel
#

snbp is last

pure elbow
#
#include <boost/algorithm/string.hpp>
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/version.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>

#include <strsafe.h>
#include <io.h>
#include <fcntl.h>
#include <wbemidl.h>
#include <shlobj.h>
#include <comdef.h>

int main() {

}

works on my machine ๐Ÿคท

quaint kestrel
#

and that means all the Windows includes should come later

#

hmm

#

Im using G++ with C++ 20

pure elbow
#

same here

quaint kestrel
#

maybe filesystem or cstdlib includes windows

pure elbow
#

it works for me and I'm using the same msys2 ucrt64 g++, boost, etc.

quaint kestrel
#

then why oh why is it not workingange

pure elbow
#

maybe you lied and forgot some includes ๐Ÿ˜›

quaint kestrel
#

should I add the -Wcpp compiler flag?

#
#include <iostream>
#include <string>
#include <unordered_map>
#include <functional>
#include <vector>
#include <filesystem>
#include <cstdlib>

#include <boost/algorithm/string.hpp>
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/version.hpp>
#include <boost/asio/connect.hpp>
#include <boost/asio/ip/tcp.hpp>

#include "snbp.hpp"
#

this is all in the entry

#

I think I know why its doing this

pure elbow
quaint kestrel
#

I am including snbp.hh later

pure elbow
quaint kestrel
#

but I compile it like this g++ ./entry_file.cpp ./snbp.cpp <some random compiler flags>

#

and snbp.cpp contains the windows includes too

pure elbow
#

each .cpp file is compiled separately

quaint kestrel
#

flip

pure elbow
#

if the error is reported from entry_file.cpp, it's in there

#

do note that I didn't edit any boost headers manually yamikek

quaint kestrel
#

this is quite frustrating

pure elbow
#

did you add strsafe includes there?

quaint kestrel
#

in where?

pure elbow
#

in boost

quaint kestrel
#

no

#

I didnt modifty boost much

pure elbow
#

I didn't need to modify boost at all, and so far it works for me ๐Ÿ˜›

quaint kestrel
#

WHY THE F-

#

I spent most of my time working in ASM and ASM was esier than this

#

All I have is STD includes then BOOST and after that SNBP

#

so that does not make sense

pure elbow
#

๐Ÿคท

quaint kestrel
pure elbow
#

If you can put your project on github I can try to repro the problem here, idk

#

reinstall boost to undo your modifications and see if that helps? yamikek

quaint kestrel
#

how do I reinstall boost?

pure elbow
#

run pacman -S mingw-w64-ucrt-x86_64-boost again

quaint kestrel
#

it says target not found

#

never mind

#

I ran it in msy2s msys instead of msys2 mingw64

pure elbow
#

?

#

it shouldn't matter, pacman is the same no matter which shell you run

quaint kestrel
#

well once says target not found

#

the other works

pure elbow
#

works on my machine

quaint kestrel
#

and now it works!!!

quaint kestrel
pure elbow
#

today's lesson: avoid modifying external libs' headers yamikek

pure elbow
#

uhh idk

quaint kestrel
grizzled eagleBOT
#

This question is being automatically marked as stale.
If your question has been answered, type !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.

chilly ermine
#

@quaint kestrel if you learn the basics of cmake its gonna make ur life way easier