Error Message: Can not find C library. How can I do this?

Hello.
I’m new to stack & FFI.
I created a dll file by http://www.mingw.org/wiki/sampleDLL
And I put all files into dll folder. (Those files are example_dll.cpp,
example_dll.dll, example_dll.h, example_dll.o, example_exe.cpp,
libexample_dll.a) I test example_exe.exe file, and confirmed that works.
(Windows7 Pro, stack 1.9.3)

Did you try setting environment variable LIBRARY_PATH?
Something like:
Set LIBRARY_PATH=%LIBRARY_PATH%;C:\wxWidgets\lib
You might need to set C_INCLUDE_PATH as well, for the header files.
Regards,
Henk-Jan van Tuyl
On Tue, 26 Feb 2019 07:47:59 +0100, S. H. Aegis
Hello.
I’m new to stack & FFI.
I created a dll file by http://www.mingw.org/wiki/sampleDLL
[...]
*Configuring test2-0.1.0.0...* *Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe: Missing dependency on a foreign* *library:* ** Missing (or bad) C library: example_dll.a* [...] How can I fix this? I did a lot of things on the webpages, but I could not.
Please, help me.
Sincerely, S. Chang.
-- Message from Stanford University: Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://foldingathome.stanford.edu/ -- http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --

Thank you to your kind reply. =)
I tried several times, but still got a same error message. (ㅠㅠ)
But I'm going to googling with key-word that you told me.
Thank you again.
Best reguard
S. Chang.
2019년 3월 2일 (토) 오전 3:03, Henk-Jan van Tuyl
Did you try setting environment variable LIBRARY_PATH? Something like: Set LIBRARY_PATH=%LIBRARY_PATH%;C:\wxWidgets\lib You might need to set C_INCLUDE_PATH as well, for the header files.
Regards, Henk-Jan van Tuyl
On Tue, 26 Feb 2019 07:47:59 +0100, S. H. Aegis
wrote: Hello.
I’m new to stack & FFI.
I created a dll file by http://www.mingw.org/wiki/sampleDLL
[...]
*Configuring test2-0.1.0.0...* *Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe: Missing dependency on a foreign* *library:* ** Missing (or bad) C library: example_dll.a* [...] How can I fix this? I did a lot of things on the webpages, but I could not.
Please, help me.
Sincerely, S. Chang.
-- Message from Stanford University:
Folding@home
What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://foldingathome.stanford.edu/
-- http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-- Sok Ha, CHANG Dr. Chang's Clinic. #203. 503-23. AmSa-Dong, GangDong-Gu, Seoul. Tel: +82-2-442-7585

