ghc sanity check error while setup ghc-8.2.1 for haskell stack on Opensuse 42.3 - opensuse

I have installed haskell stack and I'm trying to setup ghc for the same. stack version is
stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e (4861 commits) x86_64 hpack-0.17.1
I have updated the ~/.stack/global-project/stack.yaml as below
# This is the implicit global project's config file, which is only used when
# 'stack' is run outside of a real project. Settings here do _not_ act as
# defaults for all projects. To change stack's default settings, edit
# '/home/rajkumar/.stack/config.yaml' instead.
#
# For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration/
#
flags: {}
extra-package-dbs: []
packages: []
extra-deps: []
resolver: ghc-8.2.1
Then I run stack setup command and got the below error -
> stack setup
The GHC located at /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.1/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /home/user/.stack/programs/x86_64-linux/ghc-tinfo6-8.2.1/bin/ghc /tmp/stack-sanity-check6389/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check6389/ exited with ExitFailure 1
[1 of 1] Compiling Main ( /tmp/stack-sanity-check6389/Main.hs, /tmp/stack-sanity-check6389/Main.o )
Linking /tmp/stack-sanity-check6389/Main ...
/usr/bin/ld.bfd: cannot find -lgmp
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
How can I resolve this issue?

I am able to resolve this error.
Verify gmp is installed already on opensuse linux using the below command.
sudo ldconfig -p | grep libgmp
libgmp.so.10 (libc6,x86-64) => /usr/lib64/libgmp.so.10
If not present install it using below command
sudo zypper install libgmp10
create link for the lib file in the same folder. Example
sudo ln /usr/lib64/libgmp.so.10 /usr/lib64/libgmp.so
Hope this helps for someone.

Related

Build and run a Qt application on macOS via Bazel

