Olivier TARTROU | 4 Feb 01:58
Picon

Runtime link problem

Hello

I'm new to ncurses. Read doc and FAQ but not found the solution to my problem.

I'm creating a .so library: ok.
Writing a test application that links to my library and calls its functions: ok.
But to perform deeper tests, in my case, a human interaction would be better (using serial port IO pins and minimal hw instrumentation).
So I found ncurses that would be great for user controlled tests, in a terminal window.

I learned about basic functions such as initscr(), keypad() and printw().

When I compile and run, it works fine for these functions.

But mycode crashes at run time when I call a function of my libray, without any warning/error at link time and I can't figure why.
My library is correctly (I think so) linked, but when behaviour changes when I link with ncurses.

Error message:
Command: ./shell: symbol lookup error: ./shell: undefined symbol: SERIAL_GetDtr

This function is in my lib, that I created and compiled. And it works successfully when not using ncurses.

Test program Makefile:
gcc -Wall xx1.o xx2.o -o shell -L../../module_src/src/ -l first_lib -l pthread -l ncurses

(this links with no warning, and runs if I remove -l ncurses and ncurses calls).

Compiled on Ubuntu 10.04 with 2.6.32-38-generic kernel (x86).

Function prototype:
bool SERIAL_GetDtr(int fd);
bool is typedef enum {false = FALSE, true = TRUE} bool;

I seems that there is a link problem, visible only at runtime, as soon as I link with ncursed. But can't figure why. Not absolutely sure it's ncurses related, but ncurses link triggers it.

Have any idea?

Thanks for you help!

Maya

_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Thomas Dickey | 5 Feb 03:06
Picon

ncurses-5.9-20120204.patch.gz

 ncurses 5.9 - patch 20120204 - Thomas E. Dickey

 ------------------------------------------------------------------------------

 Ncurses 5.9 is at
 	ftp.gnu.org:/pub/gnu

 Patches for ncurses 5.9 are in the subdirectory
 	ftp://invisible-island.net/ncurses/5.9

 ------------------------------------------------------------------------------
 ftp://invisible-island.net/ncurses/5.9/ncurses-5.9-20120204.patch.gz
 patch by Thomas E. Dickey <dickey <at> invisible-island.net>
 created  Sun Feb  5 01:59:13 UTC 2012
 ------------------------------------------------------------------------------
 NEWS              |    8 ++-
 dist.mk           |    4 -
 man/tic.1m        |   38 ++++++++++------
 progs/tic.c       |  119 ++++++++++++++++++++++++++++++++++++++++++++--------
 test/movewindow.c |    5 --
 5 files changed, 136 insertions(+), 38 deletions(-)
 ------------------------------------------------------------------------------

20120204
	+ improved tic -D option, avoid making target directory and provide
	  better diagnostics.

--

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Thomas Dickey | 12 Feb 02:39
Picon

ncurses-5.9-20120211.patch.gz

 ncurses 5.9 - patch 20120211 - Thomas E. Dickey

 ------------------------------------------------------------------------------

 Ncurses 5.9 is at
 	ftp.gnu.org:/pub/gnu

 Patches for ncurses 5.9 are in the subdirectory
 	ftp://invisible-island.net/ncurses/5.9

 ------------------------------------------------------------------------------
 ftp://invisible-island.net/ncurses/5.9/ncurses-5.9-20120211.patch.gz
 patch by Thomas E. Dickey <dickey <at> invisible-island.net>
 created  Sun Feb 12 01:33:57 UTC 2012
 ------------------------------------------------------------------------------
 INSTALL           |   10 
 NEWS              |   16 
 configure         | 3675 ++++++++++++++++++++++++++--------------------------
 configure.in      |   24 
 dist.mk           |    4 
 misc/Makefile.in  |    3 
 misc/gen_edit.sh  |   11 
 misc/terminfo.src |   47 
 8 files changed, 1941 insertions(+), 1849 deletions(-)
 ------------------------------------------------------------------------------

20120211
	+ make sgr for xterm-pcolor agree with other caps -TD
	+ make sgr for att5425 agree with other caps -TD
	+ make sgr for att630 agree with other caps -TD
	+ make sgr for linux entries agree with other caps -TD
	+ make sgr for tvi9065 agree with other caps -TD
	+ make sgr for ncr260vt200an agree with other caps -TD
	+ make sgr for ncr160vt100pp agree with other caps -TD
	+ make sgr for ncr260vt300an agree with other caps -TD
	+ make sgr for aaa-60-dec-rv, aaa+dec agree with other caps -TD
	+ make sgr for cygwin, cygwinDBG agree with other caps -TD
	+ add configure option --with-xterm-kbs to simplify configuration for
	  Linux versus most other systems.

