LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C won't execute?!??! (https://www.linuxquestions.org/questions/programming-9/c-wont-execute-728773/)

ectof 05-27-2009 03:00 AM

C won't execute?!??!
 
Hi,

For some reason one of my computers has stopped executing C programs. On startup it will be fine for a bit and then (presumably after some unknown event) will not run any of my c programs.

I can compile and run a new C program that will work and it will run Tcl and bash scripts but not C.

Sorry there isn't more information but it hasn't happened many times.

Thanks,

ectof

verdeboy2k 05-27-2009 03:22 AM

What distribution are you using? And what exact error message are you getting when you try to run programs that don't work?

Sergei Steshenko 05-27-2009 03:25 AM

Quote:

Originally Posted by ectof (Post 3554055)
Hi,

For some reason one of my computers has stopped executing C programs. On startup it will be fine for a bit and then (presumably after some unknown event) will not run any of my c programs.

I can compile and run a new C program that will work and it will run Tcl and bash scripts but not C.

Sorry there isn't more information but it hasn't happened many times.

Thanks,

ectof

I think items in red and blue contradict each other.

ectof 05-27-2009 06:37 AM

Sorry, the question was not well posed.

The distro is a quite old version of suse (7.?) and gcc is 3.3, it has been reasonably stable up to now.

I meant that I could compile and run the executable of a new program, but I cannot run programs that have been compiled previously i.e. before the last boot up.

ectof

Sergei Steshenko 05-27-2009 06:45 AM

Quote:

Originally Posted by ectof (Post 3554219)
Sorry, the question was not well posed.

The distro is a quite old version of suse (7.?) and gcc is 3.3, it has been reasonably stable up to now.

I meant that I could compile and run the executable of a new program, but I cannot run programs that have been compiled previously i.e. before the last boot up.

ectof

So, post (copy-paste) the source, command lines you used to compile and link, command lines you used to invoke the newly produced programs and the error messages they produce.

ectof 05-27-2009 12:58 PM

Thanks for your help so far.
So I managed to find out a bit more.
The program I was testing with was just the most basic 'hello_world.c'

When I compile and run

#include <stdio.h>

int main() {
printf("hello world\n");
return 0;
}

gcc 'hello_world.c'
./a.out

it gives the expected 'hello world'

But, if I do

gcc 'hello_world.c' -lgpibapi
./a.out

It seems to compile OK and then when I execute it just hangs.
I then tried

gcc 'hello_world.c' -lm
./a.out

and again it executes.
As I say the on immediate startup things are OK but then it stops working.
If you have any idea why this might happen for this library that would be great. I guess I am doing something to screw up the gpib, but I have no idea what.

ectof

verdeboy2k 05-27-2009 04:21 PM

So, only programs that use that one library are not working, correct?

ectof 05-27-2009 05:13 PM

Yes so far as I'm aware but I haven't tested all the libraries.

ta0kira 05-27-2009 05:28 PM

Can you post ldd a.out (when the program doesn't execute)? Do you happen to have two versions of libgpibapi with the same soname? Also post ls -l /usr/lib/libgpibapi/libgpibapi* (adjust path as applicable.)
Kevin Barry

ectof 05-27-2009 06:19 PM

Hi this is the output from the session log

ldd a.out
linux-gate.so.1 => (0xffffe000)
libgpibapi.so.2 => /usr/local/lib/libgpibapi.so.2 (0x40032000)
libc.so.6 => /lib/tls/libc.so.6 (0x40091000)
libnipalu.so.1 => /usr/local/lib/libnipalu.so.1 (0x401a6000)
libgpibconf.so.2 => /usr/local/lib/libgpibconf.so.2 (0x4023b000)
libm.so.6 => /lib/tls/libm.so.6 (0x40251000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
librt.so.1 => /lib/tls/librt.so.1 (0x40273000)
libdl.so.2 => /lib/libdl.so.2 (0x4027b000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x4027e000)

ls -l /usr/local/lib/libgpibapi*
lrwxrwxrwx 1 root root 15 2005-09-16 16:09 /usr/local/lib/libgpibapi.so -> libgpibapi.so.2
lrwxrwxrwx 1 root root 19 2005-09-16 16:09 /usr/local/lib/libgpibapi.so.2 -> libgpibapi.so.2.3.1
lrwxrwxrwx 1 root root 49 2005-09-16 16:09 /usr/local/lib/libgpibapi.so.2.3.1 -> /usr/local/natinst/ni4882/lib/libgpibapi.so.2.3.1

ls -l /usr/local/natinst/ni4882/lib/libgpibapi.so.2.3.1
-rwxr-xr-x 1 root root 379735 2005-03-02 20:25 /usr/local/natinst/ni4882/lib/libgpibapi.so.2.3.1

verdeboy2k 05-27-2009 10:10 PM

Have you recompiled all (or at least one) of the non-functioning programs? Maybe you updated the library and they are linked against the wrong version.

ta0kira 05-27-2009 10:18 PM

It seems like it has something to do with the loading of that particular library (i.e. the _init function.) Why do you try to link to it? Does it replace something contained in libm?
Kevin Barry

ectof 05-28-2009 02:44 AM

I have tried recompiling a few of the programs, which didn't work.

Some of the other programs need it.

Thanks.

AnanthaP 05-28-2009 03:24 AM

Having googled for "libgpibapi", here are two promising results you may like to pursue.

http://forums.ni.com/ni/board/messag...ssage.id=17597

http://linux.derkeiler.com/pdf/Newsg...1/msg00165.pdf

End

ectof 05-28-2009 04:24 AM

Thanks, that's kind of embarrassing. This looks like it may be a much more common problem than I thought.


All times are GMT -5. The time now is 03:09 PM.