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

MSW: Unable to build / test as dll #460

Closed
richardeakin opened this issue Jan 30, 2017 · 5 comments
Closed

MSW: Unable to build / test as dll #460

richardeakin opened this issue Jan 30, 2017 · 5 comments

Comments

@richardeakin
Copy link
Contributor

Hi there and thanks for the wonderful formatting library. I've been using it for the last couple years and it has been great, my goto for string formatting.

Now I'm in need of building fmtlib as part of a larger shared library, specifically with Visual Studio 2015 / v140, which I do by adding format.cc to its sources and enabling FMT_EXPORT. To get this to work however, I had to add some extra FMT_API declarations, at minimum these. After doing this, I went to see how fmtlib's tests run as is. So I cloned the master branch and generated Visual Studio 2015 projects with -DBUILD_SHARED_LIBS=1, then proceeded to build the solution and hit a number of other compiler errors. I fixed a few others in this branch but stopped when I hit one that would require restructing a test in order to gain some feedback first on how to proceed. What is the goal of the FMT_API support?

I'm not so familiar with the entirety of the codebase as I've only ever used format.h/cpp (I've ignored posix.h/cpp, printf.h/cpp, etc - are those only for testing and benchmarks?), so I'm not sure if FMT_API declarations belong there for the sole purpose of building all of the tests with a shared lib configuration.

By the way, the error message I stopped on was due to this line, which causes a __declspec(dllimport) to end up in that file while it wasn't actually being imported from a DLL. Instead I think that test could just use the header only version in order to gain extra access to format.cc.

@vitaut
Copy link
Contributor

vitaut commented Feb 1, 2017

Thanks for the feedback.

What is the goal of the FMT_API support?

The original goal is to export all necessary symbols to be able to use the fmt library itself DLL on Windows. However, it probably hasn't been kept up to date because the default configuration is a static library.

If you want to use fmt as a part of a larger DLL, it might still better to link it a static library and set DBUILD_SHARED_LIBS to 0 (or use the default).

Another options is to use the header-only mode.

@richardeakin
Copy link
Contributor Author

Would you accept a PR with the FMT_API additions I needed to add if I throw one up? Perhaps only those that affect format.h/cc, as the rest of the code seems to be for tests that weren't designed with DLL support in mind.

Header-only is an option. We'd like to reduce as much of the headers that we pull in as possible, but still might do it.

@vitaut
Copy link
Contributor

vitaut commented Feb 2, 2017

Would you accept a PR with the FMT_API additions I needed to add if I throw one up?

Absolutely.

@vitaut
Copy link
Contributor

vitaut commented Feb 14, 2017

I guess this can be closed now.

@vitaut vitaut closed this as completed Feb 14, 2017
@richardeakin
Copy link
Contributor Author

Yes, thanks for the merge!

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

2 participants