spdlog icon indicating copy to clipboard operation
spdlog copied to clipboard

spdlog as a DLL

Open Ubiquite opened this issue 9 years ago • 7 comments

spdlog is great but based on header and static variables. That means it's impossible today to use spdlog as-is in a program made of .exe and .dlls to write logs in one file. The exe and each dlls try to open the file for writing.

I suggest that spdlog have an option to be built as a dll encapsulating the static variables.

Ubiquite avatar Feb 23 '17 10:02 Ubiquite

Hi Ubiquite,

I've managed to pack SpdLog into a DLL. You may access my branch at "https://github.com/vwbij/spdlog".

vwbij avatar Feb 23 '17 10:02 vwbij

vwbij, how am I supposed to use it ?

Ubiquite avatar Feb 23 '17 12:02 Ubiquite

First you have to build the DLL. Download the sources and compile the DLL with VisualStudio 2015 or similar, 2010 does not work! You may choose between unicode or ansi build.

You can use the DLL using a importlib or using LoadLibrary / function pointers.

The base interface is in "spdloglb.h", also the printf style functions with variable parameter lists. The file has got also some basic documentation.

In "spdlog_vararg.h" you find functions with a variable parameter list object. I created this because variable parameter lists in plain C export functions are normally only possible using the printf style variable parameter list. This method is not type safe and error prone. In this header a object is defined that you may instantiate and feed with parameters with a streaming interface.

Hope this helps, Volker

vwbij avatar Feb 23 '17 15:02 vwbij

It would be way simpler to use if it's cmake-yfied

Ubiquite avatar Feb 24 '17 10:02 Ubiquite

Ok, I have no experience with CMake, and as far as I read CMake supports Visual Studio up to 2010, that is not enough for a successful build...

vwbij avatar Feb 24 '17 12:02 vwbij

It supports latest Visual Studio, you may have to update your cmake install.

Ubiquite avatar Feb 24 '17 13:02 Ubiquite

I do not have any CMake install, never done anything with it. So if somebody knows how to do it, he is welcome to create a CMake builder for this dll. For me, the most easy way is to click onto a project icon and build it via the installed Visual Studio.

vwbij avatar Feb 24 '17 13:02 vwbij