How to build goncurses on os x, centos 6 - macos

OS X, Centos 6 and Debian Squeeze all come with v5.7 of ncurses, but the go wrapper "goncurses" requires 5.9. Trying to build it on any of those platforms will give you an error like this:
$ go get -v code.google.com/p/goncurses
code.google.com/p/goncurses
# code.google.com/p/goncurses
/tmp/go-build527609801/code.google.com/p/goncurses/_obj/goncurses.o:
In function 'ncurses_is_subwin':src/code.google.com/p/goncurses/goncurses.c:71: undefined reference to `is_subwin'
/tmp/go-build527609801/code.google.com/p/goncurses/_obj/goncurses.o:
In function 'ncurses_is_pad':src/code.google.com/p/goncurses/goncurses.c:63: undefined reference to `is_pad'
You can use homebrew to install ncurses v5.9 on os x, and build from source into /usr/local/ on linux, but how do you get go to use your upgraded ncurses when building?

#JimB answered my other question How to change lib path for "go build" with a suggestion to leverage pkg-config, which solution will look like this:
On CentOS 6 you can build ncurses from source like this, which will put the .pc files that drive pkg-config into your own directory instead of /usr/lib64/pkgconfig/
mkdir ~/local-pkg-config
PKG_CONFIG_LIBDIR=~/local-pkg-config ./configure --prefix=/usr/local/ --enable-pc-files --with-pkg-config
make && make install
On OS X you can install ncurses from homebrew. Homebrew usually puts .pc files along with the package, e.g. /usr/local/Cellar/pango/1.34.1/lib/pkgconfig/pango.pc. For some reason homebrew doesn't have any .pc files with its ncurses, but I successfully grabbed the CentOS ones into ~/local-pkg-config and changed them to suit:
## -1,7 +1,7 ##
-prefix=/usr/local/
+prefix=/usr/local/Cellar/ncurses/5.9/
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
-includedir=${prefix}/include/ncurses
+includedir=${prefix}/include
major_version=5
version=5.9.20110404
Now on either platform you're set up to go get the goncurses package:
PKG_CONFIG_PATH=~/local-pkg-config/ go get -v code.google.com/p/goncurses

This Gist is a modified ncurses formula for Homebrew that adds the .pc files to the keg. If you install ncurses with it, use the PKG_CONFIG_PATH environment variable to point pkg-config to the .pc files, before calling go build or go run.
$ export PKG_CONFIG_PATH=/usr/local/Cellar/ncurses/5.9/lib/pkgconfig
$ go run your_ncurses_program.go

Related

macOS Issue when installing geany plugins

