From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21828 invoked by alias); 1 Aug 2011 04:28:20 -0000 Received: (qmail 21814 invoked by uid 22791); 1 Aug 2011 04:28:18 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yi0-f41.google.com (HELO mail-yi0-f41.google.com) (209.85.218.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 01 Aug 2011 04:28:04 +0000 Received: by yia13 with SMTP id 13so3870691yia.0 for ; Sun, 31 Jul 2011 21:28:04 -0700 (PDT) Received: by 10.143.99.21 with SMTP id b21mr2686888wfm.310.1312172881654; Sun, 31 Jul 2011 21:28:01 -0700 (PDT) Received: from [192.168.1.3] ([58.249.25.166]) by mx.google.com with ESMTPS id p9sm145419wfd.6.2011.07.31.21.27.42 (version=SSLv3 cipher=OTHER); Sun, 31 Jul 2011 21:27:44 -0700 (PDT) Message-ID: <4E362CA9.4080609@gmail.com> Date: Mon, 01 Aug 2011 04:28:00 -0000 From: PcX User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110630 Thunderbird/5.0 MIME-Version: 1.0 To: pthreads-win32@sourceware.org Subject: Re: Static linking with pthread-win32 (again) References: <4E361D40.8070400@vfemail.net> In-Reply-To: <4E361D40.8070400@vfemail.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2011/txt/msg00027.txt.bz2 于 2011/8/1 11:28, Eskes 写道: > Hello, > > I'm struggling with a problem for a while, and I can't figure it out. > I have a small test program (testpt.c) and I want to have it statically > linked with the pthread library. I use the latest TDM-4.5.2 MinGW > toolchain on WinXP (32) and I created the static lib from the cvs HEAD > version with the 'make clean GC-static' command and placed the > libpthreadGC2.a lib in the proper directory (in my case: /mingw/lib). > When I compile my testcase it keeps complaining about: > > $ gcc -c testpt.c > $ gcc -o testpt.exe testpt.o -lpthreadGC2 > testpt.o:testpt.c:(.text+0x29): undefined reference to `_imp__pthread_exit' > testpt.o:testpt.c:(.text+0x68): undefined reference to > `_imp__pthread_create' > testpt.o:testpt.c:(.text+0x86): undefined reference to `_imp__pthread_join' > collect2: ld returned 1 exit status > > This problem has been mentioned before (mailing list 2010-07-23), Ross > Johnson claimed that this problem was fixed in the cvs head version. > When I create a DLL lib with 'make clean GC' all compiles and runs fine > when I put the genereted pthreadGC2.dll in the same directory. Do I > overlook something or missing a point somewhere? Any help is appreciated. > > /* testpt.c (pthread static lib test) */ > #include > #include > #include > > void *f1(int *x){ > int i = *x; > printf("f1: %d",i); > pthread_exit(0); > } > > int main(void){ > pthread_t f1_thread; > int i1 = 1; > pthread_create(&f1_thread,NULL,(void*)f1,&i1); > pthread_join(f1_thread,NULL); > return(0); > } > > With regards, > John > > > If you use static edition, you must add the compiler option: -DPTW32_STATIC_LIB As is : gcc -DPTW32_STATIC_LIB -o testpt.exe testpt.o -lpthreadGC2 -- Best Regards, PcX