-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Building with CMAKE on Windows #543
Comments
Thanks for the report. Is there a way to have both static and shared libraries on windows. IIUC, the problem is that on Windows the result of static and shared build are both library.lib, so they can not coexist in one place? Going to try to fix the problem ASAP. Would be very grateful, if you point to the CMake project that have those problems solved, to we could grab the best practices from there. |
@eustas , it looks like that usual solution is to name static lib differently on Windows, so both .lib files (for shared and static builds) can reside in the same directory. |
Thanks. Going to try adding suffix soon. Don't know why we put all artifacts to bin on Windows; most likely it for historical reasons =) going to update libraries installation path very soon. |
I forsee one drawback with building shared+static. Unfortenately, currently we have to stick to CMake 2.8.6. This means that we can not use OBJECT libraries implemented in 2.8.8. As a consequence, sources will be compiled twice... |
Yes, just plain cmake it's supposed way. Two runs is not an issue, the issues seems are no obvious support of static build, wrong installation paths and lack of documentation. |
Max, could you take a look at #544. |
On Windows includes should be processed similar. I guess, you can just remove |
Hello, Max. |
Great news @eustas ! Going to check as much as I can... |
It seems, the libs are in expected paths on Windows now, thanks!
|
Also it's might make sense to mention in Readme.md the possibility to rename output libs for static build, if it's required. For example, in the way like it's done here. |
Unsure if this is the appropriate thread for CMAKE build issues on windows, so please excuse me, I do not intend to hijack the thread. I have attempted all the build options and they all arrive at a less than ideal conclusion. I will describe each below. Through trial and error I was able to finally build a stand alone Brotli executable...see end of post. Autotools-style CMake The basic commands to build `C:\Users\gbown\Documents\google-brotli\brotli>mkdir out && cd out C:\Users\gbown\Documents\google-brotli\brotli\out>../configure-cmake Unable to proceed further, obviously this would apply to static build with autotools as well. CMake The basic commands to build and install Build succeeded 0 Errors CMake to build static libraries Result
`C:\Users\gbown\Documents\google-brotli\brotli\out-static>cmake .. -DBUILD_SHARED_LIBS=OFF C:\Users\gbown\Documents\google-brotli\brotli\out-static>make If I add the flag -DBUILD_SHARED_LIBS=OFF to the first set of CMake instructions, it does build a stand alone brotli.exe without errors which is usable, however; I had to sort of guess that this was how to do it, point being not all of us are full on c++ developers. Running brotli -9 -f -o my-file.brotli -- my-file works great however there is no clear way to run tests on the newly created executable. The -q and --quality AND -# seem to be two different ways of setting the same thing however setting -q 11 produces a smaller file than -9 and the two commands cannot be used at the same time; is there documentation on this anywhere? So to sum things up, to build a stand alone executable on Windows with CMake, the following works. mkdir out && cd out cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./installed .. cmake --build . --config Release --target install After this you should have a brotli.exe file that you can then set an environment path to allowing you to use brotli compression in your Windows build scripts anywhere. |
Thanks for the reporting. |
BUILD_SHARED_LIBS=OFF is no-op now. Removing it from options renders your command sequence to be exactly the same as one given in readme. |
Could you please add instructions to run build with cmake on Windows.
Also it seems it's not obvious how to build shared and static versions to have both of them in one INSTALL_PREFIX directory.
Another issue, install places *.lib files into "bin" folder, but "lib" is expected on Windows.
The text was updated successfully, but these errors were encountered: