`nix-env -i stack` failed on Mac OS X - haskell-stack

Because of this problem, and some one told me that I should install stack and cabal-install using nix, so I am now trying to install haskell-stack using nix-env -i.
Whole error messages are here.
$ nix-env -i stack
...
lib/machserver.cpp:180:27: note: put the semicolon on a separate line to silence this warning
In file included from lib/alloc.cpp:32:
In file included from ./security_utilities/globalizer.h:31:
In file included from ./security_utilities/threading.h:40:
./security_utilities/threading_internal.h:67:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if _HAVE_64BIT_ATOMIC
^
./security_utilities/threading_internal.h:41:29: note: expanded from macro '_HAVE_64BIT_ATOMIC'
#define _HAVE_64BIT_ATOMIC (defined(__ppc64__) || defined(__i386__) || defined(__x86_64__))
^
./security_utilities/threading_internal.h:67:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
./security_utilities/threading_internal.h:41:51: note: expanded from macro '_HAVE_64BIT_ATOMIC'
#define _HAVE_64BIT_ATOMIC (defined(__ppc64__) || defined(__i386__) || defined(__x86_64__))
^
./security_utilities/threading_internal.h:67:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
./security_utilities/threading_internal.h:41:72: note: expanded from macro '_HAVE_64BIT_ATOMIC'
#define _HAVE_64BIT_ATOMIC (defined(__ppc64__) || defined(__i386__) || defined(__x86_64__))
^
./security_utilities/threading_internal.h:119:50: warning: while loop has empty body [-Wempty-body]
{ while (!casb(store, value, store)) /* again */; return value; }
^
./security_utilities/threading_internal.h:119:50: note: put the semicolon on a separate line to silence this warning
4 warnings generated.
4 warnings generated.
4 warnings generated.
5 warnings generated.
make[2]: *** [/nix/store/204lvxmsigkgkdv2c0fvkqalxmg4fik5-gnustep-make-2.7.0/share/GNUstep/Makefiles/Instance/library.make:278: internal-library-all_] Error 2
make[1]: *** [/nix/store/204lvxmsigkgkdv2c0fvkqalxmg4fik5-gnustep-make-2.7.0/share/GNUstep/Makefiles/Master/rules.make:297: security_utilities.all.library.variables] Error 2
make: *** [/nix/store/204lvxmsigkgkdv2c0fvkqalxmg4fik5-gnustep-make-2.7.0/share/GNUstep/Makefiles/Master/library.make:37: internal-all] Error 2
builder for '/nix/store/xxja1zlr9xqvl4vij85lcf30h5s6yyi5-libsecurity_utilities-osx-10.7.5.drv' failed with exit code 2
cannot build derivation '/nix/store/g2i0xac4g4173561i5lsgn7pncswzmqd-SecurityTool-55115.drv': 1 dependencies couldn't be built
copying path '/nix/store/b5j4s3wmh2bji4ck8wrvizh5knfnw4mw-pem-0.2.4' from 'https://cache.nixos.org'...
cannot build derivation '/nix/store/ss179ilk0x4yb6z1dks3aa9z5b0bzih5-x509-system-1.6.6.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/7f4a2s6ri62dm37md14wxla62hygxg0z-connection-0.2.8.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/lg6k2p3v4sfj6w9kb3bapizzr8qk3i3p-http-client-tls-0.3.5.3.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/djqw65b0cnlpdfpadxhnqr344qrwdqa9-stack-1.9.1.drv': 1 dependencies couldn't be built
error: build of '/nix/store/djqw65b0cnlpdfpadxhnqr344qrwdqa9-stack-1.9.1.drv' failed
and
$ uname -a
Darwin YudeMBP.local 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct 5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64
How to fix this?

It looks like you are trying to install stack from a Nixpkgs version with a broken dependency of stack.
You can see build age and links to their statuses in HowOldIs.
To change the channel you're installing from, use the nix-channel command.
For example:
# add the config
nix-channel --add https://nixos.org/channels/nixpkgs-18.09-darwin nixpkgs
# download the latest nix expressions
nix-channel --update

Related

Calling Octave interpreter from C - Problems compiling and running example

