-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: too few arguments to function 'int mbedtls_pk_parse_keyfile' #529
Comments
I tried
|
I try to ignore the error message above. I build a simple CMakeLists.txt cmake_minimum_required(VERSION 3.20)
project(background_color)
add_executable(app) # WIN32
target_include_directories(app PRIVATE E:/libs/glad-2.0.6/include)
target_include_directories(app PRIVATE E:/libs/IXWebSocket-11.4.5-prefix/include)
target_sources(app
PRIVATE
E:/libs/glad-2.0.6/src/glad.c
main.cpp
)
# This code copies the "SDL3.dll" file to the build directory
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:app> $<TARGET_FILE_DIR:app>
)
find_package(SDL3)
target_link_directories(app PRIVATE E:/libs/IXWebSocket-11.4.5-prefix/lib)
target_link_directories(app PRIVATE E:/libs/mbedtls-2.28.9-prefix/lib)
target_link_directories(app PRIVATE E:/libs/zlib-1.3.1-prefix/lib)
target_link_libraries(app PRIVATE zlibstatic ixwebsocket mbedcrypto mbedx509 ws2_32 mbedtls SDL3::SDL3)
target_compile_definitions(app PRIVATE SDL_MAIN_USE_CALLBACKS)
target_link_options(app PRIVATE -static-libgcc -static-libstdc++)
|
I think it is related to this error when I build
|
Building
Output:
Output:
|
The order of linking of libraries is very important. Now I have a view errors:
I tried to solve them by adding target_link_directories(app PRIVATE C:/Qt/Tools/OpenSSL-1.1.1j/Win_x64/bin/ssl_1.1/x86_64)
target_link_libraries(app PRIVATE ixwebsocket mbedx509 ws2_32 mbedtls mbedcrypto crypto zlibstatic wsock32 SDL3::SDL3) Added. the target_link_directories(app PRIVATE E:/libs/IXWebSocket-11.4.5-prefix/lib)
target_link_directories(app PRIVATE E:/libs/mbedtls-2.28.9-prefix/lib)
target_link_directories(app PRIVATE E:/libs/zlib-1.3.1-prefix/lib)
# https://github.com/msys2/MINGW-packages/issues/4821#issuecomment-521690294
target_link_libraries(app PRIVATE ixwebsocket mbedx509 ws2_32 mbedtls mbedcrypto crypt32 zlibstatic wsock32 SDL3::SDL3) P.S. So, |
So, I had this error with the latest Download
Set the installation path and configure it:
Build it:
Install it:
Install zlib with the same way. I use
Use the following # mkdir dist\win
# cd dist
# cmake -G "MinGW Makefiles" --fresh -S .. -B ..\dist\win
cmake_minimum_required(VERSION 3.20)
# cd win
# mingw32-make
project(ixwebsocket_example)
add_executable(app) # WIN32
target_include_directories(app PRIVATE E:/libs/IXWebSocket-11.4.5-prefix/include)
target_sources(app
PRIVATE
main.cpp
)
find_package(SDL3)
target_link_directories(app PRIVATE E:/libs/IXWebSocket-11.4.5-prefix/lib)
target_link_directories(app PRIVATE E:/libs/mbedtls-2.28.9-prefix/lib)
target_link_directories(app PRIVATE E:/libs/zlib-1.3.1-prefix/lib)
target_link_libraries(app PRIVATE ixwebsocket mbedx509 ws2_32 mbedtls mbedcrypto crypt32 zlibstatic wsock32)
target_link_options(app PRIVATE -static-libgcc -static-libstdc++) If you use SDL3 for a window and OpenGL: # mkdir dist\win
# cd dist
# cmake -G "MinGW Makefiles" --fresh -S .. -B ..\dist\win -DSDL3_DIR=E:\libs\sdl3-desktop-prefix\lib\cmake\SDL3
cmake_minimum_required(VERSION 3.20)
# cd win
# mingw32-make
cmake_minimum_required(VERSION 3.20)
project(ixwebsocket_example)
add_executable(app) # WIN32
target_include_directories(app PRIVATE E:/libs/glad-2.0.6/include)
target_include_directories(app PRIVATE E:/libs/IXWebSocket-11.4.5-prefix/include)
target_sources(app
PRIVATE
E:/libs/glad-2.0.6/src/glad.c
main.cpp
)
# This code copies the "SDL3.dll" file to the build directory
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:app> $<TARGET_FILE_DIR:app>
)
find_package(SDL3)
target_link_directories(app PRIVATE E:/libs/IXWebSocket-11.4.5-prefix/lib)
target_link_directories(app PRIVATE E:/libs/mbedtls-2.28.9-prefix/lib)
target_link_directories(app PRIVATE E:/libs/zlib-1.3.1-prefix/lib)
# https://github.com/msys2/MINGW-packages/issues/4821#issuecomment-521690294
target_link_libraries(app PRIVATE ixwebsocket mbedx509 ws2_32 mbedtls mbedcrypto crypt32 zlibstatic wsock32 SDL3::SDL3)
target_compile_definitions(app PRIVATE SDL_MAIN_USE_CALLBACKS)
target_link_options(app PRIVATE -static-libgcc -static-libstdc++) 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 const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', (ws) => {
console.log('Client connected');
ws.on('message', (message) => {
console.log('Received message:', message);
// Process the received message and send a response if needed
});
ws.on('close',
() => {
console.log('Client disconnected');
});
}); Client: main.cpp #include <SDL3/SDL.h>
#include <SDL3/SDL_main.h>
#include <glad/glad.h>
#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXWebSocket.h>
#include <ixwebsocket/IXUserAgent.h>
#include <iostream>
// Our websocket object
ix::WebSocket webSocket;
struct AppContext
{
SDL_Window *window;
SDL_GLContext glContext;
SDL_AppResult appQuit = SDL_APP_CONTINUE;
};
SDL_AppResult SDL_Fail()
{
SDL_LogError(SDL_LOG_CATEGORY_CUSTOM, "Error %s", SDL_GetError());
return SDL_APP_FAILURE;
}
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
{
// Init the library
if (!SDL_Init(SDL_INIT_VIDEO))
{
return SDL_Fail();
}
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); // Enable MULTISAMPLE
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2); // can be 2, 4, 8 or 16
// Create a window
SDL_Window *window = SDL_CreateWindow("SDL3, OpenGL 2.1, C++", 350, 350,
SDL_WINDOW_OPENGL); // | SDL_WINDOW_RESIZABLE
if (!window)
{
return SDL_Fail();
}
SDL_GLContext glContext = SDL_GL_CreateContext(window);
if (!glContext)
{
return SDL_Fail();
}
if (!gladLoadGL())
{
std::cout << "Failed to load OpenGL functions" << std::endl;
return SDL_APP_FAILURE;
}
glClearColor(0.2f, 0.3f, 0.5f, 1.f);
// Required on Windows
ix::initNetSystem();
// std::string url("wss://echo.websocket.org");
// std::string url("ws://localhost:3000");
// std::string url("wss://chat-sdl3-wasm-cpp.onrender.com");
std::string url("wss://testing-websockets-using-emscripten-sdl3-and-opengl-es-20.glitch.me");
webSocket.setUrl(url);
std::cout << "Connecting to " << url << "..." << std::endl;
// Setup a callback to be fired (in a background thread, watch out for race conditions !)
// when a message or an event (open, close, error) is received
webSocket.setOnMessageCallback([](const ix::WebSocketMessagePtr& msg)
{
if (msg->type == ix::WebSocketMessageType::Message)
{
std::cout << "received message: " << msg->str << std::endl;
std::cout << "> " << std::flush;
}
else if (msg->type == ix::WebSocketMessageType::Open)
{
std::cout << "Connection established" << std::endl;
std::cout << "> " << std::flush;
}
else if (msg->type == ix::WebSocketMessageType::Error)
{
// Maybe SSL is not configured properly
std::cout << "Connection error: " << msg->errorInfo.reason << std::endl;
// std::cout << "> " << std::flush;
}
}
);
// Now that our callback is setup, we can start our background thread and receive messages
webSocket.start();
// Send a message to the server (default to TEXT mode)
webSocket.send("hello world");
// Display a prompt
std::cout << "> " << std::flush;
std::string text;
// Read text from the console and send messages in text mode.
// Exit with Ctrl-D on Unix or Ctrl-Z on Windows.
// while (std::getline(std::cin, text))
// {
// webSocket.send(text);
// std::cout << "> " << std::flush;
// }
SDL_ShowWindow(window);
// Set up the application data
*appstate = new AppContext {
window,
glContext,
};
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
{
auto *app = (AppContext *)appstate;
switch (event->type)
{
case SDL_EVENT_QUIT:
{
app->appQuit = SDL_APP_SUCCESS;
break;
}
default:
{
break;
}
}
return SDL_APP_CONTINUE;
}
SDL_AppResult SDL_AppIterate(void *appstate)
{
auto *app = (AppContext *)appstate;
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(app->window);
return app->appQuit;
}
void SDL_AppQuit(void *appstate, SDL_AppResult result)
{
auto *app = (AppContext *)appstate;
if (app)
{
SDL_GL_DestroyContext(app->glContext);
SDL_DestroyWindow(app->window);
delete app;
}
SDL_Quit();
} |
Nice, thanks for sharing. There should be an mbedtls version detection blob somewhere, as the API changed in 3.xxx. cf c27f5a9 |
Tools:
Tested versions:
Full log:
The text was updated successfully, but these errors were encountered: