Does anyone have recommendations for C++ libraries that provide WebSocket support?
#asknostr
Does anyone have recommendations for C++ libraries that provide WebSocket support?
#asknostr
I’m using Qt for that. It’s a nice interface. Is that an option?
Looks like boost also has a library with a possibly better license.
I'll look into that as well.
I want something that can be used in FOSS software for Nostr.
Qt has a much cleaner interface.
I am working on a client in Qt right now. As long as you are dynamically linking, or open sourcing the entire thing, it’s legal.
Also, check out nlohmann’s json library (it’s epically good) and QuickType.io will generate c++ classes using his json library by just pasting in example Nostr events.
Happy hacking.
I've already set up the nlohmann JSON library. I'll dig into how to use Qt for the project.
Thanks for the recs!
No problem. I have a love/hate relationship with Qt. There are times it makes me want to pull my hair out, but there isn’t another library that does what it does, and some parts (like networking - which is a nightmare cross platform) are really, really good. Qt also has excellent concurrency/parallelism stuff in it.
Is Qt licensed for open-source use?
I was also looking at Poco, but that may be overkill since it's such a huge library.
It is usable under the GPL. You will have to dynamically link the library if you don’t plan on open sourcing the library.
I’d recommend Qt 6.5, as it’s the current LTS release.
You’ll have to dig a little to get the download page. Look for the “online installer” My internet is really flaky right now due to snow.
If you are on Linux I can point you to the packages you need.
I'm on Windows but building my project on WSL. Currently trying to figure out how to add the relevant Qt packages to my project. I guess I could just download the sources and build them. Is that the best way?
Are you using cmake?
Yep!
sudo apt install qt6-base-dev
That installs the core package?
Yes. Should support most basic functionality, and CMake will be able to find it since it is installed in the OS's standard library paths.
Are you wanting to use Qt Creator?
I believe the pkg name is just qtcreator all together like that.
Might use Qt Creator later, but I don't need it right now.
Ok. If you have any more issues let me know. I can throw a working CMakeLists.txt into a GitHub gist or something.
Thank you!
I ended up deciding to download and build a specific version of Qt. There was no Ubuntu package for the WebSocket library for the current Ubuntu LTS distro.
Let me tell you, Qt is a *fat* download/unzip. I think I'll be able to build it once and call it a day, though.
Ah. I keep forgetting how behind LTS Ubuntu is.
If you haven’t already, you might check out vcpkg when you have tinker time. Since switching to windows, I do all my Qt work on it natively, and I compile everything (deps) with vcpkg and use the toolchain file to allow cmake to find everything. Nlohmann, SQLite, and Qt 6.5 are all building natively that way on my machine.
It looks like:
vcpkg install qt:x64-windows
And it will compile it natively. Of course, on windows natively you could just use the installer, in which case vcpkg is still great for sekp256, nlohmann, and even boost.
The installer will work well in most cases, but using vcpkg (especially if you make a manifest file) makes it easy to do CI/CD later as well, since it works on all three platforms.
I'll keep that in the back pocket.
This is my first time trying to do a serious project in C++, and compared to Python or Node or .NET, C++ project management feels like the Wild West.
I'm learning on the fly.
That is awesome. You work in my two best languages. Maybe we can collaborate some time. I’m a C++/C# nerd. 🫂
I do C# in my day job, and wanted to learn C++ on the side.
DM me sometime, I'm working with a few folks on a fairly hefty project (that's what all this is about). We'd love to have another contributor, if you're interested.