`
byebyegov5qq
  • 浏览: 1219592 次
文章分类
社区版块
存档分类
最新评论

gl_locale_name

 
阅读更多

When making libgettext, I got an error: undefined reference to gl_locale_name.
By google, I got to know one guy said in http://stackoverflow.com/questions/2753996/is-there-a-way-to-access-the-locale-used-by-gettext-under-windows:
Turns out the "gl_locale_name" function was not part of gettext directly, but rather part of gnulib - http://www.gnu.org/software/gnulib. I just discovered the package today.

So getting the infamous localename.h header in my project was a matter of

gnulib-tool --import localename
Then the gl_locale_name function works just fine when cross-compiling.

Thanks to everyone for the answers !

So I tried to find out how to use gnulib, and got the following from http://www.gnu.org/software/gnulib/manual/html_node/index.html#Top:

Invoking ‘gnulib-tool --import’ will copy source files, create a Makefile.am to build them, generate a file gnulib-comp.m4 with Autoconf M4 macro declarations used by configure.ac, and generate a file gnulib-cache.m4 containing the cached specification of how Gnulib is used.

Our example will be a library that uses Autoconf, Automake and Libtool. It calls strdup, and you wish to use gnulib to make the package portable to C89 and C99 (which don't have strdup).

~/src/libfoo$ gnulib-tool --import strdup
Module list with included dependencies:
absolute-header
extensions
strdup
string
File list:
lib/dummy.c
lib/strdup.c
lib/string.in.h
m4/absolute-header.m4
m4/extensions.m4
m4/gnulib-common.m4
m4/strdup.m4
m4/string_h.m4
Creating directory ./lib
Creating directory ./m4
Copying file lib/dummy.c
Copying file lib/strdup.c
Copying file lib/string.in.h
Copying file m4/absolute-header.m4
Copying file m4/extensions.m4
Copying file m4/gnulib-common.m4
Copying file m4/gnulib-tool.m4
Copying file m4/strdup.m4
Copying file m4/string_h.m4
Creating lib/Makefile.am
Creating m4/gnulib-cache.m4
Creating m4/gnulib-comp.m4
Finished.

You may need to add #include directives for the following .h files.
#include <string.h>

Don't forget to
- add "lib/Makefile" to AC_CONFIG_FILES in ./configure.ac,
- mention "lib" in SUBDIRS in Makefile.am,
- mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am,
- invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC,
- invoke gl_INIT in ./configure.ac.
~/src/libfoo$

and then I happened search gl_locale_name in the gettext folder, and got several gl_locale_name.o, and the gnulib-lib/localename.o is ok.
Then I added the file to the link:
am_msginit_OBJECTS = ../gnulib-lib/localename.o msginit-msginit.$(OBJEXT) \
msginit-lang-table.$(OBJEXT) msginit-plural-count.$(OBJEXT) \
msginit-localealias.$(OBJEXT) msginit-lock.$(OBJEXT)

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics