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 Message-ID: <4090B4EF.4060204@yahoo.fr> Date: Thu, 29 Apr 2004 09:55:27 +0200 From: bertrand marquis Reply-To: bertrand_marquis AT yahoo DOT fr User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.2.1) Gecko/20030225 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: libiberty and getopt Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Checker-Version: SpamAssassin 2.61 (1.212.2.1-2003-12-09-exp) on donald.sysgo.com X-Spam-Level: X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=no version=2.61 X-AntiVirus: checked by AntiVir MailGate (version: 2.0.1.16; AVE: 6.25.0.2; VDF: 6.25.0.38; host: balu) X-IsSubscribed: yes Hi, I need to compile a program using libiberty.a and the function getopt_long. When compiling with the flag -liberty my program crash because it don't take the right arguments from the command line. But without libiberty this part work before. i made a small program showing that problem, if anyone has an idea ? i'm using the latest cygwin from the installer ,gcc-3.3.1 and ld 2.15.90 20040312 thanks You can find next my source code for the test program and the result i have with it. My test program: /*begin of argu.c*/ #include #include #include #include int main(int argc, char **argv) { struct option long_opts[] = { {"v", 1, 0, 'v'}, {"no-v", 0, 0, 'V'}, {"k", 1, 0, 'k'}, {"no-k", 0, 0, 'K'}, {"l", 1, 0, 'l'}, {"no-l", 0, 0, 'L'}, {0, 0, 0, 0} }; int c; while ((c = getopt_long(argc, argv, "v:Vk:Kl:L:", long_opts, NULL)) != EOF) { switch(c) { case 'v': printf("v %s\n",optarg); break; case 'V': printf("V\n"); break; case 'k': printf("k %s\n",optarg); break; case 'K': printf("K\n"); break; case 'l': printf("l %s\n",optarg); break; case 'L': printf("L\n"); break; case '?': printf("other:%c\n",c); } } printf("argc=%d , optind=%d , file=%s\n",argc,optind,argc>optind?*(argv+optind):"none"); return 0; } /*end of argu.c*/ when you compile it with : gcc argu.c -o argu.exe it works: $ ./argu.exe -v abc -K test v abc K argc=5 , optind=4 , file=test but when you compile it with gcc argu.c -o argu.exe -liberty it gives: $ ./argu.exe -v abc -K test v (null) K argc=5 , optind=1 , file=-v -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/