PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Unable to compile simple code using -Bstatic on RHEL6.1

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
David Gunter



Joined: 15 Sep 2005
Posts: 25

PostPosted: Wed Feb 29, 2012 10:57 am    Post subject: Unable to compile simple code using -Bstatic on RHEL6.1 Reply with quote

I have done fresh installs (without error) of PGI 10.9, 11.10 and 12.2 on a RHEL 6.1 system. None of them are able to compile a simple hello world app if -Bstatic is used.

Here's the code:
Code:
#include <stdio>

int main(){
   printf("Hello World!\n");
   return 0;
}


And here's what happens when I go to compile:
Code:
pgcc -Bstatic -o hello.c.static hello.c
/usr/bin/ld: cannot find -lpthread


The code will compile normally if I remove the -Bstatic flag, though I end up with the expected dynamic executable instead of the desired static one.

My /usr/bin/ld version is
Code:
ld --version
GNU ld version 2.20.51.0.2-5.20.el6_1.1 20091009
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
Back to top
View user's profile
David Gunter



Joined: 15 Sep 2005
Posts: 25

PostPosted: Wed Feb 29, 2012 11:16 am    Post subject: Reply with quote

It appears that our sysadmins have left out the glibc-static rpms needed for building static libs on RHEL6.1. I believe this to be the cause. I installed PGI 12.2 on another RHEL6.1 system that did have glibc-static installed and it works as expected.

-david
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 436

PostPosted: Wed Feb 29, 2012 11:21 am    Post subject: Re: Statically linking and libpthreads Reply with quote

David,

Thanks for the question. libpthreads is a system library, and Linux releases want you
to use the libpthreads installed on the system, and not one statically linked on another.

Either compile and/or link with
-nomp
or use
-Bstatic_pgi
to only statically link the PGI libs - then the executable will dynamically link
with the systems versions of libc and libpthreads, and incompatibliites can be
prevented. You still have no need to install PGI libs on the target systems.

We decided with 11.* releases to link every executable as if -mp were set.
This exposed a number of problems we fixed, but there are some cases, like this,
that do not match users' expectations.

regards,
dave
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group