[Bug 1001618] Re: gcc link step fails against -lpthread and -ldl

Richard Eccles r.q.eccles at gmail.com
Sat May 19 12:13:03 UTC 2012


-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/1001618

Title:
  gcc link step fails against -lpthread and -ldl

Status in “gcc-defaults” package in Ubuntu:
  New

Bug description:
  This bug found for both -ldl and -lpthread on a clean install of Ubuntu 12.04
  Tried before and after updates, on my presario f700 laptop (using both 32 & 64 bit versions) and on VirtualBox using 32bit.
  All produced exactly the same result.

  Bug reproduced for libpthread only using the simple test application
  given below - it builds and runs fine in 11.04.

  Build command and output is :
  -------------------------------------------------------------------------------------------------
  gcc -lpthread pthread_test.c -o test
  /tmp/ccJSnO1N.o: In function `main':
  pthread_test.c:(.text+0xfc): undefined reference to `pthread_create'
  pthread_test.c:(.text+0x119): undefined reference to `pthread_create'
  pthread_test.c:(.text+0x12a): undefined reference to `pthread_join'
  pthread_test.c:(.text+0x13b): undefined reference to `pthread_join'
  collect2: ld returned 1 exit status
  -------------------------------------------------------------------------------------------------

  
  And the test file source is :
  -------------------------------------------------------------------------------------------------
  #include <stdio.h>
  #include <stdlib.h>
  #include <pthread.h>

  static int idle_count = 1000000;

  void *thread_worker( void *ptr )
  {
  	int c = 0, cc = 0;
  	int id = ( ptr ) ? *((int*)ptr) : 0;

  	while( c++ < 10 ) {
  		printf("Thread(%d) %d\n", id, c);
  		/* Slow things down by doing some make work.	*/
  		for( cc = 0; cc < idle_count; cc++ ) {;}
  	}
  }

  
  int main ( int argc, char **argv )
  {
  	pthread_t thrd1, thrd2;
  	int id1 = 1, id2 = 2;

  	/* Set idle count from command line if given.	*/
  	if( argc > 1 ) {
  		idle_count = atoi( argv[1] );
  		if( idle_count < 1000 ) idle_count = 1000000;
  	}
  	printf("Idle count is [%d]\n", idle_count );

  	pthread_create( &thrd1, NULL, thread_worker, (void*)(& id1) );
  	pthread_create( &thrd2, NULL, thread_worker, (void*)(& id2) );

  	pthread_join( thrd1, NULL );
  	pthread_join( thrd2, NULL );

  	exit( 0 );
  }
  ----------------------------------------------------------------------------------------------------
  test file ends.

  ProblemType: Bug
  DistroRelease: Ubuntu 12.04
  Package: gcc 4:4.6.3-1ubuntu5
  ProcVersionSignature: Ubuntu 3.2.0-24.37-generic 3.2.14
  Uname: Linux 3.2.0-24-generic x86_64
  NonfreeKernelModules: nvidia
  ApportVersion: 2.0.1-0ubuntu7
  Architecture: amd64
  Date: Sat May 19 12:44:18 2012
  InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64 (20120425)
  ProcEnviron:
   LANGUAGE=en_GB:en
   TERM=xterm
   PATH=(custom, no user)
   LANG=en_GB.UTF-8
   SHELL=/bin/bash
  SourcePackage: gcc-defaults
  UpgradeStatus: No upgrade log present (probably fresh install)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1001618/+subscriptions




More information about the foundations-bugs mailing list