-
Notifications
You must be signed in to change notification settings - Fork 567
Description
Compiling to WebAssembly on Ubuntu 24.04.3 following the instructions on the website, I get "fatal error: 'winsock2.h' file not found" from chrono/util/ChSocket.
The code contains this guard:
#if (defined(__linux__) || defined(__APPLE__))
#define UNIX
#endif
#include <string>
#include <iostream>
#include "chrono/core/ChApiCE.h"
#ifdef UNIX
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
#include <cerrno>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <iostream>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <cstdio>
#include <cstring>
#ifdef __APPLE__
// be sure to have TARGET_OS_MAC defined
#include "TargetConditionals.h"
#endif
#else
#include <winsock2.h>
#endif
The code says: If it's not Unix, it's Windows, which is not true for Emscripten.
Compiling latest commit 13b9c9f.
Compiling on Ubuntu 24.04.3 with Emscripten 4.0.19.
Expected Behavior
I expect the compilation to succeed and to get a working WASM version of the library.
Actual Behavior
The compilation does not succeed.
Steps to Reproduce
Probably just try to compile on Linux or Mac with Emscripten. Should fail. But i'm not ruling out user error.
Further Information, Files, and Links
This seems like a kind of an error that anyone compiling to WASM on non-Windows should've encountered, yet I see no mention of this anywhere. So my question is: Is this path used by anyone? Can someone verify that this will work?
My goal is to run a simulation only in WASM and visualize it with other tools outside of WASM. I simply need the core library (as far as I understand).
So how to fix? Do I say Emscripten is Unix or do I not include this at all? What would the socket be used for anyway?