You made a small typo: example_dll.cpp, example_dll.dll, example_dll.h, example_dll.o, example_exe.cpp, *libexample_dll.a* And in your code, you call it example_dll.a instead of libexample_dll.a:
extra-libraries: - example_dll.a
That should probably be:
extra-libraries:
- libexample_dll.a
On Tue, Feb 26, 2019 at 7:48 AM S. H. Aegis
Hello.
I’m new to stack & FFI.
I created a dll file by http://www.mingw.org/wiki/sampleDLL
And I put all files into dll folder. (Those files are example_dll.cpp, example_dll.dll, example_dll.h, example_dll.o, example_exe.cpp, libexample_dll.a) I test example_exe.exe file, and confirmed that works.
(Windows7 Pro, stack 1.9.3)
executables:
test2-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- test2
extra-libraries:
- example_dll.a
extra-lib-dirs:
- dll
# Extra directories used by stack for building
extra-include-dirs:
- dll
extra-lib-dirs:
- dll
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
-- import Lib
import Foreign
foreign import ccall "example_dll.h hello"
c_hello :: IO()
main :: IO ()
main = c_hello
#include
#include "example_dll.h"
__stdcall void hello(const char *s)
{
printf("Hello %s\n", s);
}
int Double(int x)
{
return 2 * x;
}
void CppFunc(void)
{
puts("CppFunc");
}
void MyClass::func(void)
{
puts("MyClass.func()");
}
When I try to stack build, I get error messages.
*C:\Users\shaegis\Documents\Haskell\test2\dll>stack build*
*Building all executables for `test2' once. After a successful build of all of them, only specified executables will be rebuilt.*
*test2-0.1.0.0: configure (lib + exe)*
*Configuring test2-0.1.0.0...*
*Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe: Missing dependency on a foreign*
*library:*
** Missing (or bad) C library: example_dll.a*
*This problem can usually be solved by installing the system package that*
*provides this library (you may need the "-dev" version). If the library is*
*already installed but in a non-standard location then you can use the flags*
*--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the*
*library file does exist, it may contain errors that are caught by the C*
*compiler at the preprocessing stage. In this case you can re-run configure*
*with the verbosity flag -v3 to see the error messages.*
*-- While building package test2-0.1.0.0 using:*
* C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe --builddir=.stack-work\dist\e626a42b configure --with-ghc=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.3\bin\ghc.EXE --with-ghc-pkg=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.3\bin\ghc-pkg.EXE --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\3233b5e2\pkgdb --package-db=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\pkgdb --libdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\lib --bindir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\bin --datadir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\share --libexecdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\libexec --sysconfdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\etc --docdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\doc\test2-0.1.0.0 --htmldir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\doc\test2-0.1.0.0 --haddockdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\doc\test2-0.1.0.0 --dependency=base=base-4.12.0.0 --extra-include-dirs=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include --extra-include-dirs=C:\Users\shaegis\Documents\Haskell\test2\dll --extra-lib-dirs=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\bin --extra-lib-dirs=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\lib --extra-lib-dirs=C:\Users\shaegis\Documents\Haskell\test2\dll --enable-tests --enable-benchmarks*
*Process exited with code: ExitFailure 1*
How can I fix this? I did a lot of things on the webpages, but I could not.
Please, help me.
Sincerely, S. Chang. _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

Thank you to your kind reply. =)
Unfortunately, I've got same error message.
Thank you again.
Best reguard
S. Chang.
2019년 3월 2일 (토) 오전 4:42, Edgar Klerks
You made a small typo:
example_dll.cpp, example_dll.dll, example_dll.h, example_dll.o, example_exe.cpp, *libexample_dll.a*
And in your code, you call it example_dll.a instead of libexample_dll.a:
extra-libraries: - example_dll.a
That should probably be:
extra-libraries: - libexample_dll.a
On Tue, Feb 26, 2019 at 7:48 AM S. H. Aegis
wrote: Hello.
I’m new to stack & FFI.
I created a dll file by http://www.mingw.org/wiki/sampleDLL
And I put all files into dll folder. (Those files are example_dll.cpp, example_dll.dll, example_dll.h, example_dll.o, example_exe.cpp, libexample_dll.a) I test example_exe.exe file, and confirmed that works.
(Windows7 Pro, stack 1.9.3)
executables:
test2-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- test2
extra-libraries:
- example_dll.a
extra-lib-dirs:
- dll
# Extra directories used by stack for building
extra-include-dirs:
- dll
extra-lib-dirs:
- dll
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
-- import Lib
import Foreign
foreign import ccall "example_dll.h hello"
c_hello :: IO()
main :: IO ()
main = c_hello
#include
#include "example_dll.h"
__stdcall void hello(const char *s)
{
printf("Hello %s\n", s);
}
int Double(int x)
{
return 2 * x;
}
void CppFunc(void)
{
puts("CppFunc");
}
void MyClass::func(void)
{
puts("MyClass.func()");
}
When I try to stack build, I get error messages.
*C:\Users\shaegis\Documents\Haskell\test2\dll>stack build*
*Building all executables for `test2' once. After a successful build of all of them, only specified executables will be rebuilt.*
*test2-0.1.0.0: configure (lib + exe)*
*Configuring test2-0.1.0.0...*
*Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe: Missing dependency on a foreign*
*library:*
** Missing (or bad) C library: example_dll.a*
*This problem can usually be solved by installing the system package that*
*provides this library (you may need the "-dev" version). If the library is*
*already installed but in a non-standard location then you can use the flags*
*--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the*
*library file does exist, it may contain errors that are caught by the C*
*compiler at the preprocessing stage. In this case you can re-run configure*
*with the verbosity flag -v3 to see the error messages.*
*-- While building package test2-0.1.0.0 using:*
* C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.4.0.1_ghc-8.6.3.exe --builddir=.stack-work\dist\e626a42b configure --with-ghc=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.3\bin\ghc.EXE --with-ghc-pkg=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.3\bin\ghc-pkg.EXE --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\3233b5e2\pkgdb --package-db=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\pkgdb --libdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\lib --bindir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\bin --datadir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\share --libexecdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\libexec --sysconfdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\etc --docdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\doc\test2-0.1.0.0 --htmldir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\doc\test2-0.1.0.0 --haddockdir=C:\Users\shaegis\Documents\Haskell\test2\.stack-work\install\784ab3f0\doc\test2-0.1.0.0 --dependency=base=base-4.12.0.0 --extra-include-dirs=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\include --extra-include-dirs=C:\Users\shaegis\Documents\Haskell\test2\dll --extra-lib-dirs=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\bin --extra-lib-dirs=C:\Users\shaegis\AppData\Local\Programs\stack\x86_64-windows\msys2-20180531\mingw64\lib --extra-lib-dirs=C:\Users\shaegis\Documents\Haskell\test2\dll --enable-tests --enable-benchmarks*
*Process exited with code: ExitFailure 1*
How can I fix this? I did a lot of things on the webpages, but I could not.
Please, help me.
Sincerely, S. Chang. _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-- Sok Ha, CHANG Dr. Chang's Clinic. #203. 503-23. AmSa-Dong, GangDong-Gu, Seoul. Tel: +82-2-442-7585
participants (3)
-
Edgar Klerks
-
Henk-Jan van Tuyl
-
S. H. Aegis