Open oliveagle opened 9 years ago
And it works when you remove the -static
flag?
yes. without -static
works. but it will prompt error on a minimal system:
$ tig
tig: error while loading shared libraries: libncursesw.so.5: cannot open shared object file: No such file or directory
so I have to use LD_LIBRARY_PATH
and cp this lib with tig to make it work.
I'll try to reproduce it locally, but it would help if you could dig out the error messages from the file config.log.
first error:
conftest.c:9:28: fatal error: ac_nonexistent.h: No such file or directory
compilation terminated.
configure:2988: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tig"
| #define PACKAGE_TARNAME "tig"
| #define PACKAGE_VERSION "0"
| #define PACKAGE_STRING "tig 0"
| #define PACKAGE_BUGREPORT "Jonas Fonseca <fonseca@diku.dk>"
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #include <ac_nonexistent.h>
configure:3013: result: gcc -E
configure:3033: gcc -E conftest.c
configure:3033: $? = 0
configure:3047: gcc -E conftest.c
conftest.c:9:28: fatal error: ac_nonexistent.h: No such file or directory
compilation terminated.
configure:3047: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tig"
| #define PACKAGE_TARNAME "tig"
| #define PACKAGE_VERSION "0"
| #define PACKAGE_STRING "tig 0"
| #define PACKAGE_BUGREPORT "Jonas Fonseca <fonseca@diku.dk>"
| #define PACKAGE_URL ""
| /* end confdefs.h. */
| #include <ac_nonexistent.h>
second error:
configure:3359: checking whether environ is declared
configure:3359: gcc -c -static conftest.c >&5
conftest.c: In function 'main':
conftest.c:64:10: error: 'environ' undeclared (first use in this function)
conftest.c:64:10: note: each undeclared identifier is reported only once for each function it appears in
configure:3359: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tig"
| #define PACKAGE_TARNAME "tig"
| #define PACKAGE_VERSION "0"
| #define PACKAGE_STRING "tig 0"
| #define PACKAGE_BUGREPORT "Jonas Fonseca <fonseca@diku.dk>"
| #define PACKAGE_URL ""
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_GETTIMEOFDAY 1
| /* end confdefs.h. */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| # include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| int
| main ()
| {
| #ifndef environ
| #ifdef __cplusplus
| (void) environ;
| #else
| (void) environ;
| #endif
| #endif
|
| ;
| return 0;
| }
configure:3359: result: no
error 3:
configure:3442: checking for NcursesW wide-character library
configure:3466: gcc -o conftest -static -static conftest.c -lncursesw >&5
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_initscr.o): In function `initscr':
(.text+0x2): undefined reference to `_nc_globals'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_initscr.o): In function `initscr':
(.text+0xc): undefined reference to `stdscr'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_initscr.o): In function `initscr':
(.text+0x20): undefined reference to `_nc_globals'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_initscr.o): In function `initscr':
(.text+0x5a): undefined reference to `def_prog_mode'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_initscr.o): In function `initscr':
(.text+0x61): undefined reference to `stdscr'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_newterm.o): In function `filter':
(.text+0x2): undefined reference to `_nc_prescreen'
...
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_echo.o): In function `noecho':
(.text+0x23): undefined reference to `SP'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncursesw.a(lib_pad.o): In function `pnoutrefresh':
(.text+0x15a): undefined reference to `_nc_screen_of'
collect2: error: ld returned 1 exit status
configure:3466: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tig"
| #define PACKAGE_TARNAME "tig"
| #define PACKAGE_VERSION "0"
| #define PACKAGE_STRING "tig 0"
| #define PACKAGE_BUGREPORT "Jonas Fonseca <fonseca@diku.dk>"
| #define PACKAGE_URL ""
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_GETTIMEOFDAY 1
| #define HAVE_DECL_ENVIRON 0
| #define HAVE_DECL_ERRNO 1
| #define HAVE_MKSTEMPS 1
| #define HAVE_SETENV 1
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char initscr ();
| int
| main ()
| {
| return initscr ();
| ;
| return 0;
| }
configure:3475: result: no
error 4:
configure:3704: checking for Ncurses library
configure:3728: gcc -o conftest -static -static conftest.c -lncurses >&5
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_initscr.o): In function `initscr':
(.text+0x2): undefined reference to `_nc_globals'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_initscr.o): In function `initscr':
(.text+0xc): undefined reference to `stdscr'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_initscr.o): In function `initscr':
(.text+0x20): undefined reference to `_nc_globals'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_initscr.o): In function `initscr':
(.text+0x5a): undefined reference to `def_prog_mode'
...
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_echo.o): In function `echo':
(.text+0x3): undefined reference to `SP'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_echo.o): In function `noecho':
(.text+0x23): undefined reference to `SP'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libncurses.a(lib_pad.o): In function `pnoutrefresh':
(.text+0x11a): undefined reference to `_nc_screen_of'
collect2: error: ld returned 1 exit status
configure:3728: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "tig"
| #define PACKAGE_TARNAME "tig"
| #define PACKAGE_VERSION "0"
| #define PACKAGE_STRING "tig 0"
| #define PACKAGE_BUGREPORT "Jonas Fonseca <fonseca@diku.dk>"
| #define PACKAGE_URL ""
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_GETTIMEOFDAY 1
| #define HAVE_DECL_ENVIRON 0
| #define HAVE_DECL_ERRNO 1
| #define HAVE_MKSTEMPS 1
| #define HAVE_SETENV 1
| /* end confdefs.h. */
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char initscr ();
| int
| main ()
| {
| return initscr ();
| ;
| return 0;
| }
configure:3737: result: no
Thanks. Could you try adding -ltinfo
as suggested here http://www.linuxquestions.org/questions/programming-9/problems-statically-linking-c-program-to-ncurses-4175454273/#post4912877
I can pass compile process when I add -ltinfo
. but tig is still not statically linked.
when I change these line in configure file. tig is still not statically linked.
3440 LIBS="$ax_saved_LIBS -static -lncursesw -ltinfo"
3488 CURSES_LIB="-static -lncursesw -ltinfo"
but any way it works if I copy libncursesw.so.5
into mytoolschain lib.
errors:
but other ncurses dependent app can build statically, such as vim.