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

Compilation error: missing xlocale.h #61

Open
cogumbreiro opened this issue Feb 5, 2018 · 5 comments
Open

Compilation error: missing xlocale.h #61

cogumbreiro opened this issue Feb 5, 2018 · 5 comments

Comments

@cogumbreiro
Copy link

Hi, everyone,

I'm having problems compiling hclib in Ubuntu 17.10. According to ubuntu-packages it seemed I had to install libc++-dev. The file is indeed installed in my system but hclib's build script is not able to find it:

$ find /usr/include/ -iname 'xlocale.h'
/usr/include/c++/v1/support/solaris/xlocale.h
/usr/include/c++/v1/support/newlib/xlocale.h
/usr/include/c++/v1/support/ibm/xlocale.h
/usr/include/c++/v1/support/musl/xlocale.h
/usr/include/c++/v1/support/xlocale/xlocale.h

Any workarounds? I was expecting configure.sh to either find the right header or at least consider the missing header as an error.


Compilation error:

$ ./install.sh
[...]
/bin/bash ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../src -I../inc    -Wall -g -O3 -std=c11 -I../../inc -I../../src/inc -I../../src/fcontext  -DHC_ASSERTION_CHECK -DHC_COMM_WORKER_STATS -I/usr/include/libxml2 -Wall -g -O3 -std=c11 -MT libhclib_la-hclib-thread-bind.lo -MD -MP -MF .deps/libhclib_la-hclib-thread-bind.Tpo -c -o libhclib_la-hclib-thread-bind.lo `test -f 'hclib-thread-bind.c' || echo '../../src/'`hclib-thread-bind.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../src -I../inc -Wall -g -O3 -std=c11 -I../../inc -I../../src/inc -I../../src/fcontext -DHC_ASSERTION_CHECK -DHC_COMM_WORKER_STATS -I/usr/include/libxml2 -Wall -g -O3 -std=c11 -MT libhclib_la-hclib-thread-bind.lo -MD -MP -MF .deps/libhclib_la-hclib-thread-bind.Tpo -c ../../src/hclib-thread-bind.c  -fPIC -DPIC -o .libs/libhclib_la-hclib-thread-bind.o
../../src/hclib-thread-bind.c:20:10: fatal error: xlocale.h: No such file or directory
 #include <xlocale.h>
          ^~~~~~~~~~~
compilation terminated.
Makefile:695: recipe for target 'libhclib_la-hclib-thread-bind.lo' failed
make[2]: *** [libhclib_la-hclib-thread-bind.lo] Error 1
make[2]: Leaving directory '/tmp/hclib/compileTree/src'
Makefile:770: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/hclib/compileTree/src'
Makefile:478: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
@cogumbreiro
Copy link
Author

cogumbreiro commented Feb 5, 2018

I think the following link is related to this issue: xlocal.h is removed of glibc as of 2.26.

Edit: This thread discusses the issue and a workaround required to build LLVM.

@cogumbreiro
Copy link
Author

cogumbreiro commented Feb 5, 2018

Hard-coding the include path to any directory in /usr/include/c++/v1/support/* results in the following error:

In file included from /usr/include/sched.h:34:0,
                 from hclib-thread-bind.c:22:
/usr/include/time.h:113:5: error: unknown type name ‘locale_t’; did you mean ‘clock_t’?
     locale_t __loc) __THROW;
     ^~~~~~~~
     clock_t

I also tried following the suggestion of including locale.h rather than xlocale.h and obtained the same compiler error above.

@ahayashi
Copy link
Contributor

ahayashi commented Feb 6, 2018

Hello,

Can you try the code below? This would be just a quick fix and might not be a complete solution. But I confirmed the fix worked at least on my Ubuntu 17.10 machine and the C tests passed. I'll dive into more details, but please let me know if the fix works on your machine.

My changes include:

  1. Use locale.h instead of xlocale.h as you mentioned.
  2. Place #include<locale.h> before #define _GNU_SOURCE
  3. Add #include<time.h> immediately after #include<locale.h>

It seems that the locale_t error you mentioned was caused by using GNU Extensions (#define _GNU_SOURCE and __USE_GNU).

#include <stdio.h>
#include <locale.h>
#include <time.h>
#define _GNU_SOURCE
#define __USE_GNU
#include <xlocale.h>
#include <unistd.h>
#include <sched.h>
#include <errno.h>

@cogumbreiro
Copy link
Author

@ahayashi, with your changes I don't think we need to include xlocale.h. Here's the full patch below that allowed it to compile in my system:

@@ -15,9 +15,10 @@
  */
 
 #include <stdio.h>
+#include <locale.h>
+#include <time.h>
 #define _GNU_SOURCE
 #define __USE_GNU
-#include <xlocale.h>
 #include <unistd.h>
 #include <sched.h>
 #include <errno.h>

@ahayashi
Copy link
Contributor

ahayashi commented Feb 6, 2018

@cogumbreiro, oh right, I forgot to delete #include<xlocale.h>. Yes, the full patch was what I meant.

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