Skip to content
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

Support for dll builds in Win #20

Open
cstamatopoulos opened this issue May 3, 2017 · 3 comments
Open

Support for dll builds in Win #20

cstamatopoulos opened this issue May 3, 2017 · 3 comments

Comments

@cstamatopoulos
Copy link

Is this something that would interest you ?
If yes I can make a pull request or I can paste the code here as it is only minor changes in the header file.

@Iyengar111
Copy link
Owner

I'm not really sure what you mean by support for dll build. Why don't you raise the pull request, I'll have a look and hopefully get more clarity as well.
In any case, I wouldn't want to add any thing that is windows specific to NanoLog. No platform specific code and using only standard headers was a strong design consideration.

@cstamatopoulos
Copy link
Author

cstamatopoulos commented May 3, 2017

Currently, no symbols will be exported in MSVC.
To do so you have to specify which symbols to export. This is usually done with the code shown below and it will be fine in all platforms. Note that most cross-platform c++ libraries do something similar, e.g. check fmt but it is up to you.

#if defined(_WIN32)
# ifdef NANO_LOG_EXPORT
#  define NANO_LOG_API __declspec(dllexport)
# elif defined(NANO_LOG_SHARED)
#  define NANO_LOG_API __declspec(dllimport)
# endif
#endif
#ifndef NANO_LOG_API
# define NANO_LOG_API
#endif

Then you need to add the NANO_LOG_API in classes and functions that have to be exported. In your case there are only 7 places where you need to do that.
An example would be
NANO_LOG_API void set_log_level(LogLevel level);
If you are OK with that I can send a pull request otherwise feel free to close the issue.

@crapp
Copy link

crapp commented May 15, 2017

@cstamatopoulos In case you are using cmake did you have a look at WINDOWS_EXPORT_ALL_SYMBOLS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants