libucl
libucl copied to clipboard
Minor issues with win32 builds
I am building libucl in Linux targeting a Win32 platform using MXE (https://github.com/mxe/mxe). This uses an internal i686-w64-mingw32 toolchain. The same issues also apply when building using Qt's built in mingw toolchain in a Windows environment. I am using the provided cmake CMakeLists.txt in both cases, which makes it very easy to compile to target Windows and generate a static library.
Here is what I'm seeing:
- ucl_util.c fails to build out of the box because the NBBY macro is not recognized in either of these toolchains, or any mingw based toolchain I've come across. Thus, I'd propose adding something like this:
#ifdef _WIN32
#include <limits.h>
#define NBBY CHAR_BIT
#endif
- ucl_util.c again fails to build because most Windows compatible toolchains also do not support globbing due to missing glob.h (it must be added specially to certain toolchains) so I had to comment out the dependency for glob.h and comment out related globbing code in ucl_util.c code. I'd propose adding in #ifdef's around these globbing sets so we can build on Win32 (albeit with no glob support, which is fine for most users anyway), or handle this differently if there is a better way.
Unfortunately, I have no windows machine available for testing and I'm not very experienced in windows development tools. However, if you have a tested patch I'll be happy to review and include it to libucl.
Great, thank you! Give me a couple of days to get some patches together and test them to have a proper cross-compiling package. Will let you know when they are ready.
Done! Let me know if proposed patch is okay. This now compiles for me with MinGW and Cygwin targeting the Win32 platform.
Your patch seems to be fine and I have merged it, thank you! It is also interesting whether is it possible to compile libucl with the recent msvc compiler (in c99 mode).
I can test this when I get to work (as I have the latest Visual Studio there). From experience though, it's always been a chore to get C/C++ code playing well with the MSVC compiler, which is why I didn't use the _MSC_VER macro here. It is also much easier to cross compile C/C++ code for Windows in Linux using something like MXE. But yes, it is worth checking.
@vstakhov @nimaim Why haven't you close this issue?
If You are waiting for someone to try compile libucl with the recent msvc compiler (in c99 mode), would you please answer for the following questions? And I can do that.
- Which version I should try compile?
- Are you considering continuous msvc support ? if so we should prepare test programs for windows. can I try modify or add test script and test program so that test can be executed on windows in the future?
- There is multiple build script in this repository (makefile.w32, makefile.unix, setting files for autotools, and CMakeLists.txt) Could you explain the role of each build settings of each?
- Which approach do you like ?
- compile libucl on msvc
- compile libucl with mingw (or MXE) and then link libucl with msvc programs]
Thanks.