Repository navigation
error: too few arguments to function 'int mbedtls_pk_parse_keyfile' #529
Copy link
Copy link
Closed
Description
Tools:
- Window 10 64-bit
- CMake 3.27
- MinGW-w64 GCC 11.2
- Mbed-TLS 3.6.1
Tested versions:
- IXWebSocket-11.4.5 (March 6, 2024)
- IXWebSocket-master
Full log:
cmake -G "MinGW Makefiles" --fresh -S . -B build -DCMAKE_INSTALL_PREFIX=E:/libs/IXWebSocket-11.4.5-prefix -DZLIB_LIBRARY=E:/lib/zlib-1.3.1-prefix/lib/libzlibstatic.a -DZLIB_INCLUDE_DIR=E:/libs/zlib-1.3.1-prefix/include -DMBEDTLS_LIBRARY=E:/libs/mbedtls-3.6.1-prefix/lib/libmbedtls.a -DMBEDTLS_INCLUDE_DIRS=E:/libs/mbedtls-3.6.1-prefix/include -DMBEDX509_LIBRARY=E:/libs/mbedtls-3.6.1-prefix/lib/libmbedx509.a -DMBEDCRYPTO_LIBRARY=E:/libs/mbedtls-3.6.1-prefix/lib/libmbedcrypto.a -DUSE_TLS=ON -DUSE_WS=ON
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Qt/Tools/mingw1120_64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Qt/Tools/mingw1120_64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- TLS configured to use mbedtls
-- Found MbedTLS: E:/libs/mbedtls-3.6.1-prefix/include
-- Found ZLIB: E:/lib/zlib-1.3.1-prefix/lib/libzlibstatic.a (found version "1.3.1")
-- Build spdlog: 1.8.0
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Build type: Release
-- Configuring done (12.6s)
-- Generating done (0.1s)
-- Build files have been written to: E:/libs/IXWebSocket-master/build
cmake --build build -j4
[ 2%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/spdlog.cpp.obj
[ 4%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/stdout_sinks.cpp.obj
[ 8%] [ 8%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/color_sinks.cpp.obj
Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXBench.cpp.obj
[ 10%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXCancellationRequest.cpp.obj
[ 12%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXConnectionState.cpp.obj
[ 14%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXDNSLookup.cpp.obj
[ 16%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXExponentialBackoff.cpp.obj
[ 18%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/file_sinks.cpp.obj
[ 20%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXGetFreePort.cpp.obj
[ 22%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/async.cpp.obj
[ 24%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXGzipCodec.cpp.obj
[ 26%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/cfg.cpp.obj
[ 28%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXHttp.cpp.obj
[ 30%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXHttpClient.cpp.obj
[ 32%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXHttpServer.cpp.obj
[ 34%] Building CXX object _deps/spdlog-build/CMakeFiles/spdlog.dir/src/fmt.cpp.obj
[ 36%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXNetSystem.cpp.obj
[ 38%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSelectInterrupt.cpp.obj
[ 40%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSelectInterruptFactory.cpp.obj
[ 42%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSelectInterruptPipe.cpp.obj
[ 44%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSelectInterruptEvent.cpp.obj
[ 46%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSetThreadName.cpp.obj
[ 48%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSocket.cpp.obj
[ 50%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSocketConnect.cpp.obj
[ 52%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSocketFactory.cpp.obj
[ 54%] Linking CXX static library libspdlog.a
[ 56%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSocketServer.cpp.obj
[ 58%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSocketTLSOptions.cpp.obj
[ 58%] Built target spdlog
[ 60%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXStrCaseCompare.cpp.obj
[ 62%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXUdpSocket.cpp.obj
[ 64%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXUrlParser.cpp.obj
[ 66%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXUuid.cpp.obj
[ 68%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXUserAgent.cpp.obj
[ 70%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocket.cpp.obj
[ 72%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketCloseConstants.cpp.obj
[ 74%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketHandshake.cpp.obj
[ 76%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketHttpHeaders.cpp.obj
[ 78%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketPerMessageDeflate.cpp.obj
[ 80%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp.obj
[ 82%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketPerMessageDeflateOptions.cpp.obj
[ 84%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketProxyServer.cpp.obj
[ 86%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketServer.cpp.obj
[ 88%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXWebSocketTransport.cpp.obj
[ 90%] Building CXX object CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSocketMbedTLS.cpp.obj
E:\libs\IXWebSocket-master\ixwebsocket\IXSocketMbedTLS.cpp: In member function 'bool ix::SocketMbedTLS::init(const string&, bool, std::string&)':
E:\libs\IXWebSocket-master\ixwebsocket\IXSocketMbedTLS.cpp:146:41: error: too few arguments to function 'int mbedtls_pk_parse_keyfile(mbedtls_pk_context*, const char*, const char*, int (*)(void*, unsigned char*, size_t), void*)'
146 | if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "") < 0)
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from E:/libs/mbedtls-3.6.1-prefix/include/mbedtls/ssl_ciphersuites.h:16,
from E:/libs/mbedtls-3.6.1-prefix/include/mbedtls/ssl.h:20,
from E:/libs/mbedtls-3.6.1-prefix/include/mbedtls/debug.h:15,
from E:\libs\IXWebSocket-master\ixwebsocket\IXSocketMbedTLS.h:13,
from E:\libs\IXWebSocket-master\ixwebsocket\IXSocketMbedTLS.cpp:12:
E:/libs/mbedtls-3.6.1-prefix/include/mbedtls/pk.h:1174:5: note: declared here
1174 | int mbedtls_pk_parse_keyfile(mbedtls_pk_context *ctx,
| ^~~~~~~~~~~~~~~~~~~~~~~~
mingw32-make.exe[2]: *** [CMakeFiles\ixwebsocket.dir\build.make:616: CMakeFiles/ixwebsocket.dir/ixwebsocket/IXSocketMbedTLS.cpp.obj] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:117: CMakeFiles/ixwebsocket.dir/all] Error 2
mingw32-make.exe: *** [Makefile:135: all] Error 2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
ivan-enzhaev commentedon Sep 15, 2024
I tried
IXWebSocket 11.4.5withMBed-TLS 2.28.9:ivan-enzhaev commentedon Sep 15, 2024
I try to ignore the error message above. I build a simple
hello, worldproject:CMakeLists.txt
ivan-enzhaev commentedon Sep 15, 2024
I think it is related to this error when I build
IXWebSocketswhere was failed to buildlibzlibstatic.a:ivan-enzhaev commentedon Sep 15, 2024
Building
IXWebSocket 11.4.5withMBed-TLS 2.28.9was solved. The path tolibzlibstatic.awas incorrect -libmust be changed tolibs:Output:
Output:
ivan-enzhaev commentedon Sep 15, 2024
The order of linking of libraries is very important. Now I have a view errors:
I tried to solve them by adding
libcrypto.alibrary from OpenSSL 1.1 folder but it didn't help:Added. the
crypt32library solved the problem! I have received a message from the Glitch.com and Render.com free Node.js hostings!P.S. So,
MBed-TLS v2.28.9must be used withIXWebSocket 11.4.5butMBed-TLS v3.x.xhave thembedtls_pk_parse_keyfilefunction that requires 5 arguments (not 3)ivan-enzhaev commentedon Sep 16, 2024
So, I had this error with the latest
IXWebSocket-11.4.5and the latestMbed-TLS 3.6.1: too few arguments to function 'int mbedtls_pk_parse_keyfile' I solved it by usingMBed-TLS v2.28.9instead ofMBed-TLS v3.x.x. I have triedMBed-TLS v3.0.0too butIXWebSocket-11.4.5has the same error. So, the number of arguments ofmbedtls_pk_parse_keyfilewas changed inMBed-TLS v3.0.0butIXWebSocket-11.4.5uses the old version ofMBed-TLS v2.x.x.Download
MBed-TLS 2.28.9like this:Set the installation path and configure it:
Build it:
Install it:
Install zlib with the same way. I use
zlib v1.3.1. Download and installIXWebSocket-11.4.5with the configuration:Use the following
CMakeLists.txtin your projects:If you use SDL3 for a window and OpenGL:
This is my step by step guide to install SDL3 on Windows but it can be useful for MacOS too if you need a window Setting up SDL3 for Windows using CMake and MinGW-w64 You can draw GUI using ImGUI and SDL3: Building ImGUI statically and setting up it to the CMake project
Server:
app.js
Client:
main.cpp
bsergean commentedon Sep 27, 2024
Nice, thanks for sharing.
There should be an mbedtls version detection blob somewhere, as the API changed in 3.xxx.
cf c27f5a9
ivan-enzhaev commentedon May 20, 2026
I tried to use the latest version of
IXWebSocket 12.0.0andmbedtls-4.1.0: #577ivan-enzhaev commentedon May 20, 2026
Hi @bsergean,
You are exactly right. The automated version detection didn't trip on my setup, but forcing the preprocessor definition during configuration resolved the build errors completely.
For anyone else using MinGW and Mbed TLS 3+ who runs into this compile error, you can fix it without modifying the source code by explicitly passing the macro flag to CMake:
-DCMAKE_CXX_FLAGS="-DIXWEBSOCKET_USE_MBED_TLS_MIN_VERSION_3"My full working configuration command ended up looking like this:
Building and installing:
Since the compilation issue is fully resolved on my end, I will go ahead and close this issue. Thanks for pointing me in the right direction regarding the API change!
P.S. Building and installing
Mbed TLS 3.6.6:ivan-enzhaev commentedon Jun 2, 2026
Example: https://github.com/ivan-enzhaev/ixwebsocket-opengl-sdl3-cpp
ixwebsocket-opengl-sdl3-cpp
A project template demonstrating how to integrate the
IXWebSocketlibrary with an SDL3 windowing context and an OpenGL 3.3 core profile renderer on Windows using MinGW 13.1 and CMake.📖 Full Tutorial
For complete step-by-step instructions, details on compiling dependencies (
MbedTLS,zlib), and a breakdown of the non-blocking network event loop thread, follow the full guide here:👉 Setting up IXWebSocket with SDL3 and OpenGL (MinGW)
Читать на русском: Настройка IXWebSocket с SDL3 и OpenGL (MinGW)
📁 Project Structure