Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dvtm: vt.c:(.text+0x134e): undefined reference to `forkpty' #18

Open
githububub opened this issue Nov 11, 2016 · 4 comments
Open

dvtm: vt.c:(.text+0x134e): undefined reference to `forkpty' #18

githububub opened this issue Nov 11, 2016 · 4 comments

Comments

@githububub
Copy link

githububub commented Nov 11, 2016

Unable to build dvtm against netbsd-curses...

==> Starting build()...
cleaning
cleaning
dvtm build options:
CC dvtm.c
CC vt.c
CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
LDFLAGS = -lcurses
CC = cc
vt.c: In function ‘vt_forkpty’:
vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
chdir(cwd);
^~~~~~~~~~
CC -o dvtm
vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference to forkpty'
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: dvtm] Error 1
==> ERROR: A failure occurred in build().
Aborting...

Using the Sabotage build recipe as a guideline...

==> Starting build()...
cleaning
cleaning
dvtm build options:
CC dvtm.c
CC vt.c
CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
LDFLAGS = -lncurses
CC = cc
vt.c: In function ‘vt_forkpty’:
vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
chdir(cwd);
^~~~~~~~~~
CC -o dvtm
vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference to forkpty'
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: dvtm] Error 1
==> ERROR: A failure occurred in build().

With system LDFLAGS build failure...

==> Starting build()...
cleaning
cleaning
dvtm build options:
CC dvtm.c
CC vt.c
CFLAGS = -march=native -O2 -pipe -fstack-protector-all -fomit-frame-pointer -std=c99 -I. -DVERSION="0.15" -DNDEBUG -D_FORTIFY_SOURCE=2 -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_XOPEN_SOURCE_EXTENDED
LDFLAGS = -Wl,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro -lcurses -lterminfo
CC = cc
vt.c: In function ‘vt_forkpty’:
vt.c:1636:4: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
chdir(cwd);
^~~~~~~~~~
CC -o dvtm
vt.o: In function vt_forkpty': vt.c:(.text+0x134e): undefined reference to forkpty'
collect2: error: ld returned 1 exit status
make: *** [Makefile:25: dvtm] Error 1
==> ERROR: A failure occurred in build().
Aborting...

@rofl0r
Copy link
Member

rofl0r commented Nov 12, 2016

thanks, i updated dvtm package and made a number of fixes : sabotage-linux/sabotage@7e1f9c6

forkpty() is a function offered by libc, not by (n)curses. in musl it is in libc.so, but for GLIBC it may be needed to add -lutil to LDFLAGS (see https://linux.die.net/man/3/forkpty ).
so the entire LDFLAGS stanza for you would probably be -lcurses -lterminfo -lutil.

@githububub
Copy link
Author

githububub commented Nov 12, 2016

Build completed successfully with both -lutil -lcurses -lterminfo and -lc -lutil -lcurses -lterminfo. Thanks :) . This may be more of a dvtm issue so I posed a related question to the dvtm GitHub repo...

@rofl0r
Copy link
Member

rofl0r commented Jan 2, 2017

@githububub i pushed a new release 0.2.0 that should address all issues you've had. let me know how it goes, thanks.

@githububub
Copy link
Author

githububub commented Jan 2, 2017

Awesome. Will do when I get to a workstation :) . EDIT: I am not at a personal station so I cannot look into this much further, but running checksec against the binaries in the 0.2.0 build/package directory returns no canary for tabs:

$ checksec -d /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin
RELRO STACK CANARY NX PIE RPATH RUNPATH FORTIFY Checked Total Filename
Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 4 4 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/infocmp
Full RELRO No canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 1 1 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tabs
Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 4 7 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tic
Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 2 2 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tput
Full RELRO Canary found NX enabled PIE enabled No RPATH No RUNPATH Yes 2 4 /tmp/netbsd-curses/pkg/netbsd-curses/usr/bin/tset

But this is unrelated to the original issue and just an aside...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants