| View previous topic :: View next topic |
| Author |
Message |
Emma
Joined: 30 Sep 2008 Posts: 16
|
Posted: Tue Sep 30, 2008 11:24 am Post subject: error while loading shared libraries |
|
|
Hello,
I'm attempting to compile some existing C code with the PGI CDK C compiler.
The code includes a number of shared libraries, and executables which link to those shared libraries.
This being my first attempt, I've not included any optimizations in the compilation step. I've simply replace gcc with the pgcc command. The compilation appears to complete successfully. However when I attempt to run the main program it crashes abruptly on startup with: FATAL PROGRAM ERROR: Aborted on SIGSEGV.
So, I looked up the command for the PGI debugger and attempted to run the main program from there. It fails to launch and complains it cannot locate one of my shared libraries. I found the library in the directory I expect it to be in. That directory is in LD_LIBRARY_PATH and I include it in the path set by the -I flag for pgdbg:
| Code: | pgdbg -I $FPA/lib/$PLATFORM/:"other stuff here" $FPA/bin/$PLATFORM/$PROG
|
I don't know if the SIGSEGV is related to the failure of the debugger to locate the shared library or not.
Any guidance would be greatly appreciated.
I'm running PGI CDK 7.2-5 x86 32 bit version on an HP with two quad-core 64 bit Intel processors. Operating system is Red Hat Enterprise Linux Workstation 5.
I don't have a license for 64 bit in case you're wondering why I'm using the 32 bit version. |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 5001 Location: The Portland Group Inc.
|
Posted: Tue Sep 30, 2008 3:10 pm Post subject: |
|
|
Hi Emma,
PGDBG should be able to find your shared library if it's in your environment's LD_LIBRARY_PATH. However, the "-I" option tells the debugger where your source files are located, not your shared libraries. What happens if you remove the "-I$FPA/lib/$PLATFORM/:"other stuff here" option?
- Mat |
|
| Back to top |
|
 |
Emma
Joined: 30 Sep 2008 Posts: 16
|
Posted: Wed Oct 01, 2008 8:39 am Post subject: |
|
|
Hmm, that's what I thought. Anyway I removed the -I option completely and I get the same result.
Interestingly if I compile using gcc, and then run PGDBG it works just fine. Not sure why I didn't try this before. So this makes me think it's a compile issue not a debugger issue. I guess I'll have to take a closer look at our Makefiles. Are you aware of any differences between gcc and pgcc when it comes to compiling shared libraries or linking to them? |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 5001 Location: The Portland Group Inc.
|
Posted: Wed Oct 01, 2008 9:15 am Post subject: |
|
|
Hi Emma,
Chapter 7 of the PGI User's guide (http://www.pgroup.com/doc/pgiug.pdf) discusses how to create shared objects on Linux. However, we use the same method as gcc where you need compile your objects with "-fpic" and then use the flag "-shared" to create the shared object.
Also, we're object compatible with gcc so you can try creating the shared object with gcc and then link it with your application built with pgcc. Make sure that you compile the gcc portion with "-m32" if you're on a 64-bit system, in order to create 32-bit objects.
- Mat |
|
| Back to top |
|
 |
Emma
Joined: 30 Sep 2008 Posts: 16
|
Posted: Wed Oct 01, 2008 10:39 am Post subject: Not sure where to go from here. |
|
|
Hi Mat,
Well I tried your suggest and compiled the library with GCC and the main app with PGCC, same result. So for fun I compiled the library with PGCC and the main app with GCC, at least this time I got a different error message.
| Code: | | error while loading shared libraries: /opt/pgi/linux86/7.2-5/lib/libpgc.so: cannot restore segment prot after reloc: Permission denied |
Our makefiles are ancient and convoluted, but as far as I can tell I'm using the -fPIC and -shared flags correctly.
Thank-you for your ideas |
|
| Back to top |
|
 |
|