I have been trying to install the Geany plugins since yesterday but unsuccessfully.
I am using a mac os Sierra version 10.12.6
I installed Geany 1.31 on my mac.
and here are the steps I follow to install the plugins:
1- I dowloaded the plugins folder
then on the terminal I type:
cd /Users/davidabitbol/Downloads/untitled\ folder/geany-plugins-1.31
then
./configure
and here it does not work. this is what I get:
Package geany was not found in the pkg-config search path.
Perhaps you should add the directory containing `geany.pc'
to the PKG_CONFIG_PATH environment variable
No package 'geany' found
checking for GEANY... no
configure: error: Package requirements (geany >= 1.29) were not met:
No package 'geany' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables GEANY_CFLAGS
and GEANY_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
I can't manage to solve this issue.
Any idea what should be done?
thanks

GO : unknown flag -trimpath

This is my first time with GO.
/* hello.go My first GOlang program */
package main
import "fmt"
func main() {
fmt.Printf("Hello World\n")
}
I am getting this error:
# command-line-arguments
/usr/local/go/pkg/tool/darwin_amd64/6g: unknown flag -trimpath
I am not able to understand what is the problem.
Apparently, this is related to the way go has been installed.
See GOlang Some Common Errors
after trying 1.3 meant “you need to unapck your .tar.gz file to /usr/local
http://golang.org/doc/install#tarball
One can not just install the golang 1.3 from the installer, you should try out the untar option for better results.
Errors found during :
brew install spiff
go install github.com/tools/godep
# github.com/kr/fs
/usr/local/go/pkg/tool/darwin_amd64/6g: unknown flag -trimpath
So follow the install section
Download the archive and extract it into /usr/local, creating a Go tree in /usr/local/go.
For example:
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
Choose the archive file appropriate for your installation. For instance, if you are installing Go version 1.3 for 64-bit x86 on Linux, the archive you want is called go1.3.linux-amd64.tar.gz.
Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile.
export PATH=$PATH:/usr/local/go/bin
To uninstall and start over: see Uninstall Go
To remove an existing Go installation from your system delete the go directory. This is usually /usr/local/go under Linux, Mac OS X, and FreeBSD or c:\Go under Windows.
You should also remove the Go bin directory from your PATH environment variable.
Under Linux and FreeBSD you should edit /etc/profile or $HOME/.profile. If you installed Go with the Mac OS X package then you should remove the /etc/paths.d/go file.

Golang zmq binding, ZMQ4, returns package error not finding file zmq.h

I am trying to include ZMQ sockets in a Go app but both zmq4 and gozmq (the referred ZMQ binding libraries for Go) are giving me problems. I would like to understand why zmq4 specifically isn't importable on my system.
I am running a Windows 8 system and I used the windows installer from the ZMQ website for version 4.0.3. I am primarily concerned about getting zmq4 set up and here is the result of my "go get" query on the github library's location:
> go get github.com/pebbe/zmq4
# github.com/pebbe/zmq4
polling.go:4:17: fatal error: zmq.h: No such file or directory
compilation terminated.
This issue is not alleviated by cloning the Github repository - the error remains the same.
I know the issue has to do with the C library zmq.h that is located in the "include" folder of my ZMQ installation, but whether the dependency is held up by a pathing issue or an external tool issue is a mystery to me.
A similar error has come up in regards to node.js and is the solution I see others referred to, outside of node scripting, but it was unsuccessful in my case.
I've so far included the path to the "include" folder in my PATH environment variable and previously placed zmq.h inside of the zmq4 top-level folder. I don't have much of an arsenal otherwise to understand this problem because I am new to C and C-importing packages in Go
I wanted to do the same thing, but on Windows 7, and here is what I had to do.
Since the Go bindings are using cgo to integrate with zeromq, you need zeromq built with gcc. There are no pre-built binaries, so you'll have to build them yourself, with mingw or similar, but this process is easier than it may sound, and nicely described on the zeromq site.
As #photoionized pointed out, C_INCLUDE_PATH and LIBRARY_PATH need to be set when building the Go bindings.
(In my case, I ran into a problem when compiling libzmq with IN6_ADDR not being defined. The only solution I found was, inspired by this issue, to manually add the line #include <in6addr.h> to the windows.hpp file.)
The Windows installer version of ZeroMQ won't work with zmq4, you need to compile from source with gcc, I recommend using MSYS2.
Install and update MSYS2 following the instructions from
http://sourceforge.net/p/msys2/wiki/MSYS2%20installation/
Start the mingw32_shell.bat or mingw64_shell.bat based on Go arch (32bit or 64bit)
pacman -S mingw-w64-(x86_64|i686)-toolchain make (x86_64 for 64bit, i686 for 32bit)
cd into zeromq src folder (C:\ path starts with /c/ inside the shell)
./configure
make
make install
CGO_CFLAGS=-I/usr/local/include CGO_LDFLAGS=-L/usr/local/lib go get github.com/pebbe/zmq4
Copy the following dlls and put them next to your go program (.exe):
/usr/local/bin/libzmq.dll
/mingw(32|64)/bin/libgcc*.dll
/mingw(32|64)/bin/libwinpthread*.dll
/mingw(32|64)/bin/libstdc++*.dll
Here's updated steps for #user2172816's MSYS2 solution:
Install and update MSYS2 following the instructions from http://sourceforge.net/p/msys2/wiki/MSYS2%20installation/
Start the mingw32_shell.bat or mingw64_shell.bat based on Go arch (32bit or 64bit)
pacman -S mingw-w64-(x86_64|i686)-toolchain make (x86_64 for 64bit, i686 for 32bit)
Add C:\msys64\mingw64\bin to your Path (pkg-config is there)
Restart the msys2 shell to get the new Path
Download and unzip libsodium source: https://github.com/jedisct1/libsodium/releases
cd into libsodium folder (C:\ path starts with /c/ inside the shell)
./configure --build=(x86_64|i686)-w64-mingw32
make
make install
Add /usr/local/lib to PKG_CONFIG_PATH (export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig)
cd into zeromq src folder
./configure --build=(x86_64|i686)-w64-mingw32
Add
#ifdef ZMQ_HAVE_MINGW32
#include <winsock2.h>
#include <windows.h>
#include "netioapi.h"
#endif
To the top of src/tcpaddress.cpp
make
make install
CGO_CFLAGS=-I/usr/local/include CGO_LDFLAGS=-L/usr/local/lib go get github.com/pebbe/zmq4
CGO_CFLAGS=-I/usr/local/include CGO_LDFLAGS=-L/usr/local/lib go build in your project directory
Copy the following dlls and put them next to your go program (.exe):
/usr/local/bin/libzmq.dll
/mingw(32|64)/bin/libgcc*.dll
/mingw(32|64)/bin/libwinpthread-*.dll
/mingw(32|64)/bin/libstdc++*.dll
/usr/local/bin/libsodium-*.dll
maybe? /usr/local/bin/libsodium-*.def
An updated answer using MSYS2.
Install MSYS2 MSYS2 installation guide.
Make sure to choose the correct installation 32bit or 64bit.
Open the appropriate shell MSYS2 MinGW 64-bit or MSYS2 MinGW 32-bit. All further steps assume you are using this shell.
Update packages following instructions at the installation guide.
Install libtool pacman -Sy libtool.
Download zmq source code to a location of your choice.
Navigate to the zmq source folder.
To generate the configure file, run the autogen tool by running ./autogen.sh.
In the probable case that step 8 fails:
Find the file at fault (probably version.sh).
Replace line endings by (replace file by the actual filename).
cp file file.bak
tr -d '\r' <file.bak> file
If this fails you'll have to dive in the code and find the problem.
Run the configure tool ./configure.
In the probable case of failure. Comment out empty else clauses in the configure file.
Add Go to Path: PATH=${PATH}:<go bin directory>.
Install Go Package: CGO_CFLAGS=-I/usr/local/include CGO_LDFLAGS=-L/usr/local/lib go get github.com/pebbe/zmq4
To install ZMQ in windows: Problem in Installing Golang ZMQ for windows - fatal error: czmq.h: No such file or directory
First of all, install the msys64. Download the software from https://www.msys2.org/ and install it on C:\msys64.
Then add C:\msys64\mingw64\bin to PATH environment variable of the windows.
Then run the following commands (in CMD) one by one.
pacman -Su
pacman -S --needed base-devel mingw-w64-x86_64-toolchain
pacman -S base-devel gcc vim cmake
pacman -S mingw-w64-x86_64-libsodium
pacman -S mingw-w64-x86_64-zeromq
Finally, run the Go install command:
go get github.com/pebbe/zmq4
Finished.

Solving the "No package 'json' found" error

I'm on Mac OS X Mountain Lion and a newbie to autotools and other GNU build tools. I'm trying to build a custom version of json-c to use with a a C project (axis2/c). After running the auto tools, and I run the configure command I get a failure with this output:
checking whether to use JSON... yes
checking for JSON... no
configure: error: Package requirements (json) were not met:
No package 'json' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables JSON_CFLAGS
and JSON_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
If I install json-c from macports, configure runs properly. Unfortunately, the project needs a later version of json-c, than what is available in macports (even though this is successful in the configure stage, it later results in a compilation error).
When I install this manually from source, I see that the libs are there in /usr/local/lib and header files in /usr/local/include/json-c. After removing any json-c files that came from macports, I tried copying these repective to the locations in /opt/local/lib and /opt/local/include/json-c but it still resulted in the same package not found error.
What does macports do differently that the package is 'found' when you run configure? Can I replicate the same when I manually install json-c from source?
Thanks in advance.
Macports creates a .pc file with under /opt/local/pkgconfig/. In this case it was json.pc. I edited that to point to the locations in /usr/local and the configure found and used the package I manually built from source.

Does installing gfortran with homebrew and with an installer create a conflict?

I was following an online tutorial to install some Python modules using homebrew and one step was to install gfortran with brew install gfortran. Later on, I tried using another third-party installation script to install some Python modules and after the fact I realized that part of what the script did was download and run http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg. I don't know that much about gfortran, but looking at the brew formula for gfortran it appears that brew uses a different version from the att.com one. Will that lead to problems in the future? I did brew uninstall gfortran and brew install gfortran again, and so far it seems like things are the same (I tried recompiling the old code that I had compiled before), but I am not sure what all the att.com pkg did. (I have OS X 10.8.2 and XCode 4.2 if that matters).
It depends on where the other gfortran installer goes to. In general, no, it won't conflict. * Homebrew is designed to be compatible with third-party gfortran installs - it defines dependencies on a generic "fortran" compiler, and not on the specific gfortran Homebrew formula. Homebrew stays under /usr/local, sticking the main install in /usr/local/Cellar, and symlinking judiciously in to /usr/local/lib. Other installers that install to /usr/local will just prevent Homebrew from linking its own compiler in, but will work with other formulas that use a fortran compiler. (Assuming the gfortran build options are compatible.)
That particular gcc-42 installer you linked to installs to /usr, not to /usr/local.** And its binaries are suffixed with "-4.2"; that is, it installs cpp-4.2, g++-4.2, gfortran-4.2, and so on. So a) there's no direct conflict with the Homebrew gfortran, and b) it won't directly shadow the /usr/local/bin/gfortran installed by Homebrew.
Which compiler will get picked up by things you build with both these gfortrans installed will depend on how the build works, but most will be looking for plain gfortran and so will find the Homebrew one, unless you explicitly direct them to the AT&T-provided one. You don't specify how you're building things, but since you're using brew, I'm assuming it's via brew or command line tools, in which case I think they're all probably seeing the Homebrew gfortran and ignoring this one. Look at the verbose output from their build processes to find out for sure.
*Depending, of course on what you mean by "conflict".
**Side note: AFAIK there's no easy way to figure this out by looking at the package or an installation manager. I just did a find /usr before and after running that installer, and did a diff on the output:
$ diff usr_before_any_installs.txt usr_after_att_install.txt | grep '^[<>]'
> /usr/bin/c++-4.2
> /usr/bin/cpp-4.2
> /usr/bin/g++-4.2
> /usr/bin/gcc-4.2
> /usr/bin/gfortran-4.2
> /usr/bin/i686-apple-darwin11-cpp-4.2.1
> /usr/bin/i686-apple-darwin11-g++-4.2.1
> /usr/bin/i686-apple-darwin11-gcc-4.2.1
> /usr/bin/i686-apple-darwin11-gfortran-4.2.1
> /usr/include/gcc
> /usr/include/gcc/darwin
> /usr/include/gcc/darwin/4.2
...

Resources