How to configure ocamlc - ocaml

As this post suggests, ocaml 4.03.0 compiler or greater defaults warning 31 as an error. This makes me unable to install the camlidl package with the command opam install camidl because it contains a module with conflicting name as in stdlib.cma. How should I configure ocaml so I can run the command?
This is the error message:
#=== ERROR while installing camlidl.1.05 ======================================#
# opam-version 1.2.2
# os darwin
# command make all
# path /Users/xxx/.opam/system/build/camlidl.1.05
# compiler system (4.05.0)
# exit-code 2
# env-file /Users/xxx/.opam/system/build/camlidl.1.05/camlidl-58074-a71bb4.env
# stdout-file /Users/xxx/.opam/system/build/camlidl.1.05/camlidl-58074-a71bb4.out
# stderr-file /Users/xxx/.opam/system/build/camlidl.1.05/camlidl-58074-a71bb4.err
### stdout ###
# [...]
# ocamlc -g -c lexer_midl.mli
# ocamlc -g -c lexer_midl.ml
# ocamlc -g -c parse.mli
# ocamlc -g -c parse.ml
# ocamlc -g -c fixlabels.mli
# ocamlc -g -c fixlabels.ml
# ocamlc -g -c normalize.mli
# ocamlc -g -c normalize.ml
# ocamlc -g -c main.ml
# ocamlc -g -o camlidl config.cmo utils.cmo clflags.cmo prefix.cmo lexpr.cmo cvttyp.cmo variables.cmo array.cmo struct.cmo enum.cmo union.cmo cvtval.cmo structdecl.cmo enumdecl.cmo uniondecl.cmo typedef.cmo funct.cmo constdecl.cmo intf.cmo file.cmo predef.cmo linenum.cmo parse_aux.cmo parser_midl.cmo lexer_midl.cmo parse.cmo fixlabels.cmo normalize.cmo main.cmo
### stderr ###
# [...]
# File "parse_aux.ml", line 459, characters 10-26:
# Warning 3: deprecated: String.lowercase
# Use String.lowercase_ascii instead.
# 12 shift/reduce conflicts.
# File "array.cmo", line 1:
# Warning 31: files array.cmo and /usr/local/lib/ocaml/stdlib.cma(Array) both define a module named Array
# File "_none_", line 1:
# Error: Some fatal warnings were triggered (1 occurrences)
# make[1]: *** [camlidl] Error 2
# make: *** [all] Error 2

Related

Unable to install tezos-crypto due to compliation error in package tezos-stdlib-unix

I am trying to install the library tezos-crypto using Opam on Kubuntu 20.04. I am getting the following error:
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of tezos-stdlib-unix failed at "/home/marc/.opam/opam-init/hooks/sandbox.sh build dune build -p
tezos-stdlib-unix -j 15".
#=== ERROR while compiling tezos-stdlib-unix.10.2 =============================#
# context 2.0.5 | linux/x86_64 | ocaml-base-compiler.4.11.1 | https://opam.ocaml.org#e0171a79
# path ~/.opam/default/.opam-switch/build/tezos-stdlib-unix.10.2
# command ~/.opam/opam-init/hooks/sandbox.sh build dune build -p tezos-stdlib-unix -j 15
# exit-code 1
# env-file ~/.opam/log/tezos-stdlib-unix-69301-e0ba4f.env
# output-file ~/.opam/log/tezos-stdlib-unix-69301-e0ba4f.out
### output ###
# [...]
# (cd _build/default && /home/marc/.opam/default/bin/ocamlc.opt -w -40 -open Tezos_error_monad -open Tezos_error_monad.TzLwtreslib -open Tezos_event_logging -open Tezos_stdlib -open Data_encoding -g -bin-annot -I src/lib_stdlib_unix/.tezos_stdlib_unix.objs/byte -I /home/marc/.opam/default/lib/angstrom -I /home/marc/.opam/default/lib/astring -I /home/marc/.opam/default/lib/base -I /home/marc/.op[...]
# File "src/lib_stdlib_unix/file_descriptor_sink.ml", line 116, characters 16-24:
# 116 | Fmt.strf "%s-%d%s" chopped (Unix.getpid ()) ext
# ^^^^^^^^
# Alert deprecated: Fmt.strf
# use Fmt.str instead.
# (cd _build/default && /home/marc/.opam/default/bin/ocamlopt.opt -w -40 -open Tezos_error_monad -open Tezos_error_monad.TzLwtreslib -open Tezos_event_logging -open Tezos_stdlib -open Data_encoding -g -I src/lib_stdlib_unix/.tezos_stdlib_unix.objs/byte -I src/lib_stdlib_unix/.tezos_stdlib_unix.objs/native -I /home/marc/.opam/default/lib/angstrom -I /home/marc/.opam/default/lib/astring -I /home/[...]
# File "src/lib_stdlib_unix/file_descriptor_sink.ml", line 116, characters 16-24:
# 116 | Fmt.strf "%s-%d%s" chopped (Unix.getpid ()) ext
# ^^^^^^^^
# Alert deprecated: Fmt.strf
# use Fmt.str instead.
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build tezos-stdlib-unix 10.2
└─
╶─ No changes have been performed
How can I resolve this error?

