digitalmars.D.learn - Get and set terminal size
- Denis Mezhov (16/16) Apr 19 2014 I want use tgetnum for get terminal size
- Adam D. Ruppe (3/3) Apr 19 2014 Try adding -lncurses or -lcurses to the command line. tgetnum is
- Denis Mezhov (4/7) Apr 19 2014 Error: unrecognized switch '-lcurses'
- Adam D. Ruppe (3/3) Apr 19 2014 Blargh, I don't know teh ldc switch for it :(
- Denis Mezhov (6/9) Apr 19 2014 pragma(lib, "curses");
- FreeSlave (4/4) Apr 19 2014 What are compiler and platform do you use? Probably you are
- FreeSlave (14/14) Apr 19 2014 I use
- Mike Parker (2/4) Apr 19 2014 And, more importantly, are nul terminated.
- Denis Mezhov (2/16) Apr 20 2014 It's work) Thanks.
I want use tgetnum for get terminal size http://www.mkssoftware.com/docs/man3/curs_termcap.3.asp extern(C): int tgetnum(const(char) *capname); calling a method from main writeln(tgetnum(toStringz("li"))); I receive an error message Undefined symbols for architecture x86_64: "_tgetnum", referenced from: _main in RSConsole.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Does anyone know what the problem is? Maybe there are other methods to get and set sizes of the Mac OS X console?
Apr 19 2014
Try adding -lncurses or -lcurses to the command line. tgetnum is found in the curses library which isn't linked in automatically by default.
Apr 19 2014
On Saturday, 19 April 2014 at 09:59:39 UTC, Adam D. Ruppe wrote:Try adding -lncurses or -lcurses to the command line. tgetnum is found in the curses library which isn't linked in automatically by default.Error: unrecognized switch '-lcurses' Error: unrecognized switch '-lncurses' :((
Apr 19 2014
Blargh, I don't know teh ldc switch for it :( Try adding pragma(lib, "curses"); (or ncurses) to your file with main in it, i think ldc supports that.
Apr 19 2014
On Saturday, 19 April 2014 at 10:39:43 UTC, Adam D. Ruppe wrote:Blargh, I don't know teh ldc switch for it :( Try adding pragma(lib, "curses"); (or ncurses) to your file with main in it, i think ldc supports that.pragma(lib, "curses"); extern(C): int tgetnum(const(char) *capname); hmm segfault error :( Segmentation fault: 11
Apr 19 2014
What are compiler and platform do you use? Probably you are trying to link with 64-bit library while being on 32-bit OS (or vice versa) It works fine on my 32-bit Debian with ldc2 and dmd.
Apr 19 2014
I use ldc2 main.d -L-lcurses or dmd main.d -L-lcurses and following source code: import std.stdio; extern(C) int tgetnum(const(char) *id); int main() { writeln(tgetnum("li")); return 0; } Note that you don't need to apply toStringz to string literals since they implicitly cast to const char*.
Apr 19 2014
On 4/19/2014 9:06 PM, FreeSlave wrote:Note that you don't need to apply toStringz to string literals since they implicitly cast to const char*.And, more importantly, are nul terminated.
Apr 19 2014
On Saturday, 19 April 2014 at 12:06:58 UTC, FreeSlave wrote:I use ldc2 main.d -L-lcurses or dmd main.d -L-lcurses and following source code: import std.stdio; extern(C) int tgetnum(const(char) *id); int main() { writeln(tgetnum("li")); return 0; } Note that you don't need to apply toStringz to string literals since they implicitly cast to const char*.It's work) Thanks.
Apr 20 2014