Comments (26)
Please update to the latest go1 release or tip and retry. It is also possible
that your version of ncurses.h defines has_mouse() as a macro which cgo does
not play nicely with. What version of ncurses do you have installed? Can you
grep ncurses.h for has_mouse and determine if has_mouse() has been defined as a
macro?
Original comment by [email protected]
on 20 Jun 2012 at 2:58
- Added labels: OpSys-OSX, Component-Core
from goncurses.
go version weekly.2012-03-27 +d13076ae2f82 is the head of hg and is considered
to be ahead of go1.0.2
Well it seems that ncurses comes with mac does not contain any thing about
has_mouse.
Then I tried to compile my own libncurses with version 5.9 and then change the
curses.go as bellow
// #cgo LDFLAGS: -L/usr/local/lib -I/usr/local/include -lncurses
// #include <ncurses/ncurses.h>
Then try build again and get errors like:
form.go:336[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/c
ode.google.com/p/goncurses/_obj/form.cgo1.go:325]: cannot use w.win (type
*_Ctype_WINDOW) as type *[0]byte in function argument
form.go:342[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/c
ode.google.com/p/goncurses/_obj/form.cgo1.go:332]: cannot use w.win (type
*_Ctype_WINDOW) as type *[0]byte in function argument
form.go:348[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/c
ode.google.com/p/goncurses/_obj/form.cgo1.go:339]: cannot use
_Cfunc_form_sub(f.form) (type *[0]byte) as type *_Ctype_WINDOW in field value
menu.go:299[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/c
ode.google.com/p/goncurses/_obj/menu.cgo1.go:294]: cannot use w.win (type
*_Ctype_WINDOW) as type *[0]byte in function argument
menu.go:314[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/c
ode.google.com/p/goncurses/_obj/menu.cgo1.go:315]: cannot use sub.win (type
*_Ctype_WINDOW) as type *[0]byte in function argument
menu.go:326[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/c
ode.google.com/p/goncurses/_obj/menu.cgo1.go:329]: cannot use
_Cfunc_menu_win(m.menu) (type *[0]byte) as type *_Ctype_WINDOW in field value
panel.go:56[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/c
ode.google.com/p/goncurses/_obj/panel.cgo1.go:19]: cannot use w.win (type
*_Ctype_WINDOW) as type *[0]byte in function argument
panel.go:120[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/
code.google.com/p/goncurses/_obj/panel.cgo1.go:89]: cannot use w.win (type
*_Ctype_WINDOW) as type *[0]byte in function argument
panel.go:144[/var/folders/ps/fg9q9gq50gx_dxcfg7r8rlzw0000gn/T/go-build799170292/
code.google.com/p/goncurses/_obj/panel.cgo1.go:116]: cannot use
_Cfunc_panel_window(p.pan) (type *[0]byte) as type *_Ctype_WINDOW in field value
Original comment by [email protected]
on 20 Jun 2012 at 3:15
from goncurses.
Since the release of go1 they no longer maintaining the 'weekly' releases.
'tip' is considered the latest post-go1.0.2:
tip 13624:b7a1cd9f1a6c
release 13231:5e806355a9e1
go1.0.2 13231:5e806355a9e1
go1.0.1 12995:2ccfd4b451d3
go1 12872:920e9d1ffd1f
weekly.2012-03-27 12869:dc5e410f0b4c
It seems that now the ncurses extensions (form, menu and panel) are causing you
issue. You you tried changing the cgo flags to reflect your new installation of
ncurses for the other libraries? I have been toying with the idea of separating
these libraries from the ncurses core rather than bundling them. This would
enforce an import of .../goncurses/form for example. This would at least let
you use the ncurses portion of the library.
After a great deal of searching, it appears that ncurses 5.7 is the most
current version of ncurses on MacOS X. In 5.8 [1], has_mouse() was added which
is why it did not work on your system. I will make a note in the wiki regarding
this issue.
[1] http://invisible-island.net/ncurses/announce-5.8.html
Original comment by [email protected]
on 21 Jun 2012 at 1:38
from goncurses.
I just installed ncurses 5.9 using Homebrew and I'm still getting the
'has_mouse' undeclared error.
NOTE: I had to apply the patch from this thread to get ncurses to install
successfully:
http://lists.gnu.org/archive/html/bug-ncurses/2011-04/msg00002.html
$ brew list --versions go
go 1.0.2
$ brew list --versions ncurses
ncurses 5.9
$ go get code.google.com/p/goncurses
# code.google.com/p/goncurses
error: 'has_mouse' undeclared (first use in this function)
error: (Each undeclared identifier is reported only once
Here's a relevant grep:
$ grep -r has_mouse .
./curses.h:extern NCURSES_EXPORT(bool) has_mouse(void);
./curses.h:extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*);
./cursesw.h:extern "C" int _nc_has_mouse(void);
./cursesw.h: bool has_mouse() const;
./ncurses.h:extern NCURSES_EXPORT(bool) has_mouse(void);
./ncurses.h:extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*);
Original comment by [email protected]
on 11 Jul 2012 at 4:25
from goncurses.
I've implemented a potential fix for this issue. Forms, Menu and Panel are now
separated from the main library and will now need to be imported individually.
Second, I've created a work-around for has_mouse. Hopefully this will solve the
issue as I have no way of testing it myself.
Original comment by [email protected]
on 12 Jul 2012 at 3:47
- Changed state: Started
from goncurses.
Thanks for looking into this.
I'm getting a different error now:
$ go get -u code.google.com/p/goncurses
# code.google.com/p/goncurses
cc1: warnings being treated as errors
ncurses.go: In function 'ncurses_has_mouse':
ncurses.go:48: warning: implicit declaration of function 'has_mouse'
Original comment by [email protected]
on 12 Jul 2012 at 4:28
from goncurses.
The implicit declaration error usually indicates that a C function declaration
is missing but your grep would indicate otherwise. It's possible that this is a
clang/llvm issue, or a cgo issue on OSX, but I can't say for certain. I'll
continue to research to see what might be the issue.
Original comment by [email protected]
on 13 Jul 2012 at 3:27
from goncurses.
Thanks! Let me know if there's anything other info about my system that would
be helpful.
Also, I'll try to apply the post-5.9 patches to my ncurses library and see if
that makes a difference.
Original comment by [email protected]
on 13 Jul 2012 at 3:31
from goncurses.
Can you try writing an ncurses program in C to verify has_mouse() works
natively?
Original comment by [email protected]
on 13 Jul 2012 at 3:33
from goncurses.
I copied the hello world example, compiled, and ran it without error:
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html
But my C foo is weak, and I'm guessing it linked against the system version of
ncurses (5.7.20081102). How do I force it to link against 5.9?
Original comment by [email protected]
on 13 Jul 2012 at 3:39
from goncurses.
Looks like '-include' is what I needed:
$ gcc -include /usr/local/Cellar/ncurses/5.9/include/ncurses/ncurses.h hello.c
Undefined symbols for architecture x86_64:
"_initscr", referenced from:
_main in ccDlKAbl.o
"_printw", referenced from:
_main in ccDlKAbl.o
"_stdscr", referenced from:
_main in ccDlKAbl.o
"_wrefresh", referenced from:
_main in ccDlKAbl.o
"_wgetch", referenced from:
_main in ccDlKAbl.o
"_endwin", referenced from:
_main in ccDlKAbl.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I haven't applied the various ncurses patches yet. Doing that next.
Original comment by [email protected]
on 13 Jul 2012 at 3:47
from goncurses.
I applied the following rollup patch:
ftp://invisible-island.net/ncurses/5.9/ncurses-5.9-20120616-patch.sh.bz2
It didn't address the has_mouse issue. :(
Original comment by [email protected]
on 13 Jul 2012 at 4:10
from goncurses.
Similar output from clang:
$ clang -I/usr/local/Cellar/ncurses/5.9/include/ncurses/ncurses.h hello.c
Undefined symbols for architecture x86_64:
"_initscr", referenced from:
_main in hello-13MyQM.o
"_printw", referenced from:
_main in hello-13MyQM.o
"_stdscr", referenced from:
_main in hello-13MyQM.o
"_wrefresh", referenced from:
_main in hello-13MyQM.o
"_wgetch", referenced from:
_main in hello-13MyQM.o
"_endwin", referenced from:
_main in hello-13MyQM.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I assume this means I'm mixing 32 and 64 bit code, but I'm not sure what to do
about it.
Original comment by [email protected]
on 13 Jul 2012 at 4:55
from goncurses.
Run the following on that hello world example, if it successfully linked and
compiled, (assumes binary is named 'a.out'; if you used -o flag replace a.out
with whatever you named the binary) in order to see what library was linked
against it:
$ldd a.out | grep curses
It will be something akin to /usr/lib/libncursesw.so.5 but this is likely a
symbolic link. Use:
$ls -l /usr/lib/libncursesw.so.5
To find out what it links to. If the result is libncursesw.so.5.9 then it's
linking against your updated library.
I would also be interested to know the output of:
$pkg-config ncurses --modversion
...if any. I don't know if OSX has pkg-config installed or if homebrew installs
a .pc file for ncurses. If the reported version is 5.9 then I may be able to
leverage pkg-config to at least ensure the correct library is used.
Original comment by [email protected]
on 13 Jul 2012 at 5:34
from goncurses.
There's no ldd in OS X, but there is otool.
The hello world that works is linked against the version of ncurses that comes
with OS X, not with the Homebrew version:
$ gcc hello.c -lncurses
$ otool -L a.out |grep curses
/usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
ls -l /usr/lib/libncurses.5.4.dylib
-rwxr-xr-x 1 root wheel 546K Oct 8 2011 /usr/lib/libncurses.5.4.dylib*
pkg-config is in OS X, but not helpful in this case:
$ pkg-config ncurses --modversion
Package ncurses was not found in the pkg-config search path.
Perhaps you should add the directory containing `ncurses.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ncurses' found
I can't figure out how to link hello.c against the Homebrew version of ncurses.
I keep getting "Undefined symbols for architecture" errors.
Original comment by [email protected]
on 13 Jul 2012 at 2:57
from goncurses.
To link against a specific library, simply include the library in the
objects/sources to compile. Example:
$gcc -o hello hello.c /usr/lib/libncurses.so.5.9
Judging by the fact that your system is linking against the 5.7 ncurses
previously installed on your system, go/cgo will too. This is probably why
has_mouse() is still undefined/unresolved. If this is the case and you can
successfully compile and run the C code, the simplest way to make the change
permanent is to alter the libncurses.so symlink to point to the 5.9 version.
Please take this advice at your own risk. If this works, I highly recommend you
contact the homebrew people to see if they can create a fix for this.
Please let me know the result so I can either close this issue or continue to
research another solution.
Original comment by [email protected]
on 16 Jul 2012 at 2:32
from goncurses.
Sorry for the delay, I wasn't notified (or perhaps didn't see a notification)
of your last comment.
I was able to get the example to successfully compile with the latest version
of ncurses by specifying the path as you advised:
$ gcc -o hello hello.c /usr/local/lib/libncurses.dylib
$ otool -L hello
hello:
/usr/local/lib/libncurses.5.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
After modifying the libncurses symlinks in /usr/lib to point /usr/local/lib. I
was again able to successfully compile against the latest ncurses, this time
without specifying the path:
$ gcc -o hello hello.c -lncurses
$ otool -L hello
hello:
/usr/local/lib/libncurses.5.dylib (compatibility version 5.0.0, current version 5.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
However, "go get" still wasn't working:
$ go get -u code.google.com/p/goncurses
# code.google.com/p/goncurses
cc1: warnings being treated as errors
ncurses.go: In function 'ncurses_has_mouse':
ncurses.go:20: warning: implicit declaration of function 'has_mouse'
So I cloned this repo (http://code.google.com/r/gcatlin-goncurses/), added an
absolute path to the #include (http://goo.gl/6htPe), pushed it, then ran go get
on the cloned repo:
$ go get -u code.google.com/p/gcatlin-goncurses
There was no output that time. A simple test (which may be worth adding to your
home page) confirmed that it installed successfully:
---
package main
import goncurses "code.google.com/p/gcatlin-goncurses"
func main() {
w, _ := goncurses.Init()
defer goncurses.End()
w.Print("Hello World! Press any key to quit.")
w.Refresh()
w.GetChar()
}
---
Clearly, my solution is not tenable, but it may be worth documenting as a
work-around.
Original comment by [email protected]
on 23 Jul 2012 at 3:01
from goncurses.
I have just pushed an alternative fix that should allow goncurses to build on
ncurses 5.7. I will also update the wiki to include your work-around, or
something similar, since it would be preferable if users linked against version
5.9.
Original comment by [email protected]
on 24 Jul 2012 at 1:56
from goncurses.
Wiki has been updated and the issue is considered closed.
Original comment by [email protected]
on 25 Jul 2012 at 1:21
- Changed state: Fixed
from goncurses.
First, let me express my appreciation for working with me on trying to resolve
this issue. Thank you!
Second and unfortunately, it is still not working, although it appears to be
getting closer:
$ go get -u code.google.com/p/goncurses
# code.google.com/p/goncurses
window.go:250[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build629847214
/code.google.com/p/goncurses/_obj/window.cgo1.go:272]: w.win._cury undefined
(type *[0]byte has no field or method _cury)
window.go:250[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build629847214
/code.google.com/p/goncurses/_obj/window.cgo1.go:272]: w.win._curx undefined
(type *[0]byte has no field or method _curx)
window.go:263[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build629847214
/code.google.com/p/goncurses/_obj/window.cgo1.go:287]: w.win._clear undefined
(type *[0]byte has no field or method _clear)
window.go:268[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build629847214
/code.google.com/p/goncurses/_obj/window.cgo1.go:293]: w.win._use_keypad
undefined (type *[0]byte has no field or method _use_keypad)
window.go:285[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build629847214
/code.google.com/p/goncurses/_obj/window.cgo1.go:312]: w.win._maxy undefined
(type *[0]byte has no field or method _maxy)
window.go:285[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build629847214
/code.google.com/p/goncurses/_obj/window.cgo1.go:312]: w.win._maxx undefined
(type *[0]byte has no field or method _maxx)
window.go:322[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build629847214
/code.google.com/p/goncurses/_obj/window.cgo1.go:354]: w.win._parent undefined
(type *[0]byte has no field or method _parent)
Original comment by [email protected]
on 25 Jul 2012 at 3:05
from goncurses.
[deleted comment]
from goncurses.
I have pushed some changes which should fix these additional issues. Let me
know if this works!
Original comment by [email protected]
on 27 Jul 2012 at 1:49
from goncurses.
Almost there.
$ go get -u code.google.com/p/goncurses
# code.google.com/p/goncurses
window.go:326[/var/folders/s5/fg_990bd4qn035mcbx8r41vm0000gn/T/go-build763017235
/code.google.com/p/goncurses/_obj/window.cgo1.go:359]: w.win._parent undefined
(type *[0]byte has no field or method _parent)
Original comment by [email protected]
on 27 Jul 2012 at 4:02
from goncurses.
Pushed a fix for this. Hopefully this will be the final issue.
If this works, you could consider trying to enable one of the extensions, panel
would probably be the best choice, by modifying panel_posix.go and adding
'darwin' to the list of platforms in the +build section. If it fails, please
open a separate issue.
Original comment by [email protected]
on 28 Jul 2012 at 9:25
from goncurses.
It works! Thanks for your persistence.
I'll look into enabling the extensions.
Original comment by [email protected]
on 30 Jul 2012 at 3:40
from goncurses.
Original comment by [email protected]
on 30 Jul 2012 at 2:12
- Changed state: Verified
from goncurses.
Related Issues (20)
- UTF-8 support HOT 3
- Thread safety HOT 2
- Build fails with "invalid flag in pkg-config" HOT 6
- Update wiki about KEY_RESIZE HOT 1
- go build issue HOT 1
- Compilation error when using REQ_LEFT
- pkgconfig problem HOT 8
- invalid flag in pkg-config HOT 1
- Convert project to Go mods
- Resizing without reinitializing?
- UTF-8 support is wrong HOT 4
- LINES and COLS? HOT 2
- About window scrolling HOT 2
- Examples fail to build: int is not MenuDriverReq
- Go get with M1 mac fails HOT 6
- Changing colors within MenuItems HOT 1
- Build fail: `lvalue required as left operand of assignment` HOT 5
- multi language support HOT 2
- Can't run audio with goncursers HOT 2
- Can't run Audio with Goncursers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goncurses.