--

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Pierre Labastie | 12 Feb 15:38
Picon

Wrong 'break' statement when testing if etip.h needs math.h

Hi,

When "checking for special defines needed for etip.h", configure uses
a double loop:
----------------------
for cf_math in "" MATH_H
do
for cf_excp in "" MATH_EXCEPTION
do
[short compilation test with -DETIP_NEEDS_${cf_math}
and -DETIP_NEEDS_${cf_excp} if those variables are not empty]
if <no compile error and compiler generated an objet file>
break
else [error message and log]
done
done
[display result and record in confdefs]
-------------------
The break statement only exits the inner loop, so that
even if compilation test passes with 2 variables empty
this is not recorded and the result is MATH_H needed.
Excerpt of config.log:
configure:17630: checking for special defines needed for etip.h
configure:17656: /usr/bin/g++ -c -O2 -I./c++ -I./menu -I./include  
-D_GNU_SOURCE -DNDEBUG conftest.cc >&5
configure:17659: $? = 0
configure:17662: test -s conftest.o
configure:17665: $? = 0
configure:17656: /usr/bin/g++ -c -O2 -I./c++ -I./menu -I./include 
-DETIP_NEEDS_MATH_H  -D_GNU_SOURCE -DNDEBUG conftest.cc >&5
configure:17659: $? = 0
configure:17662: test -s conftest.o
configure:17665: $? = 0
configure:17686: result: MATH_H

The correction is to use break 2. See attached patch.

Regards,
Pierre Labastie

Index: ncurses-5.9/configure
===================================================================
--- ncurses-5.9.orig/configure	2012-02-12 15:04:18.000000000 +0100
+++ ncurses-5.9/configure	2012-02-12 15:17:59.000000000 +0100
@@ -17674,7 +17674,7 @@
 EOF

 	cf_result="$cf_math $cf_excp"
-	break
+	break 2

 else
   echo "$as_me: failed program was:" >&5
Index: ncurses-5.9/aclocal.m4
===================================================================
--- ncurses-5.9.orig/aclocal.m4	2011-04-01 01:35:38.000000000 +0200
+++ ncurses-5.9/aclocal.m4	2012-02-12 15:18:46.000000000 +0100
@@ -1167,7 +1167,7 @@
 	test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
 	test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
 	cf_result="$cf_math $cf_excp"
-	break
+	break 2
 ],[])
 done
 done
_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Pierre Labastie | 12 Feb 17:08
Picon

Re: Wrong 'break' statement when testing if etip.h needs math.h

Le 12/02/2012 15:38, Pierre Labastie a écrit :
>
> When "checking for special defines needed for etip.h", configure uses
> [...]
> The correction is to use break 2. See attached patch.
Answering myself because actually the picture seems more
complicated. What I said in the preceding post is true. However,
there is another issue. The compile test uses:
----------------
#include <etip.h.in>
----------------------
and <etip.h.in> does
--------------------
#includes <ncurses_dll.h>
--------------------
and at the time configure is run, ncurses_dll.h
does not exist in the ncurses tree. (only ncurses_dll.h.in)

So there are two cases:
-the host has ncurses_dll.h, or configure has already been
run once in the same tree. Then the compile tests pass
and because of what I said in the preceding message,
it ends up with ETIP_NEEDS_MATH_H defined to 1.
-the host does not yet have ncurses_dll.h. Then all 4 tests
fail and the result is none (nothing needed).

Applying the patch of my preceding message does not
solve this second case. The solution would be that etip.h.in
include ncurses_dll.h.in, but then that it changes to
including ncurses_dll.h when generating etip.h. I do not know
enough of the ncurses package to find what is to be modified.

Regards
Pierre Labastie
Thomas Dickey | 18 Feb 23:50
Picon

Re: Wrong 'break' statement when testing if etip.h needs math.h

On Sun, Feb 12, 2012 at 05:08:50PM +0100, Pierre Labastie wrote:
> Le 12/02/2012 15:38, Pierre Labastie a ?crit :
>>
>> When "checking for special defines needed for etip.h", configure uses
>> [...]
>> The correction is to use break 2. See attached patch.

I did overlook this (thanks)

> Answering myself because actually the picture seems more
> complicated. What I said in the preceding post is true. However,
> there is another issue. The compile test uses:
> ----------------
> #include <etip.h.in>
> ----------------------
> and <etip.h.in> does
> --------------------
> #includes <ncurses_dll.h>
> --------------------
> and at the time configure is run, ncurses_dll.h
> does not exist in the ncurses tree. (only ncurses_dll.h.in)

I made a fix for the missing ncurses_dll.h in December:

20111203
	+ modify configure-check for etip.h dependencies, supplying a temporary
	  copy of ncurses_dll.h since it is a generated file (prompted by
	  Debian #646977).
	+ modify CF_CPP_PARAM_INIT "main" function to work with current C++.

--

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Thomas Dickey | 19 Feb 00:19
Picon

Re: ncurses-5.9-20120107.patch.gz

On Sun, Jan 15, 2012 at 11:06:52PM +0200, Roumen Petrov wrote:
> Hello Thomas,
>
> Thomas Dickey wrote:
>>   ncurses 5.9 - patch 20120107 - Thomas E. Dickey
> I cannot follow rapid development of ncursers.

from my viewpoint, it seems to crawl ;-)

>> [SNIP]
>> 20120107
>> 	+ various improvments for MinGW (patch by Juergen Pfeifer):
>> 	  + modify stat() calls to ignore the st_size member
>> 	  + drop mk-dlls.sh script.
>> 	  + change recommended regular expression library.
>> 	  + modify rain.c to allow for threaded configuraton.
>> 	  + modify tset.c to allow for case when size-change logic is not used.
> Thanks to Juergen Pfeifer for mingw patches. It seems to me such patches  
> cover native build.
>
> In same topic but not related only to mingw I would like to inform you  
> about cross-compilation issue - build on linux form mingw host and run  
> in emulated environment.
>
>
> - term_entry.h (real cross-issue)

I've fixed this in tonight's patch (and since I keep overlooking cross
compiles) added a check for cross-compiles to my regression builds.

Since I've more than one VM setup with mingw cross-compilers, I've
also a to-do to investigate building the dll's there.  (On my Windows 7,
there's work needed to incorporate Juergen's changes there - just a lot
of things to work through...).

>   term_entry.h include term.h and latest is for host system
>   make_hash - a binary for build system include term_entry.h to get  
> enumerate DBDIRS for some functions in tic.h and cross-build fall if is  
> for incompatible host like build from linux to mingw.
>   For protocol I enclose all except enumerate in  #ifndef USE_BUILD_CC  
> to build ncurses.
>
> - db_iterator.c
>   mingw patch just ignore st_size member in two places .
>   If I understand code check_existence(...) is only to test existence of 
> a directory .
>   S_ISDIR(sb->st_mode) work on mingw.
>   Could "..sb->st_size" be replaced by .._ISDIR(sb->st_mode)  ?

I addressed this shortly after your email, since I ran into the same
issue testing with eCS.

--

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Thomas Dickey | 19 Feb 02:05
Picon

re: Runtime link problem

>*From*: 	Olivier TARTROU
>*Subject*: 	Runtime link problem
>*Date*: 	Sat, 4 Feb 2012 01:58:11 +0100
>
>------------------------------------------------------------------------
>Hello
>
>I'm new to ncurses. Read doc and FAQ but not found the solution to my
>problem.
>
>I'm creating a .so library: ok.
>Writing a test application that links to my library and calls its
>functions: ok.
>But to perform deeper tests, in my case, a human interaction would be
>better (using serial port IO pins and minimal hw instrumentation).
>So I found ncurses that would be great for user controlled tests, in a
>terminal window.
>
>I learned about basic functions such as initscr(), keypad() and printw().
>
>When I compile and run, it works fine for these functions.
>
>But mycode crashes at run time when I call a function of my libray,
>without any warning/error at link time and I can't figure why.
>My library is correctly (I think so) linked, but when behaviour changes
>when I link with ncurses.
>
>Error message:
>Command: ./shell: symbol lookup error: ./shell: undefined symbol:
>SERIAL_GetDtr
>
>This function is in my lib, that I created and compiled. And it works
>successfully when not using ncurses.
>
>Test program Makefile:
>gcc -Wall xx1.o xx2.o -o shell -L../../module_src/src/ -l first_lib -lpthread -l ncurses

Perhaps there's a problem with the way you're using threads.
Normally ncurses isn't threadsafe; it's possible to improve that.

>(this links with no warning, and runs if I remove -l ncurses and ncurses
>calls).
>
>Compiled on Ubuntu 10.04 with 2.6.32-38-generic kernel (x86).
>
>Function prototype:
>bool SERIAL_GetDtr(int fd);
>bool is typedef enum {false = FALSE, true = TRUE} bool;
>
>I seems that there is a link problem, visible only at runtime, as soon
>as I link with ncursed. But can't figure why. Not absolutely sure it's
>ncurses related, but ncurses link triggers it.
>
>Have any idea?

From the description, it's more than "ncurses link" but the execution
of the program.

--

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Thomas Dickey | 19 Feb 03:15
Picon

