Error during compiling application template written with Eliom of Ocsigen Start - ocaml

When I try to compile an application template of Ocsigen Start following this instruction, the error shown below happens at make test.byte. Could you tell me how to fix this?
LC_ALL=C ocsigen-i18n-generator \
--languages en,fr \
--default-language en \
--primary myapp_i18n.tsv \
< assets/myapp_Demo_i18n.tsv \
> myapp_Demo_i18n.eliom
eliomc -w +A-4-7-9-37-38-39-41-42-44-45-48 -ppx -ppx "ocsigen-i18n-rewriter --prefix 'Myapp_' --suffix '_i18n' Myapp_i18n" -infer -package lwt_ppx -package js_of_ocaml-ppx_deriving_json -package ppx_deriving.std -package pgocaml -package ocsigen-start.server myapp_Demo_i18n.eliom
File "myapp_Demo_i18n.eliom", line 1, characters 24-37:
1 | let%shared languages = [Myapp_i18n.En;Myapp_i18n.Fr]
^^^^^^^^^^^^^
Error: Unbound constructor Myapp_i18n.En
make: *** [Makefile.os:213: _server/myapp_Demo_i18n.type_mli] Error 2
rm myapp_Demo_i18n.eliom

Related

Unable to build OpenCV with CUDA on RHEL 7

