Hi there,
I tried to compile gengetopt 2.22 on OpenSolaris 2008.11 (both using
gcc/g++ and SunStudio cc/CC) and I got the following error during linking:
g++ -g -O2 -o gengetopt parser.o scanner.o argsdef.o cmdline.o
gengetopt.o gm.o yyerror.o gm_utils.o fileutils.o acceptedvalues.o
ggos.o ../gl/.libs/libgnu.a -lfl skels/.libs/libgen.a
/usr/sfw/lib/libstdc++.so -L/usr/sfw/lib -lgcc_s -lm -Wl,-R
-Wl,/usr/sfw/lib -Wl,-R -Wl,/usr/sfw/lib
ld: warning: file /usr/sfw/lib/libstdc++.so: attempted multiple
inclusion of file
Undefined first referenced
symbol in file
yylex /usr/lib/libfl.so
ld: fatal: Symbol referencing errors. No output written to gengetopt
collect2: ld returned 1 exit status
The problem is that C++ compiler creates "mangled" symbol name for yylex:
address@hidden:~/Desktop/t/gengetopt-2.22.1$ elfdump src/scanner.o |
grep yylex
[99] 0x00000828 0x000000f7 FUNC GLOB D 0 .text
_Z13yylex_destroyv
[111] 0x000009c8 0x00000eab FUNC GLOB D 0 .text _Z5yylexv
address@hidden:~/Desktop/t/gengetopt-2.22.1$ elfdump src/parser.o | grep
yylex
[81] 0x00000000 0x00000000 NOTY GLOB D 0 UNDEF _Z5yylexv
R_386_PC32 0xcf2 .rel.text _Z5yylexv
While the libfl.so expects just "yylex". I solved this issue by
wrapping the lines declaring yylex function like:
#ifdef __cplusplus
extern "C" {
#endif
extern int yylex(int);
#ifdef __cplusplus
}
#endif
in the files parser.cc and scanner.cc.
However, when I compiled gengetopt on Ubuntu 8.10 then the code got
compiled and linked without any modifications.
Am I doing something wrong (missing some parameter for configure, etc.)?
I will definitely appreciate any advise.
Another option -- would you be eventually willing to accept a simple
patch adding the "#ifdef __cplusplus ..." guards, so gengetopt can get
directly compiled on OpenSolaris?
Thanks for any help.
Kind regards,
Lukas
_______________________________________________
Help-gengetopt mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-gengetopt