LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Ncurses based program had to be recompiled on a different PC, same OS (http://www.linuxquestions.org/questions/programming-9/ncurses-based-program-had-to-be-recompiled-on-a-different-pc-same-os-838894/)

tardis1 10-18-2010 03:41 PM

Ncurses based program had to be recompiled on a different PC, same OS
 
Riddle me this:

On an Ubuntu Server I am running, I wrote a small Ncurses program in GCC. It worked just fine.

Then, I copied the executable over to my Ubuntu 10.10 desktop edition with sftp. No matter what I did, it kept giving the error:

error opening terminal: xterm.

I had copied other non-curses programs and they all ran just fine.

Finally, I copied over the source, recompiled with GCC and voila, the executable now runs fine.

Why?

Sergei Steshenko 10-18-2010 03:53 PM

Quote:

Originally Posted by tardis1 (Post 4131690)
Riddle me this:

On an Ubuntu Server I am running, I wrote a small Ncurses program in GCC. It worked just fine.

Then, I copied the executable over to my Ubuntu 10.10 desktop edition with sftp. No matter what I did, it kept giving the error:

error opening terminal: xterm.

I had copied other non-curses programs and they all ran just fine.

Finally, I copied over the source, recompiled with GCC and voila, the executable now runs fine.

Why?

Find "error opening terminal" message in source, understand the context, i.e. what the program was actually trying to do, what checks it performed, what check failed, etc., and you'll find an answer to your 'why' question.

Sergei Steshenko 10-18-2010 04:01 PM

OK, you'd better not change case in error messages:

Code:

build/ncurses-5.7/ncurses/base/lib_initscr.c:      fprintf(stderr, "Error opening terminal: %s.\n", name);
- and now you know, which file to start from.

tardis1 10-18-2010 09:53 PM

Sorry Sergei,

I'm not understanding your advice. The error message is coming from the OS. It is not something I coded in to the source. The program ran on my server where I originally compiled it. I need to know why an executable copied to another machine would refuse to work unless recompiled. The OS's are supposed to be the same. Therefore, I should be able to copy programs from one machine to another and they should run. That was true with my programs that only used stdio, but the one with ncurses functions had to be recompiled.

paulsm4 10-18-2010 10:47 PM

tardis1 -

Quote:

Q: Finally, I copied over the source, recompiled with GCC and voila, the executable now runs fine.

Why?
A: In the words of a wise philosopher:
"Ca-ca happens ;)"

Quote:

I'm not understanding your advice
I think Sergei was chastising you for transcribing "error opening terminal" instead of cut/pasting "Error opening terminal" (capital-E), making it slightly harder for him to "grep" for the error. No biggie, and certainly nothing to do either with your question or his response.

Quote:

The OS's are supposed to be the same. Therefore, I should be able to copy programs from one machine to another and they should run.
In general, true.

But there ARE exceptions.

Google for "Error opening terminal: xterm" and you'll come up with a number of hits. For example:
http://www.osgeo.org/pipermail/grass...ch/008560.html

In this case, a dependent library caused the init_scr() failure.

Perhaps something similar happened in your case. And perhaps simply re-linking the program created a different set of dependencies, all of which were satisifed on your system. It's hard to tell.

I wouldn't lose too much sleep worrying about it, and I'd be reasonably confident that the next curses program you copied to a different PC might work just fine as-is.

IMHO...

Sergei Steshenko 10-19-2010 12:19 AM

Quote:

Originally Posted by tardis1 (Post 4131988)
Sorry Sergei,

... The OS's are supposed to be the same. ...

As paulsm4 has already pointed out, not necessarily the set of installed libraries is the same.

tardis1 10-19-2010 09:51 AM

OK, I understand; somewhat. If terminfo is not loaded correctly a curses program cannot start. I did try loading ncurses and running the executable; yet, still received the same error. This answers my question, but will also raise others.

Thanks for ya'lls help. I might eventually learn how to post questions according to the rules.


All times are GMT -5. The time now is 04:02 PM.