fpco / inline-c

284 stars 50 forks source link

"How to build" section missing #60

Closed dschoepe closed 7 years ago

dschoepe commented 7 years ago

The beginning of README.md mentions a "How to build" section. However, the section no longer exists in the README and using inline-c as is causes linker errors. It seems the section was removed in commit https://github.com/fpco/inline-c/commit/ffb1f9373cc4709d45fd66b6a6b3ce0ef64983c7.

The instructions there still work and fix the linking errors that occur for me otherwise. Is specifying c-sources etc. in the cabal file still required or should one handle this another way now?

Here's a counter example that fails for me when following the current documentation:

import qualified Language.C.Inline as C
import Foreign.C.Types

test :: IO CInt
test = [C.exp| int{ 5 } |]

I get the following error in a default stack project when running stack build without specifying c-sources:

foo-0.1.0.0: build (lib + exe)
Preprocessing library foo-0.1.0.0...
Preprocessing executable 'foo-exe' for foo-0.1.0.0...
[1 of 1] Compiling Main             ( app/Main.hs, .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/foo-exe/foo-exe-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/foo-exe/foo-exe ...
.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0/build/foo-exe/foo-exe-tmp/Main.o: In function `reTq_info':
(.text+0x81): undefined reference to `inline_c_Main_0_921171f2b48eb376e54be5ffe69dc76ea2dff9c3'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building package foo-0.1.0.0 using:
      /home/daniel/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.2.0 build lib:foo exe:foo-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
bitonic commented 7 years ago

the current readme refers to the current version, which does not require a separate linking step. please refer to the readme of the version you're using.

you're right that there is a broken reference though, i'll fix.

bitonic commented 7 years ago

amended the readme in 30bf69fbd77796cc74016e630ce2f4718a282da6 .