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

Compiling with clang on Windows #2303

kodebach opened this Issue Dec 14, 2018 · 1 comment


None yet
2 participants
Copy link

kodebach commented Dec 14, 2018

As discussed, I tried to compile Elektra on Windows using clang.

I started with the current MinGW config:

	-DPLUGINS="wresolver;dump;list" \

I then made the following adjustments:

  • I set -DBINDINGS=-ALL and -DTOOLS="" (getopt is needed for the kdb tool but doesn't exist on windows)
  • I also set -DENABLE_OPTIMIZATIONS=OFF (not sure why but with optimizations enabled there were linker errors for some of the opmphm functions)
  • I manually excluded the benchmarks in benchmarks and in src/libs/tools/benchmarks (by adding return() as the first line of the CMakeLists.txt file).
  • I set SIZEOF_MODE_T and SIZEOF_TV_USEC in kdbconfig.h to 0 so that some #ifs work (there is probably a better solution in CMake for this)
  • I added the following lines to kdb.h because these are necessary in a lot of places:
    #if defined(_MSC_VER)
    #include <BaseTsd.h>
    typedef SSIZE_T ssize_t;
    #define strcasecmp _stricmp
    #define strncasecmp _strnicmp
  • sys/time.h has to be replaced but according to this that should not be too hard.
  • unistd.h isn't available either but as far as I can tell only read is used from this header and that inside a CPP file, so it should be easily replaceable. Also mode_t has to be manually defined as typedef int mode_t.
  • __attribute__(X) has to be defined as an empty macro. It seems the windows version of clang does not support this feature.

After these changes, I was able to compile. However a still got a whole lot of linker errors. Basically for every function of Elektra (from kdbGet to keyRewindMeta and everything else) there was an error undefined symbol: _XXX (where _XXX stands for the function name prefixed with an _).

To sum up:

  • Compiling the Elektra library on native Windows might be possible with some changes and if we find out what causes the linker problems.
  • Compiling the kdb tool would either require including (or fetching during CMake configuration) of an implementation of getopt. Alternatively (in my opinion the better option) we could use a getopt-compatible C++ library for command-line arguments (e.g.

This comment has been minimized.

Copy link

markus2330 commented Dec 14, 2018

Thank you so much for trying this out!

Maybe you can create a PR with these changes in case someone else wants to pick this up. (the MSC specific lines should be in kdbos.h instead of kdb.h)

The linker error: is this maybe a problem of -fleading-underscore?

Command-line args: Of course we will switch to your implementation of command-line arguments once #1252 is ready 👍 But it would be better if we do not use C++, to make the LCDproc people happy. (Additionally "args" seems to be unmaintained).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment