mattgodbolt / seasocks

Simple, small, C++ embeddable webserver with WebSockets support
BSD 2-Clause "Simplified" License
724 stars 120 forks source link

Use Seasocks with makefile #183

Open toutriste opened 1 year ago

toutriste commented 1 year ago

Hello.

Any help on how I can integrate this into my project that uses Makefiles? Ive tried searching but I can only find CMake stuff..

mattgodbolt commented 1 year ago

Hi there! Seasocks is built using CMake, but you don't have to use it that way. You can build it using CMake and then just include the headers in your project. Or use a version of Seasocks from conan ( https://conan.io/center/seasocks ).

How are you currently using third party libraries in your makefile? And what platform are you on? Maybe we can build a few versions of seasocks as part of the release we do.

toutriste commented 1 year ago

Hi, thanks for answering!

I'm developing on Linux, and this is how I'm currently linking seasocks and others:

LIBRARIES   = -L/home/user/seasocks/build/src/main/c/ -lseasocks -lconfig++
INCLUDEFLAG = -I$(INCLUDE) -I/home/user/seasocks/src/main/c/
..

The problem is that I'm hardcoding seasocks library path, I wanted something easier to compile, so the user does not need to build first seasocks and then my project.

mattgodbolt commented 1 year ago

There's no easy solution for this more generally I'm afraid. The ecosystem for C++ is not well set up for this. You can try one of these things, though none are that appealing:

toutriste commented 1 year ago

I see D: But this makes me curious, how other libraries do it? e.g I'm using -lconfig++ and I just installed libconfig 1.7.3-1 package... And it works.. Not sure if that would be possible with seasocks.. Lets say installing the package, it builds the library (locally), it stores somewhere in /usr/lib and then it would be easier to use I guess.. ?

madebr commented 1 year ago

You can parameterize the location of seasocks:

SEASOCKS_ROOT=/usr
SEASOCKS_LIBRARIES=-L$(SEASOCKS_ROOT)/lib -lseasocks -lconfig++
SEASOCKS_INCLUDEFLAGS=-I$(SEASOCKS_ROOT)/include

You can then call your makefile with arguments:

$ make SEASOCKS_ROOT=/path/to/your/seasocks/installation
mattgodbolt commented 1 year ago

I see D: But this makes me curious, how other libraries do it? e.g I'm using -lconfig++ and I just installed libconfig 1.7.3-1 package... And it works.. Not sure if that would be possible with seasocks.. Lets say installing the package, it builds the library (locally), it stores somewhere in /usr/lib and then it would be easier to use I guess.. ?

If you don't mind forcing your users to globally install seasocks as a library as root (which is not something I particularly like) you can ask them to download seasocks, and then install it in /usr/lib or /usr/include. Or we can make packages for Arch, Ubuntu, debian...all the various UNIX OSes... and then folks can apt install it (or whatever). But it'll be tied to that specific OS's default C++ compiler (which may be ok?)

It's not something we've done, as it takes time and effort to craft package installations/packages for every OS going. I'm not against this, but it's not something I like doing myself (either the effort of packaging, or as a consumer, relying on OS-installed development libraries and headers; nothing annoys me more than having to apt install a bunch of random stuff :D )

toutriste commented 1 year ago

I see, I guess people have different tastes :) My suggestion remains, having a distro package would make some things easier for X users. Thanks for replying!

mattgodbolt commented 1 year ago

We'd be happy for someone to take this on :) I'll happily merge in!

madebr commented 1 year ago

Create an issue and mark it with an octoberfest label, you've got 2 weeks left :smile: For a little python library I'm maintaining, I received a little pr out of the blue.

See https://hacktoberfest.com/participation/#maintainers