Closed ghost closed 2 years ago
@acaiberii, you probably forget so set -std=c+11
. Also please see the note in README for more information regarding g++ compiler. https://github.com/yhirose/cpp-httplib#note
I'd like you to reopen this.
After upgrading to G++ 10.2.0 and specifying -std=c++11
(-std=c+11
doesnt work), I get a LOT of errors.
This also gives warnings and errors about my actual code in guilded.cpp
and guilded.h
.
I'd switch to libcpr if I could but I don't want to use Conan.
on Windows, you need to link windows sockets (e.g. -lws2_32
).
Hello @acaiberii, I am compiling on Windows 10 x64 with G++ 11.2.0 using these options:
1) Includes (in this order), I included openssl because I want to set some options, otherwise it's not needed, many others below httplib.h are specific to the needs of my program.
2) compiler CMD: g++ -I"C:\eclipse4c\include" -O3 -Wall -c -fmessage-length=0 -std=c++20 -MMD -MP -MF"src/microserver.d" -MT"src/microserver.o" -o "src/microserver.o" "../src/microserver.cpp"
Note: "C:\eclipse4c\include" contains openssl includes directory as well as my own .h files, only those.
3) Linker CMD: g++ -L"C:\eclipse4c\lib" -o "microserver" ./src/microserver.o -lodbc32 -lssl -lcrypto -lws2_32
Note: "C:\eclipse4c\lib" contais openssl libraries: libcrypto.a libcrypto.dll.a libssl.a libssl.dll.a
I use ODBC, otherwise, the -lodbc32 is not required.
It's very important to have the \bin folder of G++ in your system or user path. I use Eclipse CDT, if the path is not set then Eclipse won't work and a lot of errors will be generated, I also have to set the options shown above for compiler and linker.
The same source code compiles on Linux (Ubuntu 20.04) with almost identical commands, except for the linker, I don't have to link with -lws2_32 and the -pthreads is required for the linker on Linux. The path for openssl libs changes too.
Regards, Martin
@mcordova1967 Including OpenSSL from C:\openssl\include
in the INCLUDE environmental variable. The include includes the folders crypto
, openssl
and internal
which HTTPLib all uses.
Batch:
@echo off
g++ -I"C:\openssl\include" -O3 -Wall -c -fmessage-length=0 -std=c++20 -MMD -MP -MT"build/objects/guilded.o" -o "build/objects/guilded.o" "src/guilded.cpp"
ar rcs ./build/lib/libguilded.a ./build/objects/guilded.o
Running this batch file produced the same amount of errors, even more than the original command.
G++ in C:\msys64\mingw64\bin
linked in system path. No G++ bin\
folder.
@acaiberii : That's the /bin folder I am referring to. If you are using c++ 10.x you probably don't have support for -std=c++20, but that's not relevant as long as you use the minimum standard supported by httplib.
Maybe the first error messages printed by the compiler are the most important, try using -std=c++14 and also check the order of your includes, is httplib.h the first one? that caused me some trouble when I placed other includes above httplib.h, are you compiling a server or a client? because for a client I had to link with these: -lcrypto -lssl -lcrypt32 -lws2_32
All I can tell you at this point is that it does compile on Windows, even with Ming64 C++ 8.x, now I am using the latest, one, but it should compile with yours too. The error messages will lead to the solution, the first ones in particular, at least that has been my experience from recent days, I started this month using this terrific module and also had a lot of errors, but most were derived from paths, order of includes and libraries not found (the same on Linux), all solved now.
Good luck, Martin
streamable video url
As you can see, my project is completely unbuildable.
My code:
Using the WinBuilds distribution of the G++ compiler, making a library with AR.