Skip to contentSkip to conversation

use of iconv() in main.c

DISCUSSION Robert Urban 2 participants 7 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Hello,

I'm building an embedded linux system using uClibc, which by default does not have locale support. In order to build lm_sensors-2.8.7 I had to comment out the code that refers to iconv() in set_degstr() (in main.c), as well as the "#include <iconv.h>" line.

It might save others a bit of trouble if you made the use of locales an option...

thanks for lm_sensors, by the way!

cheers,

Rob Urban
Munich, Germany

#1 lore raw
Quoted 7 lines

I'm building an embedded linux system using uClibc, which by default does not have locale support. In order to build lm_sensors-2.8.7 I had to comment out the code that refers to iconv() in set_degstr() (in main.c), as well as the "#include <iconv.h>" line.

It might save others a bit of trouble if you made the use of locales an option...

Is there a way we could detect the use of uClibc? If there is a known #define, we could use it to automatically disable the use of iconv.

Thanks.

Signature · 2 lines
Jean "Khali" Delvare
http://khali.linux-fr.org/
#2 lore raw
In reply to Robert Urban
Quoted 10 lines · You
Quoted 7 lines

I'm building an embedded linux system using uClibc, which by default does not have locale support. In order to build lm_sensors-2.8.7 I had to comment out the code that refers to iconv() in set_degstr() (in main.c), as well as the "#include <iconv.h>" line.

It might save others a bit of trouble if you made the use of locales an option...

Is there a way we could detect the use of uClibc? If there is a known #define, we could use it to automatically disable the use of iconv.

In the case of cross-compiling, there is probably a way of detecting it's use. However, I'm using a chroot-environment and then just running make with the defaults.

Rob Urban

#3 lore raw
In reply to Robert Urban
Quoted 6 lines
Quoted 2 lines

Is there a way we could detect the use of uClibc? If there is a known #define, we could use it to automatically disable the use of iconv.

In the case of cross-compiling, there is probably a way of detecting it's use. However, I'm using a chroot-environment and then just running make with the defaults.

I was thinking of a test like this within the C source code:
#if defined(__GLIBC__) && __GLIBC__ = 2
#include <something>
#endif

We have this for detecting glibc 2.x. Maybe there is a similar symbol defined for uClib? If there is, we could rely on it to automatically disable the use of iconv. This would work for both the cross-compilation and the chroot-environment cases.

For glibc 2.3, the symbol is defined in include/features.h. Could you please take a look at this file (or any other you see fit) in your uClibc compilation environment and search for a similar line? If you find something relevant, let us know.

Thanks,

Signature · 2 lines
Jean "Khali" Delvare
http://khali.linux-fr.org/
#4 lore raw
In reply to Robert Urban

Hi Jean,

it looks like __UCLIBC__ is what you're looking for.

from my /usr/include/features.h:

[...]

/* This macro indicates that the installed library is uClibc. Use
* __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in
* specific releases. */
#define __UCLIBC__ 1

thanks for your trouble. Let me know if you'd like to have the whole features.h file.

cheers,

Rob Urban

Quoted 22 lines · You
Quoted 7 lines
Quoted 3 lines

Is there a way we could detect the use of uClibc? If there is a known #define, we could use it to automatically disable the use of iconv.

In the case of cross-compiling, there is probably a way of detecting it's use. However, I'm using a chroot-environment and then just running make with the defaults.

I was thinking of a test like this within the C source code:
#if defined(__GLIBC__) && __GLIBC__ = 2
#include <something>
#endif

We have this for detecting glibc 2.x. Maybe there is a similar symbol defined for uClib? If there is, we could rely on it to automatically disable the use of iconv. This would work for both the cross-compilation and the chroot-environment cases.

For glibc 2.3, the symbol is defined in include/features.h. Could you please take a look at this file (or any other you see fit) in your uClibc compilation environment and search for a similar line? If you find something relevant, let us know.

#5 lore raw
In reply to Robert Urban

Hi Jean,

shortly after you sent this mail the hard disk on which my OS resode died. I will try to test your patch in the next few days and get back to you.

cheers,

Rob Urban

Quoted 15 lines · You
Quoted 2 lines

it looks like __UCLIBC__ is what you're looking for.

OK. Care to test the attached patch? It should skip iconv completely when uclibc is used.

If it works OK I'll commit it to our repository.

Thanks.

Signature · 2 lines
Jean "Khali" Delvare
http://khali.linux-fr.org/
#6 lore raw
In reply to Robert Urban

Hi Robert,

Quoted 8 lines
Quoted 4 lines

OK. Care to test the attached patch? It should skip iconv completely when uclibc is used.

If it works OK I'll commit it to our repository.

shortly after you sent this mail the hard disk on which my OS resode died. I will try to test your patch in the next few days and get back to you.

Any news? I need your confirmation that it works OK for you before I can apply the patch to our CVS repository.

Thanks.

Signature · 2 lines
Jean Delvare
http://khali.linux-fr.org/