July 2017
Intermediate to advanced
284 pages
6h 45m
English
Before we begin, we need to make our C code accessible. All we have at the moment is some text files. Let’s compile them into something we can use.
| | $ gcc -shared caesar.c -o caesar.so |
| | # Depending on your OS and compiler version |
| | # you may need to do the following |
| | $ gcc -fPIC -shared caesar.c -o caesar.so |
| | # You may also need to set LD_LIBRARY_PATH as well |
| | $ export LD_LIBRARY_PATH=. |
We can now invoke GHCi and try out our code.
| | $ stack exec ghci caesar.hs caesar.so |
| | GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help |
| | [1 of 1] Compiling Main ( caesar.hs, interpreted ) |
| | Ok, modules loaded: Main. |
| | *Main> caesar 2 "ATTACKATDAWN" |
| | "CVVCEMCVFCYP" |
| | *Main> native_caesar 2 "ATTACKATDAWN" |
| | "CVVCEMCVFCYP" |
We can ...
Read now
Unlock full access