Discussion:
[fpc-devel] [iconv][glibc] function "iconvctl" not found.
4iter
2011-10-23 11:49:17 UTC
Permalink
Hi!

In new GLIBC exists internal implementation "libiconv" (see
http://www.gnu.org/s/hello/manual/libc/glibc-iconv-Implementation.html)
Implemented functions:
iconv_t iconv_open (__const char *__tocode, __const char *__fromcode);
size_t iconv (iconv_t __cd, char **__restrict __inbuf,
size_t *__restrict __inbytesleft,
char **__restrict __outbuf,
size_t *__restrict __outbytesleft);
int iconv_close (iconv_t __cd);

In the file fpc/rtl/unix/cwstrings.pp using function "iconvctl" non
existings in glibc !
Original libiconv not installed!
Svn-version Lazarus show build error:
.....................
Compiling svn2revisioninc.pas
Linking ./svn2revisioninc
/home/guest/root/lib/fpc/2.7.1/units/i386-linux/rtl/cwstring.o: In
function `CWSTRING_$$_INITTHREAD':
cwstring.pp:(.text+0xf4): undefined reference to `iconvctl'
/home/guest/root/lib/fpc/2.7.1/units/i386-linux/rtl/cwstring.o: In
function `CWSTRING_$$_WIDE2ANSIMOVE$PWIDECHAR$RAWBYTESTRING$WORD$LONGINT':
cwstring.pp:(.text+0x3e5): undefined reference to `iconvctl'
svn2revisioninc.pas(600,1) Error: Error while linking
svn2revisioninc.pas(600,1) Fatal: There were 1 errors compiling module,
stopping
Fatal: Compilation aborted
..............................................
Maybe fixit it with #ifdef ?

I apologize, for incorrect English
Paul Ishenin
2011-10-23 12:01:34 UTC
Permalink
Post by 4iter
Hi!
Fatal: Compilation aborted
..............................................
Maybe fixit it with #ifdef ?
How to define this ifdef?

Maybe it could be fixed either by dynamic loading or weakexternal directive?

Best regards,
Paul Ishenin.
Jonas Maebe
2011-10-23 12:17:19 UTC
Permalink
Post by Paul Ishenin
Post by 4iter
Hi!
Fatal: Compilation aborted
..............................................
Maybe fixit it with #ifdef ?
How to define this ifdef?
Maybe it could be fixed either by dynamic loading or weakexternal directive?
Or we require libiconv also under Linux (and link against it; currently we only link against libc under Linux and use its -apparently limited- iconv functionality).


Jonas
Paul Ishenin
2011-10-24 02:00:40 UTC
Permalink
Post by Paul Ishenin
Post by 4iter
Hi!
Fatal: Compilation aborted
..............................................
Maybe fixit it with #ifdef ?
How to define this ifdef?
Maybe it could be fixed either by dynamic loading or weakexternal directive?
I tried to handle the situation by using LoadLibrary, GetProcAddress and
also failed on osx.

The next line tries to load "iconv.dylib" while on osx the library name
is "/usr/lib/libiconv.dylib":

iconvlib:=LoadLibrary(libiconvname+'.'+SharedSuffix);

Now I don't understand how it works with the static linking if
"libiconvname" variable is "iconv"?

Best regards,
Paul Ishenin.
zeljko
2011-10-24 05:45:21 UTC
Permalink
Post by Paul Ishenin
Post by Paul Ishenin
Post by 4iter
Hi!
Fatal: Compilation aborted
..............................................
Maybe fixit it with #ifdef ?
How to define this ifdef?
Maybe it could be fixed either by dynamic loading or weakexternal directive?
I tried to handle the situation by using LoadLibrary, GetProcAddress and
also failed on osx.
The next line tries to load "iconv.dylib" while on osx the library name
iconvlib:=LoadLibrary(libiconvname+'.'+SharedSuffix);
Now I don't understand how it works with the static linking if
"libiconvname" variable is "iconv"?
Because ld knows about "real" libiconv ?

zeljko
Jonas Maebe
2011-10-24 09:22:43 UTC
Permalink
Post by Paul Ishenin
I tried to handle the situation by using LoadLibrary, GetProcAddress
and also failed on osx.
The next line tries to load "iconv.dylib" while on osx the library
iconvlib:=LoadLibrary(libiconvname+'.'+SharedSuffix);
Now I don't understand how it works with the static linking if
"libiconvname" variable is "iconv"?
The compiler automatically adds the "lib" prefix and the sharedsuffix
in case of external declarations (and additionally, on Mac OS X the
library name in external declarations is not even used, only the
{$libklib xxx} directive matters -- but there the compiler performs
the same transformations of the library name).


Jonas

Marco van de Voort
2011-10-23 12:25:56 UTC
Permalink
Post by Jonas Maebe
Post by Paul Ishenin
How to define this ifdef?
Maybe it could be fixed either by dynamic loading or weakexternal directive?
Or we require libiconv also under Linux (and link against it; currently we
only link against libc under Linux and use its -apparently limited- iconv
functionality).
Seems that that function is not in the open group's specification of iconv,
it is a GNU extension.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/iconv.h.html
Jonas Maebe
2011-10-23 12:56:33 UTC
Permalink
Post by Marco van de Voort
Seems that that function is not in the open group's specification of iconv,
it is a GNU extension.
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/iconv.h.html
Ah, yes. Even Mac OS X apparently uses GNU libiconv. So a weak symbol is probably the best solution.


Jonas
Paul Ishenin
2011-10-23 13:02:25 UTC
Permalink
Post by Jonas Maebe
Post by Marco van de Voort
Seems that that function is not in the open group's specification of iconv,
it is a GNU extension.
http://pubs.opengroup.org/onlinepubs/009695399/basedefs/iconv.h.html
Ah, yes. Even Mac OS X apparently uses GNU libiconv. So a weak symbol is probably the best solution.
Does weaksymbol works on all platforms where cwstrings is used (I know
that it is not implemented on windows at least but there we don't need
cwstrings too)?

Best regards,
Paul Ishenin
Jonas Maebe
2011-10-23 13:05:39 UTC
Permalink
Does weaksymbol works on all platforms where cwstrings is used (I know that it is not implemented on windows at least but there we don't need cwstrings too)?
Good question, and I'm afraid the answer is "no"... At least http://wiki.freepascal.org/FPC_HowToDo#Weak_linking doesn't list *BSD, and I believe it also hasn't been implemented yet in the internal assembler as that page indicates.


Jonas
Marco van de Voort
2011-10-23 13:14:58 UTC
Permalink
Post by Jonas Maebe
Post by Paul Ishenin
Does weaksymbol works on all platforms where cwstrings is used (I know
that it is not implemented on windows at least but there we don't need
cwstrings too)?
Good question, and I'm afraid the answer is "no"... At least
http://wiki.freepascal.org/FPC_HowToDo#Weak_linking doesn't list *BSD, and
I believe it also hasn't been implemented yet in the internal assembler as
that page indicates.
FreeBSD supports #pragma weak, it is even used in the startup code.
Jonas Maebe
2011-10-23 13:16:57 UTC
Permalink
Post by Marco van de Voort
Post by Jonas Maebe
Post by Paul Ishenin
Does weaksymbol works on all platforms where cwstrings is used (I know
that it is not implemented on windows at least but there we don't need
cwstrings too)?
Good question, and I'm afraid the answer is "no"... At least
http://wiki.freepascal.org/FPC_HowToDo#Weak_linking doesn't list *BSD, and
I believe it also hasn't been implemented yet in the internal assembler as
that page indicates.
FreeBSD supports #pragma weak, it is even used in the startup code.
It's about the FPC support for weakexternal on the various platforms.


Jonas
Loading...