I'm trying to implement calling octave from C, as per the example shown in this answer Call GNU Octave functions in C?
I'm trying this in Nebeans on Linux.
I've created the files calloctave.cc, calloctave.h, main.c and myfunction.m as per the example. Pointed the links and includes to the correct places (in my case /usr/include/octave-5.2.0/octave/ and /usr/lib64/octave/5.2.0 ). I've chosen C++11 as the standard. In the code, there are no errors highlighted and it seems to find everything it needs, and nothing is highlighted as missing.
When I try to compile it, I just get a series of errors as follows....
cd '/home/arwel/NetBeansProjects/callOctave_new'
/bin/gmake -f Makefile CONF=Debug
"/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/arwel/NetBeansProjects/callOctave_new'
"/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux/libcallOctave_new.so
gmake[2]: Entering directory `/home/arwel/NetBeansProjects/callOctave_new'
mkdir -p build/Debug/GNU-Linux
rm -f "build/Debug/GNU-Linux/calloctave.o.d"
g++ -c -g -I/usr/include/octave-5.2.0/octave -include /usr/include/octave-5.2.0/octave/mex.h -std=c++11 -fPIC -MMD -MP -MF "build/Debug/GNU-Linux/calloctave.o.d" -o build/Debug/GNU-Linux/calloctave.o calloctave.cc
In file included from /usr/include/octave-5.2.0/octave/Cell.h:33:0,
from /usr/include/octave-5.2.0/octave/gtk-manager.h:32,
from /usr/include/octave-5.2.0/octave/interpreter.h:36,
from calloctave.cc:7:
/usr/include/octave-5.2.0/octave/ov.h:52:7: error: using typedef-name ‘mxArray’ after ‘class’
class mxArray;
^
In file included from <command-line>:0:0:
/usr/include/octave-5.2.0/octave/mex.h:55:14: note: ‘mxArray’ has a previous declaration here
typedef void mxArray;
^
In file included from /usr/include/octave-5.2.0/octave/ov.h:62:0,
from /usr/include/octave-5.2.0/octave/Cell.h:33,
from /usr/include/octave-5.2.0/octave/gtk-manager.h:32,
from /usr/include/octave-5.2.0/octave/interpreter.h:36,
from calloctave.cc:7:
/usr/include/octave-5.2.0/octave/ov-base.h:57:7: error: using typedef-name ‘mxArray’ after ‘class’
class mxArray;
^
In file included from <command-line>:0:0:
/usr/include/octave-5.2.0/octave/mex.h:55:14: note: ‘mxArray’ has a previous declaration here
typedef void mxArray;
^
calloctave.cc: In function ‘int mexCallOctave(int, mxArray**, int, mxArray**, const char*)’:
calloctave.cc:26:15: error: ‘mxArray’ is not a class, namespace, or enumeration
args(i) = mxArray::as_octave_value (argin[i]);
^
calloctave.cc:42:41: error: invalid use of ‘mxArray {aka void}’
argout[i] = new mxArray (retval(i));
^
calloctave.cc: In function ‘void free_arg_list(int, mxArray**)’:
calloctave.cc:56:29: warning: deleting ‘mxArray* {aka void*}’ is undefined [enabled by default]
delete arglist[i];
^
gmake[2]: *** [build/Debug/GNU-Linux/calloctave.o] Error 1
gmake[2]: Leaving directory `/home/arwel/NetBeansProjects/callOctave_new'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/arwel/NetBeansProjects/callOctave_new'
gmake: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
It seems to be not understanding the mex interface in some way. I'm not very knowledgeable about C/C++, so am at a loss as to how to proceed here. What could be causing these errors and how might I resolve them?

How to full (with all features - ACL support / Xattr support / xxhash library/ zstd library) install (compiling) rsync v3.2.3 on Mac?

