After having some trouble I managed to configure my Cabal project so that it runs a simple stub test True #=? True. It works still if I substitute one value with a constant from tested package. However when I try to create an instance of a custom datatype to be tested, I get a linking error.
For now the project consists of two modules:
module TestedModule where
data MyDataType = MyData String Char Int deriving Show
boolVal = True
________________________________
module TestTestedModule where
import Test.HUnit
import TestedModule
import qualified Distribution.TestSuite as C
import qualified Distribution.TestSuite.HUnit as H
tests :: IO [C.Test]
tests = return $ map (uncurry H.test) testModule
testModule :: [(String, Test)]
testModule = [{- ("Test Show", testShow), -}
("Test True", testTrue)
]
testTrue = TestCase $ boolVal #? "False!"
-- testShow = TestCase $ "blabla" #=? show (MyData "blabla" 'a' 1)
Now when testShow is commented out, everything is fine, but when I uncomment it, I get:
$ cabal test
Building argparse-0.1.0.0...
Preprocessing library argparse-0.1.0.0...
[1 of 1] Compiling TestedModule ( TestedModule.hs, dist/build/TestedModule.o )
In-place registering package-0.1.0.0...
Preprocessing test suite 'test-module' for package-0.1.0.0...
[1 of 2] Compiling TestedModule ( TestedModule.hs, dist/build/TestedModule.o )
[2 of 2] Compiling TestArgparse ( TestTestedModule.hs, dist/build/TestTestedModule.o ) [TestedModule changed]
In-place registering test-module-0.1.0.0...
[1 of 1] Compiling Main ( dist/build/test-moduleStub/test-moduleStub-tmp/test-moduleStub.hs, dist/build/test-moduleStub/test-moduleStub-tmp/Main.o )
Linking dist/build/test-moduleStub/test-moduleStub ...
/home/sven/Haskell/lib/package/dist/build/libtest-package.a(TestTestedModule.o):(.data+0x50): undefined reference to `testzmargparsezm0zi1zi0zi0_TestedModule_MyData_static_info'
collect2: error: ld returned 1 exit status
The error occurs even if testShow is still commented out in testModule list. package.cabal looks like this:
$ cat package.cabal
-- Initial package.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: package
version: 0.1.0.0
synopsis: Some description
-- description:
license: Apache-2.0
license-file: LICENSE
author: Sventimir
maintainer: xxx#yyyy.com
-- copyright:
-- category:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
exposed-modules: TestedModule
-- other-modules:
-- other-extensions:
-- hs-source-dirs:
default-language: Haskell2010
build-depends: base >=4.7 && <4.8,
HUnit >=1.2 && <1.3,
containers >=0.5 && <0.6
Test-Suite test-module
type: detailed-0.9
test-module: TestTestedModule
default-language: Haskell2010
build-depends: base >=4.7 && <4.8,
Cabal >=1.20.0,
HUnit >=1.2 && <1.3,
cabal-test-hunit,
containers >=0.5
Files are all located in:
$ ls -la /home/sven/Haskell/lib/package
drwxr-xr-x 6 sven users 4096 Oct 5 10:57 .
drwxrwxrwx 6 sven users 4096 Sep 28 11:13 ..
drwxr-xr-x 7 sven users 4096 Oct 5 10:47 .cabal-sandbox
drwxr-xr-x 8 sven users 4096 Oct 5 09:27 .git
-rw-r--r-- 1 sven users 57 Oct 4 19:06 .gitignore
-rw-r--r-- 1 sven users 546 Oct 5 10:57 TestedModule.hs
-rw-r--r-- 1 sven users 11358 Oct 4 09:27 LICENSE
-rw-r--r-- 1 sven users 46 Oct 4 09:27 Setup.hs
-rw-r--r-- 1 sven users 650 Oct 5 10:56 TestTestedModule.hs
-rw-r--r-- 1 sven users 1190 Oct 5 09:39 package.cabal
-rw r--r-- 1 sven users 990 Oct 4 18:02 cabal.sandbox.config
drwxr-xr-x 5 sven users 4096 Oct 5 11:03 dist
drwxr-xr-x 2 sven users 4096 Oct 4 09:19 orid
Related
Trying to execute "make". I have checked the toolchain directory, which is fine as I have tried successfully compiled some other files. Want to know the reason behind this error, and where to check for solution.
-rwxrw-rw- 1 ayaz ayaz 7246 Dec 17 23:33 csi_fun.c
-rwxrw-rw- 1 ayaz ayaz 2133 Dec 17 23:33 csi_fun.h
-rwxrw-rw- 1 ayaz ayaz 4488 Dec 17 23:33 csi_fun.o
-rwxrw-rw- 1 ayaz ayaz 3881 Dec 17 23:33 main.c
-rwxrw-rw- 1 ayaz ayaz 4024 Dec 17 23:33 main.o
-rwxrw-rw- 1 ayaz ayaz 399 Dec 22 15:46 Makefile
-rwxrw-rw- 1 ayaz ayaz 13580 Dec 17 23:33 recv_csi
ayaz#ubuntu:~/Atheros_CSI_tool_OpenWRT_UserSpaceApp_src-master/recvCSI$ make
mips-openwrt-linux-gcc csi_fun.o main.o -o recvCSI
/home/ayaz/openwrt/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.16/lib/gcc/mips-openwrt-linux-musl/5.3.0/../../../../mips-openwrt-linux-musl/bin/ld: csi_fun.o: Relocations in generic ELF (EM: 62)
/home/ayaz/openwrt/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.16/lib/gcc/mips-openwrt-linux-musl/5.3.0/../../../../mips-openwrt-linux-musl/bin/ld: csi_fun.o: Relocations in generic ELF (EM: 62)
csi_fun.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make: *** [recvCSI] Error 1
SOLVED after re-installing the toolchain directiry
If you compiled an object for your host system instead of your target system (i.e forgot to specify ARCH or CROSS_COMPILER) you will need to delete those objects. make clean or make distclean usually does the trick.
I have multiple executables with non-conflicting names. Yet stack ghci complains that the main module is ambiguous:
$ find . -type f -exec grep -Hi "apple\|banana" {} \; | grep -v work
./ambig.cabal:executable apple
./ambig.cabal: main-is: Apple.hs
./ambig.cabal: ghc-options: -main-is Apple.apple
./ambig.cabal:executable banana
./ambig.cabal: main-is: Banana.hs
./ambig.cabal: ghc-options: -main-is Banana.banana
./src/Apple.hs:module Apple (apple) where
./src/Apple.hs:apple :: IO ()
./src/Apple.hs:apple = putStrLn "I am apple"
./src/Banana.hs:module Banana (banana) where
./src/Banana.hs:banana :: IO ()
./src/Banana.hs:banana = putStrLn "I am banana"
$ stack ghci
The main module to load is ambiguous. Candidates are: [...]
$ stack --version
Version 1.5.1, Git revision 600c1f01435a10d127938709556c1682ecfd694e
How can I make stack ghci load all these non-conflicting modules?
The complete cabal file:
$ cat ambig.cabal
name: ambig
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.10
executable apple
hs-source-dirs: src
main-is: Apple.hs
ghc-options: -main-is Apple.apple
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
executable banana
hs-source-dirs: src
main-is: Banana.hs
ghc-options: -main-is Banana.banana
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
I had the same problem, if I translate what I did on mine onto your project, you should be able to do either of these to choose the main module:
stack ghci --main-is ambig:exe:apple
or
stack ghci --main-is ambig:exe:banana
I'm working with Yocto to create an embedded linux distribution for an ARM device (i.MX 6Quad Processors).
I've configured the list of desired locales with the variable:
IMAGE_LINGUAS = "de-de fr-fr en-gb en-gb.iso-8859-1 en-us en-us.iso-8859-1 zh-cn"
As result I've obtained a file systems that contains the following folders:
root#lam_icu:/usr/lib/locale# cd /usr/share/locale/
root#lam_icu:/usr/share/locale# ls -la
total 0
drwxr-xr-x 6 root root 416 Nov 17 2016 .
drwxr-xr-x 30 root root 2056 Nov 17 2016 ..
drwxr-xr-x 4 root root 296 Nov 17 2016 de
drwxr-xr-x 3 root root 232 Nov 17 2016 en_GB
drwxr-xr-x 4 root root 296 Nov 17 2016 fr
drwxr-xr-x 4 root root 296 Nov 17 2016 zh_CN
and:
root#lam_icu:/usr/share/locale# cd /usr/lib/locale/
root#lam_icu:/usr/lib/locale# ls -la
total 0
drwxr-xr-x 9 root root 640 Mar 13 2017 .
drwxr-xr-x 32 root root 40000 Mar 13 2017 ..
drwxr-xr-x 3 root root 1016 Mar 13 2017 de_DE
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_GB
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_GB.ISO-8859-1
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_US
drwxr-xr-x 3 root root 1016 Mar 13 2017 en_US.ISO-8859-1
drwxr-xr-x 3 root root 1016 Mar 13 2017 fr_FR
drwxr-xr-x 3 root root 1016 Mar 13 2017 zh_CN
Which is the encoding of all non ISO-8859-1 locales? Can I assume that "en_GB" or "en_US" use the UTF-8 encoding?
I've tried to open the "LC_IDENTIFICATION" file, the result is:
Hc�������������cEnglish locale for the USAFree Software
Foundation,
Inc.http://www.gnu.org/software/libc/bug-glibc-locales#gnu.orgEnglishUSA1.02000-06-24en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000en_US:2000UTF-8
At the end of the file there is something that recalls "UTF-8". Is this enough to assume that the encoding is UTF-8?
How to check if a locale is UTF-8?
LC_IDENTIFICATION doesn't tell you much:
LC_IDENTIFICATION - this is not a user-visible category, it contains information about the locale itself and is rarely useful for users or developers (but is listed here for completeness sake).
You'd have to look at the complete set of files.
There appears to be no standard command-line utility for doing this, but there is a runtime call (added a little later than the original locale functions). Here is a sample program which illustrates the function nl_langinfo:
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>
int
main(int argc, char **argv)
{
int n;
for (n = 1; n < argc; ++n) {
if (setlocale(LC_ALL, argv[n]) != 0) {
char *code = nl_langinfo(CODESET);
if (code != 0)
printf("%s ->%s\n", argv[n], code);
else
printf("?%s (nl_langinfo)\n", argv[n]);
} else {
printf("? %s (setlocale)\n", argv[n]);
}
}
return 0;
}
and some output, e.g., by foo $(locale -a):
aa_DJ ->ISO-8859-1
aa_DJ.iso88591 ->ISO-8859-1
aa_DJ.utf8 ->UTF-8
aa_ER ->UTF-8
aa_ER#saaho ->UTF-8
aa_ER.utf8 ->UTF-8
aa_ER.utf8#saaho ->UTF-8
aa_ET ->UTF-8
aa_ET.utf8 ->UTF-8
af_ZA ->ISO-8859-1
af_ZA.iso88591 ->ISO-8859-1
af_ZA.utf8 ->UTF-8
am_ET ->UTF-8
am_ET.utf8 ->UTF-8
an_ES ->ISO-8859-15
an_ES.iso885915 ->ISO-8859-15
an_ES.utf8 ->UTF-8
ar_AE ->ISO-8859-6
ar_AE.iso88596 ->ISO-8859-6
ar_AE.utf8 ->UTF-8
ar_BH ->ISO-8859-6
ar_BH.iso88596 ->ISO-8859-6
The directory names you're referring to are often (but not required) to be the same as encoding names. That is the assumption made in the example program. There was a related question in How to get terminal's Character Encoding, but it has no useful answers. One is interesting though, since it asserts that
locale charmap
will give the locale encoding. According to the standard, that's not necessarily so:
The command locale charmap gives the name used in localedef -f
However, localedef attaches no special meaning to the name given in the -f option.
localedef has a different option -u which identifies the codeset, but locale (in the standard) mentions no method for displaying this information.
As usual, implementations may (or may not) treat unspecified features in different ways. The GNU C library's documentation differs in some respects from the standard (see locale and localedef), but offers no explicit options for showing the codeset name.
I'm doing the next statement on my ubuntu:
split --number=l/5 /pathToSource.csv /pathToOutputDirectory
If i do a "ls"
myUser#serverNAme:/pathToOutputDirectory> ls -la
total 21467452
drwxr-xr-x 2 myUser group 4096 Jun 23 08:51 .
drwxrwxrwx 4 myUser group 4096 Jun 23 08:44 ..
-rw-r--r-- 1 myUser group 10353843231 Jun 23 08:48 aa
-rw-r--r-- 1 myUser group 0 Jun 23 08:48 ab
-rw-r--r-- 1 myUser group 11376663825 Jun 23 08:51 ac
-rw-r--r-- 1 myUser group 0 Jun 23 08:51 ad
-rw-r--r-- 1 myUser group 252141913 Jun 23 08:51 ae
If i do a "du" over ab and ad files.
$du -h ab ad
0 ab
0 ad
As you can see, split divided the file in a non-homogeneous form.
Anyone know what's going on?
Some unprintable character can hang the split?
Thank you.
Best Regards!
Francisco.
While this is unusual data with an average line length of 114137, I'm not sure that fully describes the issue. Hmm you've 21982648969 of data => each bucket that split is trying to fill is 4396529793. That's larger than 2^32. I wonder do we have a 32 bit overflow. Are you on a 32 bit or 64 bit platform? Looking at the code I don't see an overflow issue TBH. Note you could anonymize and compress the data providing the following file for download somewhere:
tr -c '\n' . < /pathToSource.csv | xz > /pathToSource.csv.xz
It's also worth specifying the version since implementation changed a bit between v8.8 and v8.13
A workarround in groovy:
class Sanitizer {
public static void main(String[] args) {
def textOnly = new File('/path/NoDanger.txt')
def data = new File('/path/danger.txt')
String line = null
data.withReader { reader ->
while ( ( line = reader.readLine() ) != null ){
/*char[] stringToCharArray = line.toCharArray();
for(int i = 0; i < 5; i++ ){
char a = stringToCharArray[i]
int b = Character.getNumericValue(a);
println Integer.toHexString(b)
if (!(b =~ /\w/)) {
println "inside"
} else println "outside"
}*/
String newString = line.replaceAll("[^\\p{Print}]", "");
textOnly << newString+"\n"
}
} //reader
}
}
I try to build a short ocaml event example. But when I compile, the error in the title appears.
The question of: unbound module Event error when compiling Ocaml game was not helpful for me.
The system is Kubuntu 14.04 and I installed ocaml over aptitude, so installed packages are:
camlp4, ledit, libfindlib-ocaml, libfindlib-ocaml-dev, liboasis-ocaml, liboasis-ocaml-dev, libodn-ocaml, libodn-ocaml-dev, libtype-conv-camlp4-dev, oasis, ocaml, ocaml-base, ocaml-base-nox, ocaml-compiler-libs, ocaml-doc, ocaml-findlib, ocaml-interp, ocaml-native-compilers, ocaml-nox
The OCaml compiler is version 4.01.0
Here is my short test program.
open Thread;;
open Event;;
let chan = Event.new_channel();;
let a () =
Printf.printf "A waiting...\n";;
let sigRX = Event.receive chan in
Printf.printf "A received over channel\n";
let v = Event.sync sigRx in
Printf.printf "A running\n";
Printf.printf "A done!\n";;
let b () =
Thread.delay 0.8
Printf.printf "B sending...\n";;
let sigTX = Event.send "wake up" in
Event.sync sigTX;
Printf.printf "B done!\n";;
let t_a = Thread.create a ();;
let t_b = Thread.create b ();;
I tried to compile this single file (test.ml) with:
ocamlc -thread unix.cma threads.cma test.ml
The response is:
File "test.ml", line 2, characters 0-10:
Error: Unbound module Event
I googled, found some "thread-using-tips" like: http://caml.inria.fr/pub/docs/manual-ocaml/libthreads.html#c%3Athreads
In /usr/lib/ocaml is an threads folder and an thread.mli. Inside the threads folder there are this files:
-rw-r--r-- 1 root root 487 Jan 2 2014 condition.cmi
-rw-r--r-- 1 root root 487 Jan 2 2014 condition.cmx
-rw-r--r-- 1 root root 1203 Jan 2 2014 event.cmi
-rw-r--r-- 1 root root 1867 Jan 2 2014 event.cmx
-rw-r--r-- 1 root root 421 Jan 2 2014 mutex.cmi
-rw-r--r-- 1 root root 407 Jan 2 2014 mutex.cmx
-rw-r--r-- 1 root root 1859 Jan 2 2014 thread.cmi
-rw-r--r-- 1 root root 1308 Jan 2 2014 thread.cmx
-rw-r--r-- 1 root root 62778 Jan 2 2014 threads.a
-rw-r--r-- 1 root root 47047 Jan 2 2014 threads.cma
-rw-r--r-- 1 root root 1258 Jan 2 2014 threads.cmxa
-rw-r--r-- 1 root root 4145 Jan 2 2014 threadUnix.cmi
-rw-r--r-- 1 root root 1515 Jan 2 2014 threadUnix.cmx
What am I missing? I assume, that the Event is packed in Thread Module?
This command line works for me to get past the unbound module problem.
$ ocamlc -I +threads -c test.ml
There are errors in your code, but I imagine you'll know how to fix them.
This full command line will probably work, but I can't be sure because of the errors:
$ ocamlc -thread -I +threads unix.cma threads.cma test.ml
(There are some higher-level tools for building OCaml programs that you might want to learn about at some point.)