Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Lasthop: 61.170.194.130 Message-ID: <002501c3e982$09877b40$0100a8c0@TAMAHOME> From: "Cliff Zhang" To: Subject: libiberty.a and getopt problem Date: Mon, 2 Feb 2004 19:45:19 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id i12BktX3003671 Hi, all I've compiled elf2flt (a tool to convert elf format file to flat used by uClinux), but it crashs while I'm compiling uClinux. This tool will use libiberty compiled for the specified target (for example, arm-elf) and I found if I don't use this library and it will works. (There are two applications elf2flt and flthdr, the second one will not use libiberty and I can compile it) Then I wrote a simple program to test: #include #include int main(int argc, char **argv) { int opt; while ((opt = getopt(argc, argv, "avzdrkp:s:o:R:")) != -1) { printf("opt = %d,%c\n", opt, (char)opt); printf("optarg = %s\n", optarg); } } when it is compiled with gcc -O2 opt.c -o opt it is ok and it I type opt -s 1 it will output: opt = 115,s optarg = 1 but if it is compiled with gcc -O2 opt.c -o opt -liberty opt -s 1 will output: opt = 115,s optarg = (null) gcc-3.3.1 and 3.2.3 is the same problem I use nm /lib/libiberty.a > iberty.txt and find there's already a getopt function in libiberty, and perhaps it conflicts with libc.a It can be ok if I remove the getopt implementations in libiberty.a with ar d libiberty.a getopt.o getopt1.o then it will produce the correct output. So I don't know how to deal with it.