I am trying to install rsync 3.2.3 on Mac by compiling it. But, I would like to install with all features. For that, it needs some libraries which in here (https://download.samba.org/pub/rsync/INSTALL) does not explain how can I install and/or compile them.
By the way, when I "./prepare-source", I get this message:
make: Nothing to be done for `conf'.
Is this right?
By running "./configure" I get this message:
Configure found the following issues:
Failed to find openssl/md4.h and openssl/md5.h for openssl crypto lib support.
Failed to find xxhash.h for xxhash checksum support.
Failed to find zstd.h for zstd compression support.
Failed to find lz4.h for lz4 compression support.
See the INSTALL file for hints on how to install the missing libraries and/or
how to generate (or fetch) man pages:
https://github.com/WayneD/rsync/blob/master/INSTALL.md
To disable one or more features, the relevant configure options are:
--disable-openssl
--disable-xxhash
--disable-zstd
--disable-lz4
configure.sh: error: Aborting configure run
So, like I said before, I would like to install all the features (ACL support / Xattr support / xxhash library/ zstd library).
Helps are very apreciated!
Thanks in advance!
First, install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
And then execute the following command:
brew install xxhash; brew install zstd; brew install lz4; brew install openssl;
export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib";
export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include";
echo 'export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"' >> ~/.zshrc;
Try again to execute:
./configure
UPDATE -- 06/05/2021
You can try to paste the following script into the terminal and run:
cd ~/Desktop;
curl -OL https://github.com/Cyan4973/xxHash/archive/v0.8.0.tar.gz;
tar -xvf v0.8.0.tar.gz;
cd xxHash-0.8.0;
make -j4;
sudo make install;
cd ~/Desktop;
curl -OL https://github.com/lz4/lz4/archive/v1.9.3.tar.gz;
tar -xvf v1.9.3.tar.gz;
cd lz4-1.9.3;
make -j4;
sudo make install;
cd ~/Desktop;
curl -OL https://www.openssl.org/source/openssl-1.1.1k.tar.gz;
tar -xvf openssl-1.1.1k.tar.gz;
cd openssl-1.1.1k ;
./config;
make -j4;
sudo make install;
cd ~/Desktop;
curl -OL https://github.com/facebook/zstd/archive/v1.5.0.tar.gz;
tar -xvf v1.5.0.tar.gz;
cd zstd-1.5.0 ;
make -j4;
sudo make install;
cd ~/Desktop;
curl -OL https://rsync.samba.org/ftp/rsync/src/rsync-3.2.3.tar.gz;
tar -xvf rsync-3.2.3.tar.gz;
cd rsync-3.2.3;
./configure;
make -j4;
sudo make install;
cd /usr/local/bin;
./rsync --version;
Finding all the software package source code download url is a tedious job. If you are a "script purist," you can indeed do this. But I think Homebrew can really free the programmer's hands and get rid of the nightmare of "submerged in the ocean of curl and printlog".
How do I know the download url of each package? Google a few days, in the end still have to refer to the Homebrew formulae Code:
xxhash:https://formulae.brew.sh/formula/xxhash#default
lz4: https://formulae.brew.sh/formula/lz4#default
openssl1.1: https://formulae.brew.sh/formula/openssl#1.1#default
zstd: https://formulae.brew.sh/formula/zstd#default
While I think that #Janyee gave the correct answer and should get credited, maybe this helps others that ran into a similar issue of library linking errors, too.
Compiling rsync 3.2.4 (the same happens for rsync 3.2.3) on macOS 10.12.x Sierra with manual installed external libraries xxHash, zstd, lz4, openssl, popt, zlib in non standard folders gave the following error on make, even though ./configure reported rsync 3.2.4 configuration successful:
$ make
awk -f ./daemon-parm.awk ./daemon-parm.txt
awk -f ./mkproto.awk ./*.c ./lib/compat.c daemon-parm.h
In file included from ./rounding.c:20:
./rsync.h:643:3: error: Could not find a 32-bit integer variable
# error Could not find a 32-bit integer variable
^
./rsync.h:712:2: error: unknown type name 'int32'
int32 size, entries;
^
./rsync.h:713:8: error: expected ';' at end of declaration list
uint32 node_size;
^
;
./rsync.h:719:2: error: unknown type name 'int32'
int32 key;
^
./rsync.h:803:3: error: Character pointers are not 4 or 8 bytes.
# error Character pointers are not 4 or 8 bytes.
^
./rsync.h:816:2: error: unknown type name 'int32'
int32 num;
^
./rsync.h:817:8: error: expected ';' at end of declaration list
uint32 unum;
^
;
./rsync.h:833:8: error: expected ';' at end of declaration list
uint32 len32; /* Lowest 32 bits of the file's length */
^
;
./rsync.h:992:2: error: unknown type name 'int32'
int32 len; /**< length of chunk of file */
^
./rsync.h:993:8: error: expected ';' at end of declaration list
uint32 sum1; /**< simple checksum */
^
;
./rsync.h:994:2: error: unknown type name 'int32'
int32 chain; /**< next hash-table collision */
^
./rsync.h:1002:2: error: unknown type name 'int32'
int32 count; /**< how many chunks */
^
./rsync.h:1003:2: error: unknown type name 'int32'
int32 blength; /**< block_length */
^
./rsync.h:1004:2: error: unknown type name 'int32'
int32 remainder; /**< flength % block_length */
^
./rsync.h:1013:2: error: unknown type name 'int32'
int32 p_size; /* Largest window size we allocated */
^
./rsync.h:1014:2: error: unknown type name 'int32'
int32 p_len; /* Latest (rounded) window size */
^
./rsync.h:1015:2: error: unknown type name 'int32'
int32 def_window_size; /* Default window size */
^
./rsync.h:1051:8: error: expected ';' at end of declaration list
uint32 rflags;
^
;
In file included from ./rounding.c:20:
In file included from ./rsync.h:1148:
./byteorder.h:75:8: error: 'inline' can only appear on functions
static inline uint32
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Failed to create rounding.h!
make: *** [rounding.h] Error
Compiling without extra libs worked:
$ ./configure --prefix=/NonStandardDir/rsync/rsync-3.2.4 --disable-openssl --disable-xxhash --disable-zstd --disable-lz4 --disable-roll-simd --disable-md2man
The config.log and the ./configure script output gave hints on missing libraries. Executing make generated files like ~/Library/Logs/DiagnosticReports/conftest_….crash. Those reports clearly that the library is searched in the wrong standard place: Library not loaded: /usr/local/lib/liblz4.1.dylib
That the dynamic libraries liblz4.1.9.3.dylib, libzstd.1.5.2.dylib and libxxhash.0.8.1.dylib were linked incorrectly could also be proofed by:
$ otool -L /NonStandardFolder/lz4/lz4-1.9.3/usr/local/lib/liblz4.1.9.3.dylib
# -> Output: … /usr/local/lib/liblz4.1.dylib (compatibility version 1.0.0, current version 1.9.3)…
As popt, openssl and zlib weren't affected, because --prefix was set in the ./configure command, the solution is to recompile the incorrectly linked libs with the right prefix for the destination:
$ export PREFIX="/NonStandardFolder/lz4/lz4-1.9.3" && make && make install
The mistake was to set DESTDIR instead of PREFIX while executing the make command.
Check the dynamic library again and it should be correctly linked:
$ otool -L /NonStandardFolder/lz4/lz4-1.9.3/lib/liblz4.1.9.3.dylib
# -> Output: … /NonStandardFolder/lz4/lz4-1.9.3/lib/liblz4.1.dylib (compatibility version 1.0.0, current version 1.9.3)…
After recompiling the libs lz4, xxHash, zstd, something like the following (adapt to your folder structure) should work to compile rsync:
$ cd /SourcecodeFolder/rsync/rsync-3.2.4
$ make clean
$ ./configure --prefix=/NonStandardDir/rsync/rsync-3.2.4 --disable-debug --disable-md2man --with-rsyncd-conf=/NonStandardDir/rsync/rsync-3.2.4/configuration/rsyncd.conf --with-included-popt=no --with-included-zlib=no --enable-ipv6 --disable-roll-simd CPPFLAGS="-I/NonStandardDir/openssl/openssl-1.1.1n/include -I/NonStandardDir/lz4/lz4-1.9.3/usr/local/include -I/NonStandardDir/zstd/zstd-1.5.2/include -I/NonStandardDir/xxHash/xxHash-0.8.1/include -I/NonStandardDir/popt/popt-1.18/include -I/NonStandardDir/zlib/zlib-1.2.11/include" LDFLAGS="-L/NonStandardDir/openssl/openssl-1.1.1n/lib -L/NonStandardDir/lz4/lz4-1.9.3/lib -L/NonStandardDir/zstd/zstd-1.5.2/lib -L/NonStandardDir/xxHash/xxHash-0.8.1/lib -L/NonStandardDir/popt/popt-1.18/lib -L/NonStandardDir/zlib/zlib-1.2.11/lib"
$ make
$ make test
$ make install

make error while building GNU Octave from sources

mkdir .build && \
cd .build && \
./../configure --prefix=$HOME/my_octave && \ [1]
make -j2 && \ [2]
make check && \
make install
While running make -j2 I get the error as
error: print: error opening file 'extended.tex'
error: called from print>latex_standalone at line 1029 column 5
__opengl_print__ at line 214 column 5
print at line 759 column 16 plotimages at line 109 column 7
GEN doc/interpreter/gplot.pdfMakefile:27911: recipe for target `'doc/interpreter/extended.pdf' failedmake[2]: *** [doc/interpreter/extended.pdf] Error `1make[2]: *** Waiting for unfinished jobs....make[2]: Leaving directory `'/home/bhanu/octave/.build'Makefile:26305: recipe for target 'all-recursive' failedmake[1]: *** `[all-recursive] Error 1make[1]: Leaving directory '/home/bhanu/octave/.build'Makefile:9916:
recipe for target 'all' failedmake: *** [all] Error 2
Can someone help me solve the error? I am running it on Ubuntu 18.04 system.
Some times the build process tries to rebuild all the documentation.
I am building from the source octave-5.2.0.tar.lz file and
the usual workaround is just
touch AUTHORS BUGS INSTALL.OCTAVE
between configure and the first make in the
build tree.
At the end of build phase I have only two PDFs
./doc/interpreter/octave.pdf
./doc/liboctave/liboctave.pdf
Create file named 'extended.tex' like this:
touch doc/interpreter/extended.tex
You have to do this inside the octave/.build/ directory.
Do this for any errors similar to this in the future. It worked for me this way.

how to run run LMbench on mac

I followed these instructions. Download lmbench3.tar.gz from lmbench3
and Unpack LMbench to create a tree like so:
lmbench/
Results/
doc/
scripts/
src/
And Go to the lmbench directory, and type make results see
But the result is wrong:
7 warnings generated.
gcc -O -DRUSAGE -DHAVE_uint=1 -DHAVE_uint64_t=1 -DHAVE_int64_t=1 -DHAVE_DRAND48 -c getopt.c -o ../bin/i686-apple-darwin15.6.0/getopt.o
gcc -O -DRUSAGE -DHAVE_uint=1 -DHAVE_uint64_t=1 -DHAVE_int64_t=1 -DHAVE_DRAND48 -c lib_sched.c -o ../bin/i686-apple-darwin15.6.0/lib_sched.o
lib_sched.c:94:3: error: non-void function 'handle_scheduler' should return a
value [-Wreturn-type]
return;
^
1 error generated.
make[2]: *** [../bin/i686-apple-darwin15.6.0/lib_sched.o] Error 1
make[1]: *** [lmbench] Error 2
make: *** [build] Error 2
How to solve it?
You can change the statement
return;
into
return 0;
at line 94 of lib_sched.c
Then this file should compile without this error.

How to treat a warning as an error in a Makefile?

Is it possible to treat warnings as errors in a Makfile (and thus exit before Makefile proceeds)
Furthermore, is it possible to filter out which warning yields an error?
My use case: I want to use --warn-undefined-variables in combination with this so that Makefile will exit when a variable is undefined, which is a very common source of error. Obviously I don't want to manually check for each variable as this is error-prone/tedious. I couldn't find anything on this, but it's a pretty important/basic feature.
Note: I'm not looking for -Werror which is a gcc specific command not applicable to my use case.
If you're prepared to add a dependency to every target, you can make warnings into errors.
Here is a make file with an error in it ("SRCS" instead of "SRC"):
# Turn on the warning we want
MAKEFLAGS += --warn-undefined-variables
# Make sure MAKECMDGOALS is defined, so it doesn't cause an error itself
ifndef MAKECMDGOALS
MAKECMDGOALS = all
endif
SRC=hello.c
all: compile
# Fails if the Makefile contains any warnings.
# Run this Makefile with the same goals, but with the -n flag.
# Grep for warnings, and fail if any are found.
no-make-warnings:
! make -n $(MAKECMDGOALS) 2>&1 >/dev/null | grep warning
# Targets you want to check must depend on no-make-warnings
compile: no-make-warnings
gcc -o hello $(SRCS)
When I run it, I see this:
$ make
! make -n all 2>&1 >/dev/null | grep warning
Makefile:17: warning: undefined variable `SRCS'
make: *** [no-make-warnings] Error 1
You just need to make every target that you want to be checked depend on the target no-make-warnings.
If someone knows how to do that automatically, please chime in.
The standard version of make does not support what you are looking for. However, it should not be difficult to build your own version of make to fulfill your use case.
Looking at the source code of make 3.82, check out the macro warn_undefined in variable.h:
214 /* Warn that NAME is an undefined variable. */
215
216 #define warn_undefined(n,l) do{\
217 if (warn_undefined_variables_flag) \
218 error (reading_file, \
219 _("warning: undefined variable `%.*s'"), \
220 (int)(l), (n)); \
221 }while(0)
I have not tried this, but I think it should be sufficient to replace error with fatal.

Resources