Problem using VariantDir with a SCons Builder that generates a list of files to use as source for Program

I have a SConstruct that build my tool in 3 steps:
build a static library. In my case it's the antlr4 c++ runtime
generate the antlr4 cpp and h files (listener, visitor etc) of an antlr4's grammar
finally build a program using those files and linking to the antlr4 runtime library.
1 and 2 can be built in any order, even together but 3 ahs to be built when the other two have finished.
All this works perfectly when I don't use any VariantDir, however SCons fails when I try to use a variant directory, saying that it can't find the autogenerated files:
cons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
this is the whole SConstruct:
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
VariantDir('./build', './src')
VariantDir('./build/antlr4Runtime', './dependencies/antlr4Runtime')
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./build/antlr4Runtime/*.cpp') + \
Glob('./build/antlr4Runtime/atn/*.cpp') + \
Glob('./build/antlr4Runtime/dfa/*.cpp') + \
Glob('./build/antlr4Runtime/misc/*.cpp') + \
Glob('./build/antlr4Runtime/support/*.cpp') + \
Glob('./build/antlr4Runtime/tree/*.cpp') + \
Glob('./build/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./build/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './build/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./build/*.cpp') + Glob('./build/Parser/*.cpp'),
CPPPATH = ['./build', './build/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(auto_antlr_generated_files('./build/src/Parser/'), ParserFiles)
Depends(CoralLang, ParserFiles)
It is probably worth mentioning that at this point, when I have the error, the autogenerated antlr4 files are not in ./src nor in ./build, So basically the command never generated them in first place.
note that without VariantDir everything works as expected. Everything is build in the right steps without problems
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./dependencies/antlr4Runtime/*.cpp') + \
Glob('./dependencies/antlr4Runtime/atn/*.cpp') + \
Glob('./dependencies/antlr4Runtime/dfa/*.cpp') + \
Glob('./dependencies/antlr4Runtime/misc/*.cpp') + \
Glob('./dependencies/antlr4Runtime/support/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './dependencies/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./src/*.cpp') + Glob('./src/Parser/*.cpp'),
CPPPATH = ['./src', './dependencies/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(CoralLang, ParserFiles)
I have the feeling that I'm doing something remarkably silly but I can't figure out what exactly.
This is what SCons output with the first SConstruct, the one that uses VariantDir:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
scons: building terminated because of errors.
This is really all and if I read this correctly, SCons is jumping straight to point 3 and of course at it fails because point 2 didn't create the files that point 3 needs as source.
This is instead a snippet of the output of the second SConstruct, the one that doesn't use VariantDir. (I cut off some of the similar lines where Scons create the static library, but they are all similar, as you know)
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o dependencies/antlr4Runtime/ANTLRErrorListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/ANTLRErrorListener.cpp
...
clang++ -o dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.cpp
ar qc lib/libantlr4-runtime.a dependencies/antlr4Runtime/ANTLRErrorListener.o ... dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o
ranlib lib/libantlr4-runtime.a
java org.antlr.v4.Tool Coral.g4 -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser
clang++ -o src/Parser/CoralListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralListener.cpp
clang++ -o src/Parser/CoralBaseListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseListener.cpp
clang++ -o src/Parser/CoralParser.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralParser.cpp
clang++ -o src/Parser/CoralLexer.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralLexer.cpp
clang++ -o src/main.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/main.cpp
clang++ -o src/Parser/CoralVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralVisitor.cpp
clang++ -o src/Parser/CoralBaseVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseVisitor.cpp
clang++ -o coral src/main.o src/Parser/CoralBaseListener.o src/Parser/CoralBaseVisitor.o src/Parser/CoralLexer.o src/Parser/CoralListener.o src/Parser/CoralParser.o src/Parser/CoralVisitor.o -Llib -lantlr4-runtime
scons: done building targets.
So reading this is obvious that Scons start with building the static library, then he runs antlr to generate the files needed to parse my syntax and finally, when all the dependencies are created, it build the program.

failure to install ocaml-top on mac

I'm attempting to install ocaml-top on a mac but receiving the following failure message. Any idea? Thanks!
I tried:
opam install ocaml-top
And received the following
`∗ install ocaml-top 1.1.5
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
[ocaml-top.1.1.5] found in cache
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
[ERROR] The compilation of ocaml-top failed at
"/Users/danielfriedman/.opam/opam-init/hooks/sandbox.sh build jbuilder
build -p ocaml-top".
#=== ERROR while compiling ocaml-top.1.1.5 ====================================#
# context 2.0.2 | macos/x86_64 | ocaml-base-compiler.4.06.1 | https://opam.ocaml.org#866ea725
# path ~/.opam/4.06.1/.opam-switch/build/ocaml-top.1.1.5
# command ~/.opam/opam-init/hooks/sandbox.sh build jbuilder build -p ocaml-top
# exit-code 1
# env-file ~/.opam/log/ocaml-top-49246-ffb3fd.env
# output-file ~/.opam/log/ocaml-top-49246-ffb3fd.out
### output ###
# ocamlopt src/.main.eobjs/completion.{cmx,o} (exit 2)
# (cd _build/default && /Users/danielfriedman/.opam/4.06.1/bin/ocamlopt.opt -w -40 -g -I src/.main.eobjs -I /Users/danielfriedman/.opam/4.06.1/lib/bytes -I /Users/danielfriedman/.opam/4.06.1/lib/lablgtk2 -I /Users/danielfriedman/.opam/4.06.1/lib/ocaml/compiler-libs -I /Users/danielfriedman/.opam/4.06.1/lib/ocaml/threads -I /Users/danielfriedman/.opam/4.06.1/lib/ocp-indent/lexer -I /Users/daniel[...]
# File "src/completion.ml", line 39, characters 4-26:
# Error: Unbound value IndexScope.read_string
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
┌─ The following actions failed
│ λ build ocaml-top 1.1.5
└─
╶─ No changes have been performed`

Compile and link sources from different directories with make and gcc

I`m having a Project with some subdirectories. I want to compile them with one makefile per Directory and link all Output files into one executable. Can anyone explain me, which commands I should use (-c or -g or extra call)?
makefile in my root-directory:
LIBS =
# The test will be called in this file. There is no need to change this.
#SRCS = main_test.c
SRCS = min.c max.c
###############################################################################
# #
# Normally it is not needed to edited below this. #
# #
###############################################################################
#SRCS = main_test.c Automated.c Basic.c Console.c CUCurses.c CUError.c Cunit_intl.c \
# MyMem.c TestDB.c TestRun.c Util.c wxWidget.c main_test.c \
# $(TST_SRCS)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
OBJ = $(SRCS:%.c=%.o)
# define the C compiler to use
CC = gcc
# define any compile-time flags
ODIR = out
#compile and link
#CFLAGS = -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#compile without link
CFLAGS = -O0 -c -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
#VPATH=test
#VPATH=source
# define the executable file,
TARGET = CUnit
export COVERAGE = $(TST_SRCS)
export STUBS = $(STUB_SRCS)
all:
$(MAKE) -C stub
$(MAKE) -C source
#echo --- build finished ---
#echo.
#echo TODO
#echo --- start linking ---
#echo.
and makefile of subdirectory
# define any directories containing header files other than /usr/include
# TODO
# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
# option, something like (this will link in libmylib.so and libm.so:
LIBS =
# TODO define the C source files
SRCS = $(COVERAGE)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
OBJ = $(SRCS:%.c=%.o)
# define the C compiler to use
CC = gcc
# define any compile-time flags
ODIR = ../out
#compile without link
CFLAGS = -O0 -c -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
# define the executable file,
all: $(TARGET) $(OBJ)
$(CC) $(OBJ) $(CFLAGS) -o $(TARGET) $(LFLAGS) $(OBJ)
#echo +++ build of source finished +++
clean:
$(RM) *.o *~ $(MAIN)
# DO NOT DELETE THIS LINE -- make depend needs it
I it is easier for the linker, if all Output file are in the same Directory. Works this with ODIR?
With the compiler option -c -g I can compile each submake and link the object files together.
CFLAGS = -O0 -Wall -c -g -fmessage-length=0 -fprofile-arcs -ftest-coverage

Disable some feauture while building Gstreamer Lib which cause Error?

I'm build gstreamer, at the step of building gstpgood/ext/aalib
The error log is
make[3]: Entering directory `sigma-gstreamer_1-2-rc5/build/gstpgood/ext'
make -C aalib
make[4]: Entering directory `/sigma-gstreamer_1-2-rc5/build/gstpgood/ext/aalib'
CC libgstaasink_la-gstaasink.lo
cc1: error: include location "/usr/include" is unsafe for cross-compilation [-Werror=poison-system-directories]
cc1: all warnings being treated as errors
make[4]: *** [libgstaasink_la-gstaasink.lo] Error 1
My friend build the same source on the other build host did not get this error. I compared gstpgood makefiles and found that my makefile has:
AALIB_CFLAGS = -I/usr/include
AALIB_CONFIG = /usr/bin/aalib-config
AALIB_LIBS = -L/usr/lib/x86_64-linux-gnu -laa
while my friend's make file has
AALIB_CFLAGS =
AALIB_CONFIG = no
AALIB_LIBS =
This aalib is used by aasink, how can i disable aasink when compiling gstreamer???
Pass --disable-aalib to configure before running make. Check ./configure --help for many other things you could disable.
Thank Sebastian Dröge!
I also find a way to bypass aalib check by editing .m4 file in: gstreamer/ext/gstpgood/m4/aalib.m4 it worked for me
#force disable aalibtes by putting enable_aalibtest=no
AC_ARG_ENABLE(aalibtest,
AC_HELP_STRING([--disable-aalibtest],
[do not try to compile and run a test AALIB program]),
, enable_aalibtest=yes)
enable_aalibtest=no
#comment some code
# AC_PATH_PROG(AALIB_CONFIG, aalib-config, no)
# min_aalib_version=ifelse([$1], ,0.11.0,$1)
# AC_MSG_CHECKING(for AALIB - version >= $min_aalib_version)
no_aalib=""
# if test "$AALIB_CONFIG" = "no" ; then
if test x$aalib_prefix == x ; then#add this line
no_aalib=yes
else
AALIB_CFLAGS="-I$aalib_prefix/include"#add this line
AALIB_LIBS="-L$aalib_prefix/lib -laa"#add this line
# AALIB_CFLAGS=`$AALIB_CONFIG $aalibconf_args --cflags`
# AALIB_LIBS=`$AALIB_CONFIG $aalibconf_args --libs`
# aalib_major_version=`$AALIB_CONFIG $aalib_args --version | \
# sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
# aalib_minor_version=`$AALIB_CONFIG $aalib_args --version | \
# sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
# aalib_micro_version=`$AALIB_CONFIG $aalib_config_args --version | \
# sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`