I am trying to build OpenCV tag 4.2 with CUDA 11.1 in an RHEL 7 docker image and are running into issues.
First issue/warning is this:
THRUST_COMPILER_DEPRECATION(C++14, pass -std=c++14 to your compiler);
Which can be resolved by removing --std=c++11 from cmake/OpenCVDetectCUDA.cmake:265.
Alright, simple enough to handle that warning. Although it would have been better to change it using a cmake option/define. The compile errors for gpu_mat.cu are there with or without the above change.
Then main problem is the build errors that are happening for gpu_mat.cu. Here is my current CMake line. I have tried a bunch of different options and at this point I'm just throwing everything and kitchen sink at it.
cmake ../ \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DENABLE_CXX11=OFF \ # I have tried it set to ON \
-DCMAKE_CXX_FLAGS="-std=c++14" \ # and without this line.
-DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules/ \
-DWITH_EIGEN=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DOPENCV_ENABLE_NONFREE:BOOL=ON \
-DWITH_CUDA:BOOL=ON \
-DCMAKE_PREFIX_PATH=/usr/local/cuda-11.1 \
-DCUDA_ARCH_BIN="52 60 61 70 75 80 86" \
-DCUDA_SEPARABLE_COMPILATION=ON \
-DCUDA_VERBOSE_BUILD=ON \
-DCUDA_NVCC_FLAGS="--std=c++14" \ # even passing this didn't resolve THRUST warning
-DCUDA_FAST_MATH=ON \
-DCUDA_PROPAGATE_HOST_FLAGS=OFF \
-DCUDA_BUILD_CUBIN=ON \
-DCUDA_HOST_COMPILER=/opt/rh/devtoolset-8/root/usr/bin/c++
Here is the VERBOSE output for gpu_mat.cu build:
[ 26%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o
cd /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda && /usr/bin/cmake -E make_directory /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/.
cd /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda && /usr/bin/cmake -D verbose:BOOL=ON -D build_configuration:STRING=Release -D generated_file:STRING=/opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o -D generated_cubin_file:STRING=/opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o.cubin.txt -P /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.Release.cmake
-- Removing /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o
/usr/bin/cmake -E rm -f /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o
-- Generating dependency file: /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.NVCC-depend
/usr/local/cuda-11.1/bin/nvcc -M -D__CUDACC__ /opt/tmp/opencv/modules/core/src/cuda/gpu_mat.cu -o /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.NVCC-depend -ccbin /opt/rh/devtoolset-8/root/usr/bin/c++ -m64 -D__OPENCV_BUILD=1 -D_USE_MATH_DEFINES -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -DOPENCV_WITH_ITT=1 --std=c++14 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -D_FORCE_INLINES --use_fast_math -Xcompiler -DCVAPI_EXPORTS -Xcompiler -fPIC -DNVCC -I/usr/local/cuda-11.1/include -I/opt/tmp/opencv/build/3rdparty/ippicv/ippicv_lnx/icv/include -I/opt/tmp/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include -I/opt/tmp/opencv/build -I/opt/tmp/opencv/modules/core/include -I/opt/tmp/opencv/build/modules/core -I/opt/tmp/opencv_contrib/modules/cudev/include -I/opt/tmp/opencv/3rdparty/include/opencl/1.2 -I/opt/tmp/opencv/3rdparty/ittnotify/include
-- Generating temporary cmake readable file: /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend.tmp
/usr/bin/cmake -D input_file:FILEPATH=/opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.NVCC-depend -D output_file:FILEPATH=/opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend.tmp -D verbose=ON -P /usr/share/cmake-3.18/Modules/FindCUDA/make2cmake.cmake
-- Copy if different /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend.tmp to /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend
/usr/bin/cmake -E copy_if_different /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend.tmp /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend
-- Removing /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend.tmp and /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.NVCC-depend
/usr/bin/cmake -E rm -f /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.depend.tmp /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o.NVCC-depend
-- Generating /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o
/usr/local/cuda-11.1/bin/nvcc /opt/tmp/opencv/modules/core/src/cuda/gpu_mat.cu -dc -o /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o -ccbin /opt/rh/devtoolset-8/root/usr/bin/c++ -m64 -D__OPENCV_BUILD=1 -D_USE_MATH_DEFINES -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -DOPENCV_WITH_ITT=1 --std=c++14 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -D_FORCE_INLINES --use_fast_math -Xcompiler -DCVAPI_EXPORTS -Xcompiler -fPIC -DNVCC -I/usr/local/cuda-11.1/include -I/opt/tmp/opencv/build/3rdparty/ippicv/ippicv_lnx/icv/include -I/opt/tmp/opencv/build/3rdparty/ippicv/ippicv_lnx/iw/include -I/opt/tmp/opencv/build -I/opt/tmp/opencv/modules/core/include -I/opt/tmp/opencv/build/modules/core -I/opt/tmp/opencv_contrib/modules/cudev/include -I/opt/tmp/opencv/3rdparty/include/opencl/1.2 -I/opt/tmp/opencv/3rdparty/ittnotify/include
And a snippet of the errors that immedately follow:
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/functional_hash.h: In member function 'std::size_t std::hash<float>::operator()(float) const':
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/functional_hash.h:232:22: error: expected ')' before numeric constant
return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
~ ^~~
)
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/functional_hash.h:232:15: error: invalid operands of types 'float' and 'double(const char*) throw ()' {aka 'double(const char*)'} to binary 'operator!='
return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
~~~~~~^~~~~~~~~~
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/functional_hash.h:232:64: error: expected ')' before ';' token
return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
~ ^
)
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/functional_hash.h: In member function 'std::size_t std::hash<double>::operator()(double) const':
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/functional_hash.h:244:22: error: expected ')' before numeric constant
return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
~ ^~
)
/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/functional_hash.h:244:15: error: invalid operands of types 'double' and 'double(const char*) throw ()' {aka 'double(const char*)'} to binary 'operator!='
return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
.................................
~~~
/opt/tmp/opencv/modules/core/src/cuda/gpu_mat.cu:382:4: note: to match this '('
if (value[0] == 0.0 && value[1] == 0.0 && value[2] == 0.0 && value[3] == 0.0)
^
/opt/tmp/opencv/modules/core/src/cuda/gpu_mat.cu:415:14: error: 'func_t' does not name a type; did you mean 'fpos_t'?
static const func_t funcs[7][4] =
^~~~~~
fpos_t
/opt/tmp/opencv/modules/core/src/cuda/gpu_mat.cu:426:3: error: 'funcs' was not declared in this scope
funcs[depth()][channels() - 1](*this, value, stream);
^ ~~~
-- Removing /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o
/usr/bin/cmake -E rm -f /opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o
CMake Error at cuda_compile_1_generated_gpu_mat.cu.o.Release.cmake:276 (message):
Error generating file
/opt/tmp/opencv/build/modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/./cuda_compile_1_generated_gpu_mat.cu.o
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/build.make:84: modules/core/CMakeFiles/cuda_compile_1.dir/src/cuda/cuda_compile_1_generated_gpu_mat.cu.o] Error 1
make[2]: Leaving directory '/opt/tmp/opencv/build'
make[1]: *** [CMakeFiles/Makefile2:3852: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make[1]: Leaving directory '/opt/tmp/opencv/build'
make: *** [Makefile:182: all] Error 2
I am running the build process after enabling devtools
scl enable devtoolset-8 bash # also tried with devtoolset-7
I have searched for these errors, but I guess my google-fu is weak for this. I didn't have these errors/problems when I built OpenCV 4.5.1 w/ CUDA in an Ubuntu 18 Docker image.
So I'm totally missing something and have been working on this for a couple of days. I am just out of ideas of what to do next.
Thanks for any input.
I'm seeing some very similar build errors as you are, so you're not alone! I'm told it has something to do with a recent change to centos 7, which has broken nvcc. Hopefully, it gets fixed soon.
https://gitlab.com/nvidia/container-images/cuda/-/issues/109#note_503061879
There was a reported issue with RHEL/CentOS and has since been resolved.
https://access.redhat.com/errata/RHBA-2021:0439

compiling cpp wasm module using skia library face to an error

I'm trying to use SKIA lib in my WASM solution. first I Compiled Skia to wasm bitcode using bellow config:
/bin/gn gen ./out/Build-wasm-Release/Release --args="cc=\"emcc\" extra_cflags_cc=[\"-frtti\",\"-s\",\"USE_FREETYPE=1\"] cxx=\"em++\" extra_cflags=[\"-Wno-unknown-warning-option\",\"-s\",\"USE_FREETYPE=1\",\"-s\",\"USE_LIBPNG=1\"] \
is_debug=false \
is_official_build=true \
is_component_build=false \
target_cpu=\"wasm\" \
\
skia_use_egl=false \
skia_use_vulkan=false \
skia_use_libwebp=false \
skia_use_libpng=true \
skia_use_lua=false \
skia_use_dng_sdk=false \
skia_use_fontconfig=false \
skia_use_libjpeg_turbo=false \
skia_use_libheif=false \
skia_use_expat=false \
skia_use_vulkan=false \
skia_use_freetype=false \
skia_use_icu=false \
skia_use_expat=false \
skia_use_piex=false \
skia_use_zlib=true \
skia_enable_gpu=true \
skia_enable_pdf=false"
it successfully compiled, when I try to compile my own code using:
em++ multiply.cpp -o multiply.js -s EXPORTED_FUNCTIONS="['_float_multiply','_float_multiply_array','_sample_array_rtn','_sample_array_float_rtn','_msd_main']"-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -s ALLOW_MEMORY_GROWTH=1 -s USE_WEBGL2=1 -s NO_EXIT_RUNTIME=1 -s USE_LIBPNG=1 -s WASM=1 -s MODULARIZE=1 -s FORCE_FILESYSTEM=0 -I$SKIAPATH/include/ -I$SKIAPATH/include/gpu -I$SKIAPATH/include/core -I$SKIAPATH/include/config -I$SKIAPATH/include/c -L$SKIAPATH/out/Build-wasm-Release/Release -I$SKIAPATH -lskia
I got bellow this error:
LLVM ERROR: Invalid SIMD cast between items of different bit sizes!

How to configure ocamlc

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

gcc soname unrecognized command line

I'm compiling sipXtapi and I need to compile with this line
gcc -shared -DPIC .libs/codec_pcmapcmu_la-CodecPcmaWrapper.o .libs/codec_pcmapcmu_la-CodecPcmuWrapper.o .libs/codec_pcmapcmu_la-G711.o .libs/codec_pcmapcmu_la-PlgPcmaPcmu.o -lc -W1,-soname=codec_pcmapcmu.so -o .libs/codec_pcmapcmu.so
gcc: error: unrecognized command line option ‘-W1,-soname=codec_pcmapcmu.so’
and this is the Makefile.am:
## Process this file with automake to produce Makefile.in
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/../sipXportLib/include -I$(top_srcdir)/contrib/libspandsp/src
pkgdata_LTLIBRARIES = codec_pcmapcmu.la
codec_pcmapcmu_la_SOURCES = \
CodecPcmaWrapper.c \
CodecPcmuWrapper.c \
G711.c \
PlgPcmaPcmu.c
if PCMAPCMU_STATIC
codec_pcmapcmu_la_CFLAGS = -DCODEC_STATIC
codec_pcmapcmu_la_LDFLAGS = -module -avoid-version -static else
codec_pcmapcmu_la_LDFLAGS = -module -avoid-version
all-local: codec_pcmapcmu.la
echo "Installing plugin codec_pcmapcmu.so ..."
cp -f .libs/codec_pcmapcmu.so #DEFAULT_CODECS_PATH#
clean-local:
rm -f #DEFAULT_CODECS_PATH#/codec_pcmapcmu.so endif
how can I solve the problem?
There's a spelling error there -W1 should be -Wl (that's a lower case L instead of the digit 1)

