Re: Problem with compiling gengetopt on OpenSolaris

Lorenzo Bettini <[email protected]> Wed, 06 May 2009 17:19:33 +0200
Newsgroups gmane.comp.gnu.gengetopt.general
Message-ID <[email protected]>
Hi Lukas

thanks for your patch!
Actually another Opensolaris user experienced this problem, which seems 
to be due to how flex library is implemented in opensolaris (by googling 
a bit I had found other similar problems, not related to gengetopt but 
to programs using flex in open solaris);  I wasn't able to find a 
solution since I can't reproduce the problem in linux (and I don't have 
opensolaris).  Yours seems to be the solution!

However, I'd like to try to get rid of the flex library which is 
basically not used by gengetopt; I'll try to provide you with a new 
version to test.

cheers
	Lorenzo

Lukas Rovensky wrote:
> 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:
> 
> lukas@myspulin:~/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
> lukas@myspulin:~/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
> [email protected]
> http://lists.gnu.org/mailman/listinfo/help-gengetopt


-- 
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net