$ dune build ./src/main.exe --profile=release
ocamlc src/.main.eobjs/byte/ast.{cmi,cmo,cmt} (exit 2)
(cd _build/default && /usr/bin/ocamlc.opt -w -40 -O3 -g -bin-annot -I src/.main.eobjs/byte -I /home/jackprograms/.opam/default/lib/cairo2 -I /home/jackprograms/.opam/default/lib/lablgtk3 -I /usr/lib/ocaml/threads -no-alias-deps -o src/.main.eobjs/byte/ast.cmo -c -impl src/ast.ml)
/usr/bin/ocamlc.opt: unknown option '-O3'.
I ran this, and dune is using ocamlc bytecode... I am using exe which means native, as I saw on the dune documentation. Why is it running ocamlc when it should be running ocamlopt?
(executable
(name main)
(libraries lablgtk3)
(modes exe))
(ocamllex
(modules lexer))
(ocamlyacc
(modules parser))
(env
(dev
(flags (:standard -w +42)))
(release
(flags (:standard -O3))))
^ In src directory
It will still use ocamlc to compile .cmi files.
Instead of using flags (e.g. (flags (:standard -O3))), use ocamlopt_flags.
(executable
(name main)
(libraries lablgtk3)
(modes exe))
(ocamllex
(modules lexer))
(ocamlyacc
(modules parser))
(env
(dev
(flags (:standard -w +42)))
(release
(ocamlopt_flags (:standard -O3))))
Related
Trying to install PktGen with DPDK 21.11, however I am getting the below error
[1/69] Compiling C object lib/common/libcommon.a.p/copyright_info.c.o
FAILED: lib/common/libcommon.a.p/copyright_info.c.o
cc -Ilib/common/libcommon.a.p -Ilib/common -I../lib/common -I/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -Werror -O3 -march=native -mavx -mavx2 -DALLOW_EXPERIMENTAL_API -D_GNU_SOURCE -Wno-pedantic -Wno-format-truncation -fPIC -include rte_config.h -march=native -mno-avx512f -MD -MQ lib/common/libcommon.a.p/copyright_info.c.o -MF lib/common/libcommon.a.p/copyright_info.c.o.d -o lib/common/libcommon.a.p/copyright_info.c.o -c ../lib/common/copyright_info.c
cc1: fatal error: rte_config.h: No such file or directory
compilation terminated.
I think I am missing some environmental variable?
23:45:08 [root:~/Pktgen-DPDK] dev* ± echo $RTE_SDK
/root/repo/gNB_CU/ngp/thirdparty/dpdk/dpdk-21.11/
23:45:41 [root:~/Pktgen-DPDK] dev* ± echo $RTE_TARGET
x86_64-native-linux-gcc
23:45:46 [root:~/Pktgen-DPDK] dev* ± pkg-config --libs libdpdk
-Wl,--as-needed -L/lib64 -lrte_node -lrte_graph -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_pdump -lrte_port -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_dmadev -lrte_regexdev -lrte_rawdev -lrte_power -lrte_pcapng -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_gpudev -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bpf -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs
23:45:54 [root:~/Pktgen-DPDK] dev* ± pkg-config --cflags libdpdk
-I/include -include rte_config.h -march=native -mno-avx512f
23:46:06 [root:~/Pktgen-DPDK] dev* ±
Any suggestion where I might have gone wrong?
Problem was in DPDK installation path.
wget http://fast.dpdk.org/rel/dpdk-21.11.tar.xz
tar -xf dpdk-21.11.tar.xz
cd dpdk-21.11/
meson -Dexamples=all build
ninja -C build
cd build
ninja install
ldconfig
export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/
Once this was done, installation was successful.
I'm trying to build GLEW 2.1.0 on Windows (8.1) using MinGW and have been struggling for a while now.
I tried to follow the instructions for "MSYS/Mingw" on the GLEW GitHub page but when running mingw32-make, I only got a couple errors about missing commands (test and config) as well as the following: Makefile:40: *** "Platform '' not supported". Stop.
Under "Requirements" it says that bash is needed, so I installed git, because that apparently comes with a version of bash. Running mingw32-make (in the directory that all the GLEW files and folders are in) using Git Bash results in a long list of warnings and "undefined reference"s. The latter come from the linker as far as I know, but I have no idea what could cause them. As it's so much text, I'll only include the last few lines here:
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: tmp/mingw/default/shared/glewinfo.o:glewinfo.c:(.text.startup+0x181b): undefined reference to `_imp___iob'
collect2.exe: error: ld returned 1 exit status
Makefile:181: recipe for target 'bin/glewinfo.exe' failed
mingw32-make: *** [bin/glewinfo.exe] Error 1
mingw32-make install has the following output:
$ mingw32-make install
install -d -m 0755 "/usr/include/GL"
install -m 0644 include/GL/wglew.h "/usr/include/GL/"
install -m 0644 include/GL/glew.h "/usr/include/GL/"
install -m 0644 include/GL/glxew.h "/usr/include/GL/"
sed \
-e "s|#prefix#|/usr|g" \
-e "s|#libdir#|/usr/lib|g" \
-e "s|#exec_prefix#|/usr/bin|g" \
-e "s|#includedir#|/usr/include/GL|g" \
-e "s|#version#|2.1.0|g" \
-e "s|#cflags#||g" \
-e "s|#libname#|glew32|g" \
-e "s|#requireslib#|glu|g" \
< glew.pc.in > glew.pc
install -d -m 0755 "/usr/lib"
install -d -m 0755 "/usr/bin"
install -m 0755 lib/glew32.dll "/usr/bin/"
install -m 0644 lib/libglew32.dll.a "/usr/lib/"
install -m 0644 lib/libglew32.a "/usr/lib/"
install -d -m 0755 "/usr/lib/pkgconfig"
install -d -m 0755 "/usr/lib/pkgconfig"
install -m 0644 glew.pc "/usr/lib/pkgconfig/"
And mingw32-make install.all produces another long list of undefined references and the same error that came from running mingw32-make. The first lines however are (about) the same as the result of running mingw32-make install.
As expected with all of the errors, running these commands didn't produce a binary file. I guess it could have something to do with me not having make, which is one of the requirements listed on the GitHub page. However I don't understand how I should install make on Windows and why it is even needed when the instructions say to use mingw32-make.
I've also tried some of the suggestions made in this thread, but that doesn't seem to have worked either.
What could be the problem and what can I do to successfully compile GLEW?
I could never build it with the instructions I found around the internet, so here's how I build glew (using https://downloads.sourceforge.net/project/glew/glew/2.2.0/glew-2.2.0.tgz) under MSYS2 with MinGW-w64:
# change the line below to your desired install path
INSTALLPREFIX=/usr/local
VERSION=2.2.0
gcc -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a -o lib/glew32.dll src/glew.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32.a src/glew.o &&
gcc -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c &&
gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
ar cr lib/libglew32mx.a src/glew.mx.o &&
gcc -O2 -c -Iinclude -o src/glewinfo.o src/glewinfo.c &&
gcc -s -o src/glewinfo.exe src/glewinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 &&
gcc -O2 -c -Iinclude -o src/visualinfo.o src/visualinfo.c &&
gcc -s -o src/visualinfo.exe src/visualinfo.o lib/libglew32.dll.a -Wl,--as-needed -lgdi32 -lopengl32 -lglu32 &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#??; s?#libname#?glew32?" glew.pc.in > glew.pc &&
sed -e "s?#prefix#?$INSTALLPREFIX?; s?#libdir#?\$\{prefix\}/lib?; s?#version#?$VERSION?; s?#requireslib#?glu?; s?#cflags#?-DGLEW_MX?; s?#libname#?glew32mx?" glew.pc.in > glewmx.pc &&
echo Installing... &&
mkdir -p $INSTALLPREFIX/include $INSTALLPREFIX/lib/pkgconfig $INSTALLPREFIX/bin $INSTALLPREFIX/cmake &&
cp -rf include/GL $INSTALLPREFIX/include/ &&
cp -f lib/*.a $INSTALLPREFIX/lib/ &&
cp -f *.pc $INSTALLPREFIX/lib/pkgconfig/ &&
cp -f lib/*.dll src/*.exe $INSTALLPREFIX/bin/ &&
cp -f build/cmake/*.cmake $INSTALLPREFIX/cmake/ &&
echo Success
Is there a command line option or argument to ocamlopt (and ocamlc) to tell there it where to put the produced .cmx (and similar) files?
The documentation mentions -o, but that only works for me when there's no .mli file.
Similar for .cmi files.
The -o option works for me:
$ ocamlopt -version
4.03.0
$ ls
t.ml
$ ocamlopt -c -o zed.cmx t.ml
$ ls
t.ml
zed.cmi
zed.cmx
zed.o
I am trying to compile three files - toolbar.ml which uses lablgtk2, window.ml which uses lablgl and main.ml which calls both these files. Here is my shell script:
#!/bin/bash
echo "Compiling files"
eval $(opam config env)
echo "Compiling toolbar"
ocamlc -I +lablgtk2 lablgtk.cma gtkInit.cmo toolbar.ml
echo "Compiling window"
ocamlfind ocamlc window.ml -package lablgl.glut -linkpkg
ocamlc -c main.ml
ocamlc -o run window.cmo main.cmo toolbar.cmo
echo "Running executable"
./run
echo "Clearing up"
rm run main.cmo main.cmi main.o window.cmo window.cmi window.o a.out
rm toolbar.cmo toolbar.cmi
But I am getting this error message:
File "_none_", line 1:
Error: Error while linking window.cmo:
Reference to undefined global `Glut'
Does anyone know what I am doing wrong here?
Turns out I wasn't linking all the packages / creating a new package - this is how I fixed it:
#!/bin/bash
echo "Compiling files"
eval $(opam config env)
echo "Compiling toolbar"
ocamlc -a -o toolbar.cma -linkall -I +lablgtk2 lablgtk.cma gtkInit.cmo toolb ar.ml
echo "Compiling window"
ocamlfind ocamlc -a -o window.cma -linkall window.ml -package lablgl.glut -l inkpkg
ocamlc -c main.ml
ocamlc -o run window.cma toolbar.cma main.cmo
echo "Running executable"
./run
echo "Clearing up"
rm run main.cmo main.cmi main.o window.cmo window.cmi window.o a.out
rm toolbar.cmo toolbar.cmi
rm window.cma toolbar.cma
How to build with enabled profile information using Ocamlbuild? It seems -p doesn't work there.
Now, I use ocamlopt for this. For example,
$ ocamlfind ocamlopt -c -p -thread -package core test.ml
$ ocamlfind ocamlopt -p -o test -thread -package core -linkpkg test.cmx
How to do the same with
ocamlbuild -user-ocamlfind test.native
You can pass the argument explicitly,
ocamlbuild -cflags -p
or in your _tags file,
true : profile
There is also a rule for the file-name,
ocamlbuild test.p.native