Installing Ocaml/grammar module for SWIG

Running Swig example for ocaml gives me this error message.
rm -rf swig.mli swig.ml swigp4.ml && ../../../preinst-swig -ocaml -co swig.mli 2>/dev/null && ../../../preinst-swig -ocaml -co swig.ml 2>/dev/null && ../../../preinst-swig -ocaml -co swigp4.ml 2>/dev/null && ocamlc -c swig.mli && ocamlc -c swig.ml && ocamlc -I ` camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml
File "swig.ml", line 159, characters 54-57:
Warning 20: this argument will not be used by the function.
File "swigp4.ml", line 26, characters 2-6:
Parse error: Deprecated syntax, the grammar module is expected
File "swigp4.ml", line 1, characters 0-1:
Error: Preprocessor error
The File "swigp4.ml", line 26, characters 2-6 has the following content.
EXTEND
Line 25: expr:
Line 26: [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" ->
Line 27: >
...
Line 114: | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
Line 115: >
Line 116: ] ] ;
Line 117: END ;;
What might be wrong? How to install grammar module with ocaml?
ADDED
I use Mac OS X 10.6.4, and I installed Ocaml from this site.
And I got the following result with 'camlp4 -where'.
simple> camlp4 -where
/usr/local/lib/ocaml/camlp4
The swigp4.ml is downloadable here.
I've never used this swig package, but have used the camlp4 grammar module. You probably have camlp4, so I'm guessing the issue is the syntax being used. You can check for camlp4 and the grammar module, find the camlp4 directory by,camlp4 -where and see if that directory has, /Camlp4Parsers/Camlp4GrammarParser.[cmi|cmo|cmx|o]
If it's the syntax, I pulled up some code for a camlp4 grammar, and the expressions are structured slightly differently (I'm unsure if that format is invalid or not, but it's at least not how I've structured it before)
[[ | expr1 | expr2 ]]
should be
[ [ expr1] | [expr2] ]
I believe you're not using the latest version of Swig. With Swig 1.3 I had the same issue. Try moving to swig 2.0.X and you'll have no issues.
I've been working on ocaml bindings for Xapian and unfortunately the ocaml support in Swig has gone a bit unmaintained. However, I've found the examples in the Swig source tree to be extremely helpful. I've put together a decent make recipe for compiling the swig dependencies. You'll probably notice this is not really any different than the swig examples, I am just shamelessly using this time to share it:
SWIG=../../swig/preinst-swig
swig:
$(SWIG) -ocaml -co swigp4.ml
$(SWIG) -ocaml -co swig.mli
$(SWIG) -ocaml -co swig.ml
ocamlfind ocamlc -package camlp4 \
-pp "camlp4o pa_extend.cmo q_MLast.cmo" \
-c swigp4.ml
ocamlc -c swig.mli swig.ml
You can then build with that by including a -pp "camlp4o ./swig4.cmo" when compiling any code that uses the syntax extensions. You will also need to add swig.cmo when linking. I've got a gist of my complete Makefile which you might also find useful.