Segementation fault when trying to run a working program (C++)
Okay, I know that title seems ridiculous, but here's my problem:
I wrote a C++ program that is working. I have used it a lot on my university's Linux network computers. I have had 0 problems with getting usable data out of it. Recently I transferred the program to the lab computer's in my adviser's lab. After compiling it and trying to run it, I get a segmentation fault. There is no output at all. I tried just printing a "1" before any variables were even initialized. It wouldn't even do that much before segmentation fault. I don't think there is a problem with the code (like I said, I can get data out of the program on the university's Linux network computers). Could this be an issue with not having up-to-date C++ compiler or something of that nature? |
Quote:
Quote:
Quote:
The best thing to do with a segmentation fault is use gdb to find out where the segmentation fault occurs. |
If you've got static objects, their constructors will get called. Those constructors might be causing your segfault. Try using gdb to find out where it exactly crashed.
|
Hi -
tuxdev and johnsfine are correct. A lot could be happening before your first line of code gets called, and you really should rebuild everything with "-g" and run the program in "gdb" to get a better idea where the problem is. One additional note: C/C+ both use "buffered I/O". It's entirely possible that your "print 1" actually got called, but never got a chance to display. WORKAROUND: Code:
fprintf (stderr, "1\n"); 'Hope that helps .. PSM |
Ah okay, thank you all very much for the replies! I'll look into using gdb.
|
All times are GMT -5. The time now is 04:20 AM. |