Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-14-2012, 06:13 PM
|
#1
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Rep: 
|
Undefined reference errors with static compile - dynamic works fine.
Trying to compile a program on Red Hat EL 6.2. It runs into "undefined reference" errors at link time. I've searched the web and attempted everything suggested. No luck.
One thing to note is it compiles fine when linked dynamically. It's only when we use the "-static" option it fails.
Also, the "-static" compile works fine on a CentOS 5.7 system.
Any suggestions beyond termcap and cuses libs are highly appreciated.
System info and errors follow. Note the "undefined reference" errors start in our own code, but then start lib the libcurses.a file.
Quote:
Library system info:
$ rpm -qa | grep curses
ncurses-5.7-3.20090208.el6.i686
ncurses-devel-5.7-3.20090208.el6.i686
ncurses-static-5.7-3.20090208.el6.i686
ncurses-base-5.7-3.20090208.el6.i686
ncurses-libs-5.7-3.20090208.el6.i686
$ rpm -qa | grep term
libtermcap-2.0.8-20.i386
termcap-9.12.6-15.i386
$ rpm -qa | grep gcc
libgcc-4.4.6-3.el6.i686
gcc-4.4.6-3.el6.i686
|
Quote:
Compile link errors:
/usr/bin/gcc [-I,<include directory>]... -O2 [-L<library path>]... -o <binary filename> [<object filename>]... [-l<libarary>].... -lcurses -static
dispproc.o: In function `prompt_pid':
dispproc.c .text+0x1d): undefined reference to `LINES'
dispproc.c(.text+0x3b): undefined reference to `COLS'
<... more .o files with undefined reference to `LINES` & `COLS` ...>
lib/libcursesutil.a(cursedfkeys.o): In function `initFkeyModule':
cursedfkeys.c: (.text+0x765): undefined reference to `cur_term'
cursedfkeys.c: (.text+0x7cc): undefined reference to `tparm'
cursedfkeys.c: (.text+0x7d4): undefined reference to `putp'
cursedfkeys.c: (.text+0xb2a): undefined reference to `tigetstr'
lib/libcursesutil.a(cursedfkeys.o): In function `initFkeyModule':
cursedfkeys.c: (.text+0xc60): undefined reference to `setupterm'
lib/libcursesutil.a(cursedwindow.o): In function `flushInput':
cursedwindow.c: (.text+0x127): undefined reference to `flushinp'
lib/libcursesutil.a(cursedwindow.o): In function `keypadOn':
cursedwindow.c: (.text+0x607): undefined reference to `keypad'
lib/libcursesutil.a(cursedwindow.o): In function `addChar':
lib/libcursesutil.a(cursedwindow.o): In function `resetShellMode':
cursedwindow.c: (.text+0x9f7): undefined reference to `reset_shell_mode'
lib/libcursesutil.a(cursedwindow.o): In function `resetProgramMode':
cursedwindow.c: (.text+0xa57): undefined reference to `reset_prog_mode'
lib/libcursesutil.a(cursedwindow.o): In function `defineShellMode':
cursedwindow.c: (.text+0xb47): undefined reference to `def_shell_mode'
lib/libcursesutil.a(cursedwindow.o): In function `defineProgramMode':
cursedwindow.c: (.text+0xba7): undefined reference to `def_prog_mode'
lib/libcursesutil.a(cursedshell.o): In function `cursed_shell_cmd':
lib/libcursesutil.a(cursedmisc.o): In function `enter_curses_mode':
cursedmisc.c: (.text+0x7e): undefined reference to `cbreak'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_addch.o): In function `waddch_nosync':
(.text+0xda): undefined reference to `unctrl'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_addch.o): In function `waddch_nosync':
(.text+0x4b2): undefined reference to `TABSIZE'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_addch.o): In function `_nc_waddch_nosync':
(.text+0x86c): undefined reference to `unctrl'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_addch.o): In function `_nc_waddch_nosync':
(.text+0x2c): undefined reference to `acs_map'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_box.o): In function `wborder':
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_box.o): (.text+0xc3): more undefined references to `acs_map' follow
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_delwin.o): In function `delwin':
(.text+0x21): undefined reference to `_nc_globals'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_delwin.o): In function `delwin':
(.text+0x99): undefined reference to `curscr'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_echo.o): In function `echo':
(.text+0x1): undefined reference to `SP'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_endwin.o): In function `endwin':
(.text+0x2f): undefined reference to `reset_shell_mode'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getch.o): In function `_nc_wgetch':
(.text+0x1ef): undefined reference to `_nc_keypad'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getch.o): In function `_nc_wgetch':
(.text+0x355): undefined reference to `_nc_timed_wait'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getch.o): In function `_nc_wgetch':
(.text+0xa2d): undefined reference to `_nc_handle_sigwinch'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getch.o): In function `_nc_wgetch':
(.text+0xa3d): undefined reference to `_nc_update_screensize'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getstr.o): In function `wgetnstr':
(.text+0x10d): undefined reference to `_nc_get_tty_mode'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getstr.o): In function `wgetnstr':
(.text+0x149): undefined reference to `noraw'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getstr.o): In function `wgetnstr':
(.text+0x151): undefined reference to `cbreak'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getstr.o): In function `wgetnstr':
(.text+0x156): undefined reference to `erasechar'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getstr.o): In function `wgetnstr':
(.text+0x15e): undefined reference to `killchar'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_getstr.o): In function `wgetnstrb:
(.text+0x2bc): undefined reference to `_nc_set_tty_mode'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_initscr.o): In function `initscr':
(.text+0x12): undefined reference to `stdscr'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_initscr.o): In function `initscr':
(.text+0x22): undefined reference to `_nc_globals'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_initscr.o): In function `initscr':
(.text+0x5d): undefined reference to `def_prog_mode'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_initscr.o): In function `initscr':
(.text+0x62): undefined reference to `stdscr'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `repeated_append':
(.text+0x45): undefined reference to `_nc_safe_strcat'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `_nc_mvcur_resume':
(.text+0x68): undefined reference to `cur_term'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `_nc_mvcur_resume':
(.text+0x7a): undefined reference to `putp'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `_nc_mvcur_resume':
(.text+0x7f): undefined reference to `cur_term'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `_nc_mvcur_resume':
(.text+0xaa): undefined reference to `tparm'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `_nc_mvcur_resume':
(.text+0xb2): undefined reference to `putp'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `_nc_mvcur_resume':
(.text+0xe8): undefined reference to `curs_set'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `_nc_msec_cost':
(.text+0x2af): undefined reference to `_nc_prescreen'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xa0b): undefined reference to `_nc_str_copy'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xa23): undefined reference to `cur_term'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xa55): undefined reference to `_nc_safe_strcat'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xc79): undefined reference to `_nc_str_init'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xc7f): undefined reference to `cur_term'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xce8): undefined reference to `SP'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xd20): undefined reference to `_nc_safe_strcat'
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../libcurses.a(lib_mvcur.o): In function `relative_move':
(.text+0xd4a): undefined reference to `cur_term'
...
|
|
|
|
02-15-2012, 02:48 AM
|
#2
|
LQ Guru
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 5,078
|
Please paste here the link-command...
|
|
|
02-16-2012, 03:40 PM
|
#3
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Original Poster
Rep: 
|
no command line link used
I didn't explicitly type a link command - gcc deals with that. And all the gcc options that are used to execute the link command are listed.
Here's gcc -v output:
Quote:
/usr/bin/gcc -I../includes [-I
<include dir>]... -D__USE_SVID -v -O2 [-L<lib dir>]... -o <binary filename> <.o object file>... -l<libraries>... -lcurses -static
Using built-in specs.
Target: i686-redhat-linux
Configured with: ../configure
--prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap
--enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch=i686
--build=i686-redhat-linux
Thread model: posix
gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
COMPILER_PATH=/usr/libexec/gcc/i686-redhat-linux/4.4.6/:/usr/libexec/gcc/i686-redhat-linux/4.4.6/:/usr/libexec/gcc/i686-redhat-linux/:/usr/lib/gcc/i686-redhat-linux/4.4.6/:/usr/lib/gcc/i686-redhat-linux/:/usr/libexec/gcc/i686-redhat-linux/4.4.6/:/usr/libexec/gcc/i686-redhat-linux/:/usr/lib/gcc/i686-redhat-linux/4.4.6/:/usr/lib/gcc/i686-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/i686-redhat-linux/4.4.6/:/usr/lib/gcc/i686-redhat-linux/4.4.6/:/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='[-I <include dir>]... '-D__USE_SVID' '-v' '-O2'
'-L/home/herbergj/swdev/RedLinux2632x86D06p_branchopt/share/lib'
'-L/home/herbergj/swdev/RedLinux2632x86D06p_branchopt/sos/share/lib'
'-L/home/herbergj/swdev/RedLinux2632x86D06p_branchopt/share/lib' '-o' 'cvhost' '-static' '-mtune=generic' '-march=i686'
/usr/libexec/gcc/i686-redhat-linux/4.4.6/collect2 --build-id -m elf_i386
--hash-style=gnu -static -o <binary filename>
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../crt1.o
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../crti.o
/usr/lib/gcc/i686-redhat-linux/4.4.6/crtbeginT.o [-L<librar path>]....
-L/usr/lib/gcc/i686-redhat-linux/4.4.6 -L/usr/lib/gcc/i686-redhat-linux/4.4.6
-L/usr/lib/gcc/i686-redhat-linux/4.4.6/../../.. -l<library>... -lcurses
--start-group -lgcc -lgcc_eh -lc --end-group
/usr/lib/gcc/i686-redhat-linux/4.4.6/crtend.o
/usr/lib/gcc/i686-redhat-linux/4.4.6/../../../crtn.o
|
|
|
|
02-17-2012, 02:20 AM
|
#4
|
LQ Guru
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 5,078
|
Then please paste the command you gave to gcc to perform linking...
|
|
|
02-17-2012, 10:20 AM
|
#5
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Original Poster
Rep: 
|
Maybe the fact that I've taken out the specifics that aren't applicable to the problem (or a solution  ) caused confusion. But the gcc command has been included in both posts.
Items specific to my files, my libraries, and my include directories aren't included, but what is emphasized below is that I'm already linking in the curses library (that's the only -l for a library not developed by me) and we're specifying "-static".
/usr/bin/gcc -I../includes [-I <include dir>]... -D__USE_SVID -v -O2 [-L<lib dir>]... -o <binary filename> <.o object file>... -l<libraries>... -lcurses -static
|
|
|
02-18-2012, 07:00 AM
|
#6
|
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339
|
As it’s working with a dynamic link, it can point to circular references between the libraries. They would then be need to be put in a group for static linking:
Code:
-Wl,--start-group <lib1> <lib2> -Wl,--end-group
<libn> can be absolute paths or referenced by the -l option ( man ld section “--start-group archives --end-group”).
|
|
|
02-18-2012, 05:53 PM
|
#7
|
Senior Member
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,823
|
I don't think there is a circular reference, just libcurses depends on libtermcap, try adding -ltermcap after -lcurses.
|
|
|
02-18-2012, 09:14 PM
|
#8
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Original Poster
Rep: 
|
Sadly, I have tried that one, but due to an error (and not understanding why a static compile would require a library that a dynamic does not), I gave-up on it. Assuming it will fix the problem though ...
where in the world can I find a static libtermcap library for Red Hat 6.2?
Output that shows current termcap libs installed & static compile error follow:
$ rpm -qa | grep termcap
libtermcap-2.0.8-20.i386
termcap-9.12.6-15.i386
$ ls /lib/*term*
/lib/libtermcap.so.2 /lib/libtermcap.so.2.0.8
Compile/link error with the "-static" option:
/usr/bin/ld: cannot find -ltermcap
collect2: ld returned 1 exit status
gmake: *** [cvhost] Error 1
|
|
|
02-18-2012, 11:29 PM
|
#9
|
Senior Member
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,823
|
Quote:
Originally Posted by John H.
not understanding why a static compile would require a library that a dynamic does not
|
Dynamic libraries pull in their dependencies automatically, but the same libraries are required in both cases.
Quote:
where in the world can I find a static libtermcap library for Red Hat 6.2?
|
(lib)termcap-devel, maybe?
|
|
|
02-19-2012, 02:03 PM
|
#10
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Original Poster
Rep: 
|
I would agree about the dynamic pulling dependencies in automatically, but the mystery is I didn't even have the termcap libs installed & the dynamic compile/link/execute of program all worked fine.
Will libtermcap* fix the static compile? I don't know, but I'm trying any option possible.
I'll let you know about the termcap-devel lib.
Thanks,
John
|
|
|
02-20-2012, 02:51 AM
|
#11
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Original Poster
Rep: 
|
Update
I encompassed every library being linked with the -Wl,--start-group <lib1> <lib2> -Wl,--end-group and it still has the same problem.
My search for a package that actually has a static termcap library continues.
- JWH
|
|
|
02-21-2012, 06:43 PM
|
#12
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Original Poster
Rep: 
|
Problem solved:
-lcurses -static doesn't cut it.
Either does -ltermcap.
What does is:
-lcurses -ltinfo -static
I'd guess libtinfo = terminfo library. terminfo replaced termcap.
John H.
|
|
1 members found this post helpful.
|
02-22-2012, 02:24 AM
|
#13
|
Senior Member
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339
|
Quote:
Originally Posted by John H.
I encompassed every library being linked with the -Wl,--start-group <lib1> <lib2> -Wl,--end-group and it still has the same problem.
|
You mean a list of all libraries you enclosed with the group statement, or each library in its own group?
|
|
|
02-22-2012, 04:31 AM
|
#14
|
LQ Newbie
Registered: Feb 2012
Posts: 8
Original Poster
Rep: 
|
I threw all the libraries in one group. Didn't matter. As my last post said, the problem was solved by linking in libtinfo - no group statement.
|
|
|
All times are GMT -5. The time now is 04:24 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|