I try opening Yojson.Basic.Util in one of my files and keep getting an unbound module error. I've tried several different things and can't seem to figure out what's wrong
I have this in my .ocamlinit:
#require "yojson";;
#require "ANSITerminal";;
and this in my makefile:
test:
ocamlbuild -pkg yojson, oUnit test.byte && ./test.byte
play:
ocamlbuild -pkgs oUnit,yojson,str,ANSITerminal main.byte && ./main.byte
check:
bash checkenv.sh
clean:
ocamlbuild -clean
Typing make produces this error:
ocamlbuild -pkg yojson, oUnit test.byte && ./test.byte
ocamlfind: Package `yojson,' not found
Cannot run Ocamlfind.
make: *** [test] Error 2
Changing the makefile to:
test:
ocamlbuild -use-ocamlfind -pkg yojson, oUnit test.byte && ./test.byte
play:
ocamlbuild -pkgs oUnit,yojson,str,ANSITerminal main.byte && ./main.byte
check:
bash checkenv.sh
clean:
ocamlbuild -clean
I type in make and it gives me this error:
ocamlbuild -use-ocamlfind -pkg yojson, oUnit test.byte && ./test.byte
Solver failed:
Ocamlbuild knows of no rules that apply to a target named oUnit. This can happen if you ask Ocamlbuild to build a target with the wrong extension (e.g. .opt instead of .native) or if the source files live in directories that have not been specified as include directories.
Compilation unsuccessful after building 0 targets (0 cached) in 00:00:00.
make: *** [test] Error 6
There is a difference between the -pkg and -pkgs option for ocamlbuild. The -pkg option takes exactly one package name. The -pkgs option takes a list of comma-separated package names (there can be optional spaces before and after the commas, but then you have to quote the argument).
In your example, you use -pkg, but with a comma-separated list of arguments, and that list has a space, so it would have to be quoted. Using -pkgs yojson,oUnit should fix the issue.
Related
I have a Makefile with two rules. i want to include one rule in another.
example:
|--> compile:
| g++ main.cpp -o main
| run:
----- compile (should execute the compile rule)
./main
how do i do this?? because when i try to do this it doesn't work.
it gives me this error:
make: compile: Command not found
make: *** [Makefile:4: all] Error 127
the arrows and lines are just to point the rule
The common and trivial way to do this is to have one target depend on the other.
run: compile
./main
There is no need to name the compile rule separately, though.
run: main
./$<
(Obscurely but conveniently uses the first dependency as the name of the script to run. make probably already knows how to make main so you don't need to spell that out.)
I'm trying to port libisofs to Windows. My environment is MSYS2 with mingw-w64-i686 toolchain installed.
I've used gnulib for missing headers with
gnulib-tool --import command:
$ ../gnulib/gnulib-tool --import fnmatch
I've done all steps in instruction:
Don't forget to
- add "lib/Makefile" to AC_CONFIG_FILES in ./configure.ac,
- mention "lib" in SUBDIRS in Makefile.am,
- mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am,
- mention "m4/gnulib-cache.m4" in EXTRA_DIST in Makefile.am,
- invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC,
- invoke gl_INIT in ./configure.ac.
Altough, there was no AC_PROG_CC in configure.ac, so I've added gl_EARLY after AM_PROG_CC_C_O
And there was no SUBDIRS variable in Makefile.am so I've added it manually at the bottom, as so:
SUBDIRS = lib
All configurations I've made as so:
autoreconf -i
automake --add-missing
autoconf
./configure
After running make I recieve error:
hard-locale.c:19:10: fatal error: config.h: No such file or directory
#include <config.h>
As I understand that file must be created by ./configure, but I don't understand why compiler doesn't find it.
configure.ac: https://pastebin.com/JbWRqjEv
Makefile.am: https://pastebin.com/V6ZBq8Vd
All outputs: https://pastebin.com/WFu5aJU7
Gnulib assumes that your configure.ac file contains
AC_CONFIG_HEADERS([config.h])
Without it, every compiler command invocation is more than 1000 characters long, due to the many -D options; this is not practical for development.
So I'm trying to install the Homotopy Type Theory library for Coq from github following these instructions. Running the command etc/install_coq.sh sets it off messing with a bunch of files before it hits an error as so:
$ make clean
make: *** No rule to make target `clean'. Stop.
Apparently there's one or more bugs present within Makefile.am, and according to what I've read while googling the issue it's likely related to improper whitespace. Running make clean myself yields the same thing:
make: *** No rule to make target `clean'. Stop.
Meanwhile running make -f Makefile.am clean yields:
Makefile.am:4: *** missing separator. Stop.
Lines 4-6 in the file are simply:
if make_hoqide
bin_SCRIPTS += hoqide
endif
What's wrong with that that's causing the problem?
Makefile.am is generally paired with Makefile.in; these need to be processed with automake or configure before you get a usable real Makefile.
If you've got a script "autogen.sh" in your top-level source directory, run that
first, then configure:
$ ./autogen.sh
$ ./configure
$ make
This is, in fact, step 3 of the instructions that you linked to. Perhaps the install_coq.sh script isn't finding all of the dependencies that you need?
I have a project structured like this:
Makefile
src/
main.ml
tests/
tests.ml
and the Makefile is something like this:
tests:
ocamlbuild -Is src,tests tests.byte -build-dir $(BUILDDIR) $(TESTFLAGS) -lflags -I,/usr/lib/ocaml/oUnit -cflags -I,/usr/lib/ocaml/oUnit -libs oUnit
Running make tests (after building main.byte) returns this error:
ocamlbuild -Is src,tests tests.byte -build-dir build -lflags -I,/usr/lib/ocaml/oUnit -cflags -I,/usr/lib/ocaml/oUnit -libs oUnit
+ /usr/bin/ocamlc -c -I /usr/lib/ocaml/oUnit -I tests -I src -o tests/tests.cmo tests/tests.ml
File "tests/tests.ml", line 3, characters 46-50:
Error: Unbound value main
Command exited with code 2.
Compilation unsuccessful after building 2 targets (0 cached) in 00:00:00.
make: *** [tests] Error 10
showing that ocamlbuild cannot link to main.byte. What should the tests rule of the Makefile look like?
Since OCaml programs don't have a default main function (OCaml just runs the top-level code in each module at start-up) you'll probably want to have a separate file for starting the code. e.g.
main.ml
myprog.ml
tests.ml
Where:
main.ml defines a main function let main args = ...
myprog.ml just calls it: let () = Main.main Sys.argv
tests.ml calls it in the same way from each test-case
Then build myprog.byte and tests.byte as your two targets to ocamlbuild. Run myprog.byte to run the program and tests.byte to run the tests.
unbound value main does not sound like an error related to main.byte, but a genuine mistake in the OCaml code of tests.ml. Could you provide (possibly simplified) sources to experiment?
(Thomas' advice on program structure of course still stands, independently.)
I have a autotool project where part of the source code is downloaded dynamically from the net (because of IP rights preventing direct redistribution) and then built.
I have a Makefile.am that works but I'm not happy about some of it's aspects.
Here it is:
INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
AM_CFLAGS = -fPIC -Wall ${SYMBOL_VISIBILITY}
LIBVERSION=0:0:0
REFSRC_PATH=refsrc
REFSRC_SRC=refsrc/dtx.c refsrc/globdefs.c refsrc/host.c refsrc/mathhalf.c refsrc/sp_enc.c refsrc/sp_rom.c refsrc/vad.c refsrc/err_conc.c refsrc/homing.c refsrc/mathdp31.c refsrc/sp_dec.c refsrc/sp_frm.c refsrc/sp_sfrm.c
${REFSRC_PATH}/.downloaded:
./fetch_sources.py "${REFSRC_PATH}"
for f in `ls -1 "${REFSRC_PATH}"/*.{c,h}`; do \
sed -i -e"s/round/round_l2s/" "$$f"; \
done
touch $#
${REFSRC_PATH}/dtx.c: ${REFSRC_PATH}/.downloaded
lib_LTLIBRARIES = libgsmhr.la
libgsmhr_la_SOURCES = libgsmhr.c $(REFSRC_SRC)
clean-local:
-rm -rf ${REFSRC_PATH}
So essentially, libgsmhr.c is my main wrapper, then I download the source code in a refsrc/ subdirectory and patch it a little.
First problem is that in REFSRC_SRC I would have loved to use a $(addprefix ...) instead of repeating refsrc/ in front of each .c file. But that doesn't seem to work and autoreconf complains a little.
Failure details (when removing the refsrc/ prefix from REFSRC_SRC= and using $(addprefix ${REFSRC_PATH}/, ${REFSRC_SRC}) on the dependency list):
bash$ autoreconf -i
libgsmhr/Makefile.am:19: addprefix ${REFSRC_PATH}/, ${REFSRC_SRC}: non-POSIX variable name
libgsmhr/Makefile.am:19: (probably a GNU make extension)
(configure works fine)
bash$ make
...
make[2]: Entering directory `/tmp/ram/gapk.build/libgsmhr'
CC libgsmhr.lo
CCLD libgsmhr.la
make[2]: Leaving directory `/tmp/ram/gapk.build/libgsmhr'
...
(So as you see it didn't include any of the downloaded .c files, didn't even download them at all. The compile works because libgsmhr.c is a stub that doesn't use the symbols in those file yet)
Second problem is this rule:
${REFSRC_PATH}/dtx.c: ${REFSRC_PATH}/.downloaded
I have to explicitely list the first file (dtx.c) instead of using a wildcard like:
${REFSRC_PATH}/%.c: ${REFSRC_PATH}/.downloaded
If I try to use the wildcard, then autoreconf complains and also it just doesn't work ... (pattern doesn't match somehow).
Failure detail:
bash$ autoreconf -i
libgsmhr/Makefile.am:16: `%'-style pattern rules are a GNU make extension
(configure works fine)
bash$ make
...
make[2]: *** No rule to make target `refsrc/dtx.c', needed by `dtx.lo'. Stop.
...
Sylvain
You seem to be writing a makefile in GNUMake style, but actually running some other version of Make. If it's not obvious what autoreconf is calling, you could insert a rule in the makefile:
dummy:
#echo using $(MAKE)
$(MAKE) -v
If this theory proves correct, you can either persuade autoconf to use GNUMake, or write for the version it's using.