ncurses-5.9-20120218.patch.gz

 ncurses 5.9 - patch 20120218 - Thomas E. Dickey

 ------------------------------------------------------------------------------

 Ncurses 5.9 is at
 	ftp.gnu.org:/pub/gnu

 Patches for ncurses 5.9 are in the subdirectory
 	ftp://invisible-island.net/ncurses/5.9

 ------------------------------------------------------------------------------
 ftp://invisible-island.net/ncurses/5.9/ncurses-5.9-20120218.patch.gz
 patch by Thomas E. Dickey <dickey <at> invisible-island.net>
 created  Sun Feb 19 02:09:31 UTC 2012
 ------------------------------------------------------------------------------
 Ada95/aclocal.m4              |   10 
 Ada95/configure               |  251 +-
 INSTALL                       |   11 
 NEWS                          |   13 
 aclocal.m4                    |   37 
 configure                     | 3798 ++++++++++++++++++++--------------------
 configure.in                  |   13 
 dist.mk                       |    4 
 include/curses.h.in           |   13 
 include/nc_tparm.h            |    8 
 include/tic.h                 |   11 
 ncurses/tinfo/make_hash.c     |    5 
 ncurses/tinfo/tinfo_driver.c  |    6 
 ncurses/tty/lib_twait.c       |    3 
 ncurses/win32con/win_driver.c |   43 
 progs/tput.c                  |    9 
 16 files changed, 2169 insertions(+), 2066 deletions(-)
 ------------------------------------------------------------------------------

20120218
	+ correct CF_ETIP_DEFINES configure macro, making it exit properly on
	  the first success (patch by Pierre Labastie).
	+ improve configure macro CF_MKSTEMP by moving existence-check for
	  mkstemp out of the AC_TRY_RUN, to help with cross-compiles.
	+ improve configure macro CF_FUNC_POLL from luit changes to detect
	  broken implementations, e.g., with Mac OS X.
	+ add configure option --with-tparm-arg
	+ build-fix for MinGW cross-compiling, so that make_hash does not
	  depend on TTY definition (cf: 20111008).

--

-- 
Thomas E. Dickey <dickey <at> invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net
_______________________________________________
Bug-ncurses mailing list
Bug-ncurses <at> gnu.org
https://lists.gnu.org/mailman/listinfo/bug-ncurses
Samuel Bronson | 20 Feb 22:19
Picon
Gravatar

tack's configure script doesn't find separate tic library. (Also needlessly pulls in libncurses when libtinfo would suffice.)

When ncurses has been built with --with-ticlib, as it is in Debian's
ncurses packages since 5.6+20071006-3, tack configures but fails to
link, like this:

naesten <at> hydrogen:~/hacking/debian/source-tack/tack% make
linking tack ...
edit.c:971: error: undefined reference to '_nc_tic_expand'
edit.c:891: error: undefined reference to '_nc_tic_expand'
edit.c:881: error: undefined reference to '_nc_reset_input'
edit.c:882: error: undefined reference to '_nc_trans_string'
edit.c:476: error: undefined reference to '_nc_tic_expand'
edit.c:477: error: undefined reference to '_nc_tic_expand'
edit.c:351: error: undefined reference to '_nc_reset_input'
edit.c:352: error: undefined reference to '_nc_trans_string'
collect2: ld returned 1 exit status
make: *** [tack] Error 1
naesten <at> hydrogen:~/hacking/debian/source-tack/tack% make -n
echo linking tack ... ; gcc ../tack/ansi.o ../tack/charset.o
../tack/color.o ../tack/control.o ../tack/crum.o ../tack/edit.o
../tack/fun.o ../tack/init.o ../tack/menu.o ../tack/modes.o
../tack/output.o ../tack/pad.o ../tack/scan.o ../tack/sync.o
../tack/sysdep.o ../tack/tack.o -lncurses   -L/lib    -DHAVE_CONFIG_H
-I. -I.  -D_GNU_SOURCE -g -O2 -o tack

This can be worked around by passing LIBS="-ltic" to the configure
script, though.

Another, less serious issue is that there is no way to prevent it from
linking with libncurses, which causes this warning when building a
Debian package (using libncurses-dev >= 5.9-2, which uses the
--with-termlib flag):

dpkg-shlibdeps: warning: dependency on libncurses.so.5 could be
avoided if "debian/tack/usr/bin/tack" were not uselessly linked
against it (they use none of its symbols).

This is not particularly harmful, of course: ncurses isn't exactly
going to stop needing terminfo, and users of tack who would mind
having libncurses installed can probably be counted on one hand (or
less). It's just kind of annoying not to be able to avoid the
warning...

Gmane