I tried to build and run a Qt5 (5.15.2) application on macOS (10.15.7) using Bazel 5.0.0.
Unfortunately, I run into some problems.
The building part seems to work, but not the run part.
I installed Qt5 on my machine using Homebrew:
brew install qt#5
brew link qt#5
I adapted https://github.com/justbuchanan/bazel_rules_qt/ to my needs. See this PR. When I try to run:
bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
I receive the runtime error:
dyld: Symbol not found: __ZN10QByteArray6_emptyE
Steps to reproduce the issue:
# brew install bazel # Install Bazel
# brew install qt#5 # Install Qt5
git clone https://github.com/Vertexwahn/bazel_rules_qt.git
cd bazel_rules_qt
git checkout add-macos-support
bazel build --cxxopt=-std=c++17 //... # should work
bazel run --cxxopt=-std=c++17 //tests/qt_resource:main # should give you the error message
Nevertheless, building everything using bazel build --cxxopt=-std=c++17 //... seems to work.
I am not 100% sure if the link options -F/usr/local/opt/qt5/Frameworks and -framework QtCore, etc. are correct.
Maybe someone can confirm this.
Did I use the correct link options?
For me, it is a bit unclear what dependencies the main binary expects. I tried to copy QtCore.framework to the location of the main binary manually but this does not change the error message.
What files does the main binary expect?
If I try to run macdeployqt on my main binary I get also some errors. I do within my workspace root dir a cd bazel-bin/tests/qt_resource and run then /usr/local/opt/qt5/bin/macdeployqt main:
ERROR: Could not find bundle binary for "main"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/otool-classic: can't open file: (No such file or directory)\n"
WARNING:
WARNING: Could not find any external Qt frameworks to deploy in "main"
WARNING: Perhaps macdeployqt was already used on "main" ?
WARNING: If so, you will need to rebuild "main" before trying again.
ERROR: Could not find bundle binary for "main"
ERROR: "error: /Library/Developer/CommandLineTools/usr/bin/strip: can't open file: (No such file or directory)\n"
ERROR: ""
My hope was that macdeployqt would collect all needed resources for me. Any idea why this is not working?
How can macdeployqt be used to collect all needed dependencies for the main binary?
If I convert my main to an app via lipo -create -output universall_app main and do then a /usr/local/opt/qt5/bin/macdeployqt universall_app I get the same error message.
The CMake approach
To make sure that there is no general problem with my system setup I tried to use CMake to build a Qt5 application:
git clone https://github.com/euler0/mini-cmake-qt.git
cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5 .
make -j
This produces an example.app.
With a double click on this application bundle,
the application can be started.
This worked on my system.
Future directions
It seems that rules_apple can be used to create an application bundle.
I am not sure if I need to transform my Qt application binary to an app bundle to be able to execute it.
One could use --sandbox_debugto identify what Bazel is doing and dtruss for the CMake version to compare the differences.
I am currently not sure what trying to do next and hope for an easy solution. I am also fine with a Qt6 solution.
Update: Alternative Answer
It would also be helpful if someone can point out how to build a minimal Qt application using make only on macOS and a brew installed Qt5 or tell me what the linker and compiler options must look like.
I followed your steps with Mac OSX 10.15.7, Qt (installed by homebrew) 5.15.1 and both bazel 4.2.2-homebrew and 5.0.0-homebrew and initially I could not build the project from git:
* 3fe5f6c - (4 weeks ago) Add macOS support — Vertexwahn (HEAD -> add-macos-support, origin/add-macos-support)
This is the result that I get when building:
% bazel build --cxxopt=-std=c++17 //...
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed 14 targets (0 packages loaded, 0 targets configured).
INFO: Found 14 targets...
ERROR: /Users/home/Git/my_repo/bazel_rules_qt/tests/qt_qml/BUILD:4:10: Compiling tests/qt_qml/main.cc failed: (Aborted): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -O0 -DDEBUG '-std=c++11' ... (remaining 38 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
tests/qt_qml/main.cc:1:10: fatal error: 'QtQml/QQmlApplicationEngine' file not found
#include <QtQml/QQmlApplicationEngine>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error in child process '/usr/bin/xcrun'. 1
INFO: Elapsed time: 0,594s, Critical Path: 0,32s
INFO: 3 processes: 3 internal.
FAILED: Build did NOT complete successfully
After playing around with headers and include paths in qt.BUILD:
diff --git a/qt.BUILD b/qt.BUILD
index 517c8db..8f110b5 100644
--- a/qt.BUILD
+++ b/qt.BUILD
## -28,11 +28,12 ## QT_LIBRARIES = [
cc_library(
name = "qt_%s_osx" % name,
# When being on Windows this glob will be empty
- hdrs = glob(["%s/**" % include_folder], allow_empty = True),
+ hdrs = glob(["include/%s/**" % include_folder], allow_empty = True),
includes = ["."],
linkopts = ["-F/usr/local/opt/qt5/lib"] + [
"-framework %s" % library_name.replace("5", "") # macOS qt libs do not contain a 5 - e.g. instead of Qt5Core the lib is called QtCore
],
+ strip_include_prefix= "include"
# Available from Bazel 4.0.0
# target_compatible_with = ["#platforms//os:osx"],
)
I could build and run the project:
% bazel build --cxxopt=-std=c++17 //...
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed 14 targets (1 packages loaded, 7422 targets configured).
INFO: Found 14 targets...
INFO: Elapsed time: 11,761s, Critical Path: 7,23s
INFO: 3 processes: 1 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 3 total actions
% bazel run --cxxopt=-std=c++17 //tests/qt_resource:main
DEBUG: /private/var/tmp/_bazel_home/761aafaa2237a9607dd915f1f52bca3e/external/com_justbuchanan_rules_qt/qt_configure.bzl:43:14: Installation available on the default path: /usr/local/opt/qt5
INFO: Analyzed target //tests/qt_resource:main (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //tests/qt_resource:main up-to-date:
bazel-bin/tests/qt_resource/main
INFO: Elapsed time: 3,657s, Critical Path: 0,00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
opened resource file
file1
Related to your question whether the linker options are correct
-F/usr/local/opt/qt5/Frameworks -framework QtCore
Yes they are correct, you could alternatively use -F/usr/local/opt/qt5/lib (as you are already using in qt.BUILD) as all the files under the Frameworks folder are links to the lib folder.
With macdeployqt and lipo I get the same results as in the OP even after the test is running successfully.

ocamlbuild can't find file graphics.cma

I reviewed this thread OCaml - Cannot find graphics.cma but unfortunately wasn't able to resolve it finding the recommendation here. I'm on Catalina macos and when running ocamlbuild foo.byte, I get this error:
+ ocamlc.opt str.cma graphics.cma -thread threads.cma foo.cmo -o foo.byte
File "_none_", line 1:
Error: Cannot find file graphics.cma
Command exited with code 2.
Compilation unsuccessful after building 3 targets (0 cached) in 00:00:00.
I tried installing graphics via opam and installing xquartz as well manually after removing the brew version of xquartz which, enabled me to install graphics just fine but still gives me the error above.
Without more details, it sounds like you have not added the "graphics" package to your _tag file. (Detailing this dependency is also required with dune).

Installing OpenCV 3 in Homebrew using libstdc++

I am installing Caffe on Mac OS X 10.11 El Capitan, which somehow requires that I install OpenCV with libstdc++. To do so, I did "brew update opencv" and adding the following lines below "def install" as mentioned on the Caffe website (http://caffe.berkeleyvision.org/install_osx.html):
def install
# ADD THE FOLLOWING:
ENV.append "CXXFLAGS", "-stdlib=libstdc++"
ENV.append "CFLAGS", "-stdlib=libstdc++"
ENV.append "LDFLAGS", "-stdlib=libstdc++ -lstdc++"
# The following is necessary because libtool likes to strip LDFLAGS:
ENV["CXX"] = "/usr/bin/clang++ -stdlib=libstdc++"
...
However, when I go install it using "brew install --build-from-source -vd opencv", I get the following error:
cd /tmp/opencv-20170909-8122-1xa5qpl/opencv-3.3.0/build/modules/dnn &&
/usr/local/Cellar/cmake/3.9.2/bin/cmake -E cmake_symlink_library
../../lib/libopencv_dnn.3.3.0.dylib ../../lib/libopencv_dnn.3.3.dylib
../../lib/libopencv_dnn.dylib [ 59%] Built target opencv_dnn make: ***
[all] Error 2 /usr/local/Homebrew/Library/Homebrew/debrew.rb:11:in
`raise' BuildError: Failed executing: make
1. raise
2. ignore
3. backtrace
4. irb
5. shell Choose an action:
Anyone know how to solve this? Thank you in advance!
EDIT: Actually, I realized that my original opencv.rb file is producing the exact same problem. How do I fix/find an opencv.rb file that works?
It looks like he build you are going for in not compatible with the OS. If installing on Mac would suggest trying this method of implementation. It also uses homebrew but allows for a quick and simple implementation.

Makefile error raspberry-pi 3

I have an issue with Codelite compilation, running on raspbian jessie - these are the (known) steps I have taken to produce it.
First I installed Codelite with apt-get install Codelite, then produced a c++ project.
When running build project I get the error:
/bin/sh -c ' -j 4 -e -f Makefile'
/bin/sh: 1: -j: not found
0 errors, 0 warnings
I note that this error has been found and corrected previously, through running a different version of Codelite from 6.1.1 (that which apt-get installs). I therefore found the updated version of armhf .deb codelite from the rasbian archive with gdebi-gtk. However the updated version (9.1.1) produces the following error (install attempt with the graphical debian):
Error: Dependency is not satisfiable: libclang 1-3.8 (>=3.2)
I do not understand why the package manager cannot update these packages - do they not exist for the pi? I ran the manager as root, so I do not think it is a permissions issue.
EDIT 1:
Thank you for that Fabre. My Enviromental Variables file now looks like this:
CodeLiteDir=/usr/share/codelite
export MAKE=make
I still get the same error however.

ocaml-glpk (glpk bindings) and OASIS

Preface: I am new to OCaml, OPAM, and OASIS.
tldr question: How do I properly set up a package with opam that is not already available in the repository (I can't just do opam install X)? More details follow:
I am trying to include ocaml-glpk in an OCaml project. I installed ocaml-glpk just by running make and make install as stated in the README, and the given example compiles and runs correctly. However, I am using OASIS to generate the build system of my project, and I am not sure how to set it up. I have the same example (renamed to glpkExample.ml in a src folder) and the following in my _oasis file:
Executable "glpkExample"
Path: src
MainIs: glpkExample.ml
CompiledObject: best
BuildDepends:
glpk
After running oasis setup -setup-update dynamic, I run make and get the following error:
ocaml setup.ml -build
Finished, 0 targets (0 cached) in 00:00:00.
+ /home/dimitrios/.opam/system/bin/ocamlfind ocamlopt -g -linkpkg -package glpk src/glpkExample.cmx -o src/glpkExample.native
File "_none_", line 1:
Error: Cannot find file /home/dimitrios/.opam/system/lib/glpk/glpk.cmxa
Command exited with code 2.
Compilation unsuccessful after building 4 targets (3 cached) in 00:00:00.
E: Failure("Command ''/usr/bin/ocamlbuild' src/glpkExample.native -tag debug' terminated with error code 10")
make: *** [build] Error 1
It seems the glpk library is missing a cmxa file needed to compile a native executable. I am not sure how to fix this. To compile glpkExample.ml correctly, my Makefile includes /home/dimitrios/.opam/system/lib/glpk and also uses the OCamlMakefile, which is extremely long and convoluted. Any help on setting this up with OASIS or how to get ocaml-glpk to work nicely with OASIS would be greatly appreciated.
Thanks!
This website is not appropriate for bug reports. You should really report it here.
The temporary solution is to use CompiledObject: byte to compile in bytecode.
If you're using opam then it is best to install application with it, not manually. Try to clean up your system and remove whatever you installed, and then do:
$ eval `opam config env`
$ opam install ocaml-glpk
Afterwards, if glpk is packaged in opam correctly, it should work with your setup, i.e., just with oasis's BuildDepends field and nothing more.