Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1398 Search for -lphtread.a it should be -lpthread.dll

closed-invalid
Cesar Strauss
ld (17)
2010-02-17
2010-02-16
Julio Tentor
No

I'm using Code-Block IDE (on Windows Server 2008 with MinGW and gcc-c++-4.4.0), when trying to compile a program who include pthread.h from pthreads_w32-2.8.0-2-mingw32 the link process fail because ld is searching for -lphtread.a and it should be -lpthread.dll.

I copy lib\libpthread.dll.a and rename it to lib\libphtread.a and run ok

Discussion

  • Julio Tentor
    Julio Tentor
    2010-02-16

    this is the code that i try to compile and link

     
    Attachments
  • Cesar Strauss
    Cesar Strauss
    2010-02-16

    • assigned_to: nobody --> cstrauss
     
  • Cesar Strauss
    Cesar Strauss
    2010-02-16

    Could you try using simply "-lpthread" instead of "-lpthread.a"?
    In codeblocks, I believe you just use "pthread" in the link library list.
    Otherwise, could you show the full command line?
    In codeblocks, I believe it's configured in:
    Settings->Compiler->Other Settings->Compiler logging->Full command line

     
  • Julio Tentor
    Julio Tentor
    2010-02-16

    Thanks guy,
    I can see the full command line so I could add pthread.dll in Settings->Linker settings, this is the name for the library in pthreads_w32-2.8.0-2-mingw32

    This is my Build Log:

    -------------- Build: Release in DemoThread ---------------

    mingw32-g++.exe -Wall -fexceptions -O2 -c H:\GNU\DemoThread\DemoThread\main.cpp -o obj\Release\main.o
    H:\GNU\DemoThread\DemoThread\main.cpp: In function 'void* GenerarPrimos(void*)':
    H:\GNU\DemoThread\DemoThread\main.cpp:54: warning: no return statement in function returning non-void
    mingw32-g++.exe -o bin\Release\DemoThread.exe obj\Release\main.o -s -lpthread.dll
    Output size is 468.50 KB
    Process terminated with status 0 (0 minutes, 1 seconds)
    0 errors, 1 warnings

    Sorry it is not a bug, my mistake.

     
  • Cesar Strauss
    Cesar Strauss
    2010-02-17

    I'm glad you got it working.
    Regards,
    Cesar

     
  • Cesar Strauss
    Cesar Strauss
    2010-02-17

    • status: open --> closed
     
  • Cesar Strauss
    Cesar Strauss
    2010-02-17

    • status: closed --> closed-invalid
     
  • Keith Marshall
    Keith Marshall
    2010-02-17

    Notwithstanding that he fortuitously got it working, he still appears to have it wrong! It should *neither* be `-lpthread.a' *nor* `-lpthread.dll'; it *should* simply be `-lpthread'.

    The documentation for ld, (the GNU linker), clearly explains the search algorithm; when you (incorrectly) specify `-lpthread.dll', the search goes:

    1) libpthread.dll.dll.a
    2) pthread.dll.dll.a
    3) libpthread.dll.a
    4) pthread.dll.lib
    5) libpthread.dll.dll
    6) pthread.dll.dll

    and it's nothing more than sheer blind luck that (3) happens to match the correct name.

    When you specify it correctly, as `-lpthread', then the search order becomes:

    1) libpthread.dll.a
    2) pthread.dll.a
    3) libpthread.a
    4) pthread.lib
    5) libpthread.dll
    6) pthread.dll

    and the correct match will be found immediately at (1), with any of the correctly named possible alternatives also being acceptable; (e.g. if the library had instead been libpthread.a, it would still be found, because (3) would match).