Re: [Haskell-cafe] static linking with ghc?

2012-04-25 Thread Ketil Malde
Johannes Waldmann waldm...@imn.htwk-leipzig.de writes:

 A similar thing is mentioned here (see Caveat)
 http://www.haskell.org/haskellwiki/Web/Literature/Static_linking

Another caveat is that shared linking isn't very useful on Linux, since
the C library loads various stuff dynamically anyway.  It'd be great to
be able to link to a different C library (maybe something from the
BSDs?).

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] static linking with ghc?

2012-04-22 Thread Johannes Waldmann
Hi.

I want to produce a statically linked executable.
I am trying 'ghc  --make -fforce-recomp -static -optl-static  Main'

but it gives lots of  errors like 
(.text+0xfa): undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status

A similar thing is mentioned here (see Caveat)
http://www.haskell.org/haskellwiki/Web/Literature/Static_linking

The ghc user guide talks a great length about shared libs
http://www.haskell.org/ghc/docs/latest/html/users_guide/using-shared-libs.html
but I don't see anything on how to switch this off.

- J.W.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] static linking with ghc?

2012-04-22 Thread Scott Lawrence

Adding -optl-pthread fixes it for me.

On Sun, 22 Apr 2012, Johannes Waldmann wrote:


Hi.

I want to produce a statically linked executable.
I am trying 'ghc  --make -fforce-recomp -static -optl-static  Main'

but it gives lots of  errors like
(.text+0xfa): undefined reference to `pthread_mutex_unlock'
collect2: ld returned 1 exit status

A similar thing is mentioned here (see Caveat)
http://www.haskell.org/haskellwiki/Web/Literature/Static_linking

The ghc user guide talks a great length about shared libs
http://www.haskell.org/ghc/docs/latest/html/users_guide/using-shared-libs.html
but I don't see anything on how to switch this off.

- J.W.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



--
Scott Lawrence

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] static linking with ghc?

2012-04-22 Thread Ivan Lazar Miljenovic
On 22 April 2012 22:33, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote:
 Hi.

 I want to produce a statically linked executable.
 I am trying 'ghc  --make -fforce-recomp -static -optl-static  Main'

 but it gives lots of  errors like
 (.text+0xfa): undefined reference to `pthread_mutex_unlock'
 collect2: ld returned 1 exit status

I believe this is due to C libraries that are used in GHC's RTS; all
Haskell libs are statically linked by default.


 A similar thing is mentioned here (see Caveat)
 http://www.haskell.org/haskellwiki/Web/Literature/Static_linking

 The ghc user guide talks a great length about shared libs
 http://www.haskell.org/ghc/docs/latest/html/users_guide/using-shared-libs.html
 but I don't see anything on how to switch this off.

 - J.W.



 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
http://IvanMiljenovic.wordpress.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] static linking with ghc?

2012-04-22 Thread Johannes Waldmann
Scott Lawrence bytbox at gmail.com writes:
 
 Adding -optl-pthread fixes it for me.

great! in my case, I also needed to add '-pgml g++'
and together, this seems to work. Thanks.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static linking for machines that don't have Haskell

2011-10-02 Thread Ketil Malde
Roshan James rpja...@umail.iu.edu writes:

 This gives me several warnings of the form:
 */usr/lib/haskell-packages/ghc6/lib/network-2.2.1.7/ghc-6.12.3/libHSnetwork-2.2.1.7.a(BSD.o):
 In function `sw4B_info':*
 *(.text+0x584c): warning: Using 'getservbyport' in statically linked
 applications requires at runtime the shared libraries from the glibc version
 used for linking*

Yes, the Linux libc doesn't really support static linking, and in fact
actively subverts it by dynamically loading other libraries from
hardwired paths. I'm sure there's a good reason for it.

Some things can be worked around by setting environment variables etc,
but generally, try to compile on the oldest system you can find (since
backwards compatibility is better supported than forward), and use the
same distribution.  Use strace to see what dynamic libraries your
executable tries to load, and Google to see what can be done about
them.

The best solution would be to use a different libc.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Static linking for machines that don't have Haskell

2011-09-30 Thread Roshan James
Hi All,

I am trying to run a Haskell program compiled on my Ubuntu box on a server
box that does not have GHC installed and where I dont have root privileges.
I run into several missing libraries, in particular libgmp, libffi and
libuuid (the later two are needed by my program). How I can statically link
my program such that I can run it on this server?

I have a tried static linking as follows:
*  ghc -static -optl-static -optl-pthread --make -o p main.hs*

This gives me several warnings of the form:
*/usr/lib/haskell-packages/ghc6/lib/network-2.2.1.7/ghc-6.12.3/libHSnetwork-2.2.1.7.a(BSD.o):
In function `sw4B_info':*
*(.text+0x584c): warning: Using 'getservbyport' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking*

And sure enough the generated executable segfaults on the server which has a
different glibc version.

Is there some way to static link all the other libraries needed except
glibc? I have looked around for an example of this but to no avail and the
output of the -v switch seemed a bit overwhelming. Or is there some other
way to go about doing this?

thanks in advance,
Roshan

ps. including these, in case they maybe of some use:

My machine:

*$ ldd p*
* linux-vdso.so.1 =  (0x7fff3000)*
* libncurses.so.5 = /lib/libncurses.so.5 (0x7fbdbbf4f000)*
* libuuid.so.1 = /lib/x86_64-linux-gnu/libuuid.so.1 (0x7fbdbbd4a000)*
* librt.so.1 = /lib/x86_64-linux-gnu/librt.so.1 (0x7fbdbbb41000)*
* libutil.so.1 = /lib/x86_64-linux-gnu/libutil.so.1 (0x7fbdbb93e000)*
* libdl.so.2 = /lib/x86_64-linux-gnu/libdl.so.2 (0x7fbdbb73a000)*
* libpthread.so.0 = /lib/x86_64-linux-gnu/libpthread.so.0
(0x7fbdbb51b000)*
* libgmp.so.3 = /usr/lib/libgmp.so.3 (0x7fbdbb2be000)*
* libffi.so.5 = /usr/lib/libffi.so.5 (0x7fbdbb0b6000)*
* libm.so.6 = /lib/x86_64-linux-gnu/libm.so.6 (0x7fbdbae3)*
* libc.so.6 = /lib/x86_64-linux-gnu/libc.so.6 (0x7fbdbaa9c000)*
* /lib64/ld-linux-x86-64.so.2 (0x7fbdbc1b5000)*

Server:

*$ ldd p*
*./p: /lib64/libuuid.so.1: no version information available (required by
./p)*
*linux-vdso.so.1 =  (0x7fffc51fd000)*
*libncurses.so.5 = /usr/lib64/libncurses.so.5 (0x0037bce0)*
*libuuid.so.1 = /lib64/libuuid.so.1 (0x0037b720)*
*librt.so.1 = /lib64/librt.so.1 (0x0037b5a0)*
*libutil.so.1 = /lib64/libutil.so.1 (0x0037bda0)*
*libdl.so.2 = /lib64/libdl.so.2 (0x0037b4a0)*
*libpthread.so.0 = /lib64/libpthread.so.0 (0x0037b520)*
*libgmp.so.3 = not found*
*libffi.so.5 = not found*
*libm.so.6 = /lib64/libm.so.6 (0x0037b4e0)*
*libc.so.6 = /lib64/libc.so.6 (0x0037b460)*
*/lib64/ld-linux-x86-64.so.2 (0x0037b420)*
*
*
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static linking problem // CentOS 5.5 - GHC 6.12.3

2011-03-16 Thread Ketil Malde
frode k mailingl...@klevstul.com writes:

 However I do of course want to run it through CGI on a webserver. I'm
 running lighttpd. If I try to run the file compiled above I get 500 -
 Internal Server Error, most likely since the enviroment is not correct for
 dynamic linked files:

Why wouldn't the environment (i.e. available dynamic libraries) be
correct for the web server?

 Hence I wanted to use static linking (
 http://www.haskell.org/haskellwiki/Web/Literature/Static_linking ). However
 trying to compile using the -optl-static option fails:
 There are two main categories of error messages above:

 1 : ...requires at runtime the shared libraries from the glibc version used
 for linking

Yes, Linux (or rather, glibc) doesn't really support static linking any
more, and relies on hard-coded paths to libraries for unicode stuff and
name resolution and authentication.  You can override this with
environment variables, though.

Perhaps this is helpful:
  http://blog.malde.org/index.php/2010/05/22/snagged/

 2a : undefined reference to `pthread_'

 2b : undefined reference to `pthread_mutex_lock'

  ghc ... -optl-static -optl-pthread
   ^
Not sure why you have to add this manually, but it's been this way for
years - at least since ghc 6.8, I think.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static linking problem // CentOS 5.5 - GHC 6.12.3

2011-03-16 Thread frode k
On Wed, Mar 16, 2011 at 8:05 AM, Ketil Malde ke...@malde.org wrote:

 frode k mailingl...@klevstul.com writes:

  However I do of course want to run it through CGI on a webserver. I'm
  running lighttpd. If I try to run the file compiled above I get 500 -
  Internal Server Error, most likely since the enviroment is not correct
 for
  dynamic linked files:

 Why wouldn't the environment (i.e. available dynamic libraries) be
 correct for the web server?


You are right, dynamically linked files do work.

It must be something with Lighttpd that prevents the Haskell compiled CGI
code to be executed. When I moved the exact same CGI file to the cgi-bin
directory on my Apache it ran without problems.

If I do find out why I can not run Haskell CGI on Lighttpd I will send an
update on this.

Thanks for your feedback.

Regards,
Frode
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static linking problem // CentOS 5.5 - GHC 6.12.3

2011-03-16 Thread J . Waldmann

 Why wouldn't the environment (i.e. available dynamic libraries) be
 correct for the web server?

beacuse it runs CGI programs in a chroot jail?

Then you need to copy the .so files into the jail, cf.
http://www.cyberciti.biz/tips/howto-setup-lighttpd-php-mysql-chrooted-jail.html

J.W.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static linking problem // CentOS 5.5 - GHC 6.12.3

2011-03-16 Thread frode k
I had missed out some settings in the configuration files of lighttpd.

Summary:
- I renamed the Haskell test file to haskell.hcgi
- I edited /etc/lighttpd/conf.d/cgi.conf and added two entries in the
cgi.assign section, one for .hcgi and one for .hs (the latter one only
to enable running of .hs files / uncompiled Haskell code for testing
purposes).

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cgi.assign = ( .pl  = /usr/bin/perl,
   .cgi = /usr/bin/perl,
   .rb  = /usr/bin/ruby,
   .erb = /usr/bin/eruby,
   .py  = /usr/bin/python,
   .hcgi= ,
   .hs  = /usr/haskell/bin/runhaskell)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

After a lighttpd restart I can now access both .hs files (for testing
purposes, since performance assumingly won't be top notch here) and compiled
.hcgi files. If I did not need to use perl for .cgi I could have change the
setting for .cgi pointing to empty () in stead of adding a new entry for
.hcgi / Haskell CGI.

Regards,
Frode
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Static linking problem // CentOS 5.5 - GHC 6.12.3

2011-03-15 Thread frode k
I've installed GHC version 6.12.3 on CentOS 5.5 x86_64. I'm trying to run a
very simple Haskell program as CGI following the guide at:
http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell

My .hs file I'm trying to use looks like this:
--
import Network.CGI
import Text.XHtml

page :: Html
page = body  h1  Hello World!

cgiMain :: CGI CGIResult
cgiMain = output $ renderHtml page

main :: IO ()
main = runCGI $ handleErrors cgiMain
--

If I compile it using dynamic linking I can run it from the command line,
since the environment is correct:

# ghc haskell_v2.hs --make -o haskell_v2.cgi
Linking haskell_v2.cgi ...
# ./haskell_v2.cgi
Content-type: text/html; charset=ISO-8859-1

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;
body
  h1
Hello World!/h1
/body
  /html

[root@vps-1040050-2953 haskellTest]#

However I do of course want to run it through CGI on a webserver. I'm
running lighttpd. If I try to run the file compiled above I get 500 -
Internal Server Error, most likely since the enviroment is not correct for
dynamic linked files:

# ldd haskell_v2.cgi
librt.so.1 = /lib64/librt.so.1 (0x2aff22c25000)
libutil.so.1 = /lib64/libutil.so.1 (0x2aff22e2e000)
 libdl.so.2 = /lib64/libdl.so.2 (0x2aff23031000)
libgmp.so.3 = /usr/lib64/libgmp.so.3 (0x2aff23236000)
 libm.so.6 = /lib64/libm.so.6 (0x2aff2346f000)
libc.so.6 = /lib64/libc.so.6 (0x2aff236f2000)
 libpthread.so.0 = /lib64/libpthread.so.0 (0x2aff23a4a000)
/lib64/ld-linux-x86-64.so.2 (0x2aff22a08000)
# file haskell_v2.cgi
haskell_v2.cgi: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for
GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9,
not stripped

Hence I wanted to use static linking (
http://www.haskell.org/haskellwiki/Web/Literature/Static_linking ). However
trying to compile using the -optl-static option fails:

# ghc haskell_v2.hs --make -optl-static -fforce-recomp -o haskell_v2.cgi
[1 of 1] Compiling Main ( haskell_v2.hs, haskell_v2.o )
Linking haskell_v2.cgi ...
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(HsNet.o): In
function `hsnet_getaddrinfo':
HsNet.c:(.text+0x11): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`sAwu_info':
(.text+0xd45d): warning: Using 'gethostbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`syh4_info':
(.text+0x4364): warning: Using 'gethostbyname' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`sygm_info':
(.text+0x424f): warning: Using 'gethostent' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`syx3_info':
(.text+0x5318): warning: Using 'sethostent' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`sxz5_info':
(.text+0x12c6): warning: Using 'endhostent' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`syJY_info':
(.text+0x605d): warning: Using 'getnetbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`sycm_info':
(.text+0x3e75): warning: Using 'getnetbyname' in statically linked
applications requires at runtime the shared libraries from the glibc version
used for linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`sybC_info':
(.text+0x3de7): warning: Using 'getnetent' in statically linked applications
requires at runtime the shared libraries from the glibc version used for
linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`syyg_info':
(.text+0x5458): warning: Using 'setnetent' in statically linked applications
requires at runtime the shared libraries from the glibc version used for
linking
/usr/local/lib/network-2.3/ghc-6.12.3/libHSnetwork-2.3.a(BSD.o): In function
`sxz5_info':
(.text+0x1296): warning: Using 'endnetent' in statically linked applications
requires at runtime the 

Re: [Haskell-cafe] Static Linking Problem

2009-11-12 Thread Svein Ove Aas
On Thu, Nov 12, 2009 at 8:57 AM, David Virebayre
dav.vire+hask...@gmail.com wrote:
 On Wed, Nov 11, 2009 at 5:44 PM, Svein Ove Aas svein@aas.no wrote:

 My recommendation would be to take glibc off the list of statically
 linked libraries.

 How do you do that ?

By specifying the entire list manually, and not naming glibc.

-- 
Svein Ove Aas
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static Linking Problem

2009-11-11 Thread MightyByte
On Tue, Nov 10, 2009 at 4:29 PM, Ketil Malde ke...@malde.org wrote:
 MightyByte mightyb...@gmail.com writes:

 After a bit of googling, I came to the conclusion that I needed to
 compile it with ghc --make -static -optl-static Foo.hs.  Using only
 -static or -optl-static by themselves did not generate a
 statically linked binary.  But when I compile with both those
 parameters I get a bunch of linker errors:
  [..]
 (.text+0x59c): undefined reference to `pthread_mutex_lock'

 For some reason, GHC doesn't link with the pthreads library, so you need
 to compile (link) with two options: -opt-static -optl-pthread

Excellent, that appears to have solved my problem.  It still gives me
the warning:

(.text+0x3068): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking

But glibc is pretty standard, so I don't think this will be a problem
for me.  Thanks for the help.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static Linking Problem

2009-11-11 Thread Svein Ove Aas
On Wed, Nov 11, 2009 at 3:22 PM, MightyByte mightyb...@gmail.com wrote:

 (.text+0x3068): warning: Using 'getaddrinfo' in statically linked
 applications requires at runtime the shared libraries from the glibc
 version used for linking

 But glibc is pretty standard, so I don't think this will be a problem
 for me.  Thanks for the help.

You may have unexpected results.

That warning occurs because some of glibc (namely, the getaddrinfo
bit) is dynamically linked regardless of what you want; this is
apparently to make NSS work, or something along those lines.

However, if you then link the rest of glibc statically, you get
dependencies between your program and the installed glibc, for
internal, unstable APIs. (!)

This is generally a Big No. Doing this means your program definitely
won't be compatible with older versions of glibc, but it probably
wouldn't be either way. However, in this case it also won't be
compatible with *newer* versions of glibc.

My recommendation would be to take glibc off the list of statically
linked libraries.


-- 
Svein Ove Aas
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static Linking Problem

2009-11-11 Thread David Virebayre
On Wed, Nov 11, 2009 at 5:44 PM, Svein Ove Aas svein@aas.no wrote:

 My recommendation would be to take glibc off the list of statically
 linked libraries.

How do you do that ?

David.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Static Linking Problem

2009-11-10 Thread MightyByte
I am trying to statically compile a simple haskell program so I can
use it on a Linux computer without haskell and it's associated
libraries.  Here is a small example program that illustrates my
problem:

 module Main where
 import Network.Fancy
 main = do
   withDgram (IP 127.0.0.1 1234) (flip send Hello network\n)

After a bit of googling, I came to the conclusion that I needed to
compile it with ghc --make -static -optl-static Foo.hs.  Using only
-static or -optl-static by themselves did not generate a
statically linked binary.  But when I compile with both those
parameters I get a bunch of linker errors:

/home/mightybyte/.cabal/lib/network-fancy-0.1.4/ghc-6.10.4/libHSnetwork-fancy-0.1.4.a(Fancy.o):
In function `s6ks_info':
(.text+0x3068): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/lib/ghc-6.10.4/libffi.a(closures.o): In function `init_mparams':
(.text+0x3e): undefined reference to `pthread_mutex_lock'
/usr/lib/ghc-6.10.4/libffi.a(closures.o): In function `init_mparams':
(.text+0x52): undefined reference to `pthread_mutex_unlock'
/usr/lib/ghc-6.10.4/libffi.a(closures.o): In function `init_mparams':
(.text+0xd3): undefined reference to `pthread_mutex_init'
/usr/lib/ghc-6.10.4/libffi.a(closures.o): In function
`ffi_closure_free':
(.text+0x59c): undefined reference to `pthread_mutex_lock'

etc...

I've tried this on both Fedora and Arch Linux and I get the same
error.  Anyone know how to solve this problem?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static Linking Problem

2009-11-10 Thread Ketil Malde
MightyByte mightyb...@gmail.com writes:

 After a bit of googling, I came to the conclusion that I needed to
 compile it with ghc --make -static -optl-static Foo.hs.  Using only
 -static or -optl-static by themselves did not generate a
 statically linked binary.  But when I compile with both those
 parameters I get a bunch of linker errors:
  [..]
 (.text+0x59c): undefined reference to `pthread_mutex_lock'

For some reason, GHC doesn't link with the pthreads library, so you need
to compile (link) with two options: -opt-static -optl-pthread 

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Static linking

2009-07-24 Thread Michael Oswald
Hello,


I wrote a small installer program which configures and installs some software
packages. In order to be able to let it run on a different machine, where I
possibly don't have the needed shared libraries, I tried to link it
statically, following this advice:

http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Deployin
g_statically_linked_applications

However I get some linking errors:

 ghc --make Installer.hs -static -optl-static

/usr/lib/ghc-6.10.3/unix-2.3.2.0/libHSunix-2.3.2.0.a(User__143.o)(.text+0xf1):

In function `s7Tu_info':
: warning: Using 'getgrnam_r' in statically linked applications requires at 
runtime the shared libraries from the glibc version used for linking 
/usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../../libedit.a(readline.o)(.text+0x7b
2):

In function `username_completion_function': 
/home/oswald/build/libedit-20090610-3.0/src/readline.c:1467:0:
 warning: Using 'getpwent' in statically linked applications requires at
runtime the shared libraries from the glibc version used for linking

src/dlmalloc.c:2486:0:  undefined reference to `pthread_mutex_lock'
/usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x132):src/dlmalloc.c:2493:
undefined reference to `pthread_mutex_unlock'
/usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x184):src/dlmalloc.c:2490:
undefined reference to `pthread_mutex_init'
/usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x227): In function
`ffi_closure_free':


Because of the undefined references to pthread_mutex_lock I then 
tried various versions of 

ghc --make Installer.hs -static -optl-static -lpthread -lrt

and reordered the -l switches, but neither combination helped. I always get the
same error.

Does somebody know how to correctly specify the pthread library for this?


lg,
Michael



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Static linking

2009-07-24 Thread Marcin Kosiba
On Friday 24 July 2009, Michael Oswald wrote:
 Hello,


 I wrote a small installer program which configures and installs some
 software packages. In order to be able to let it run on a different
 machine, where I possibly don't have the needed shared libraries, I tried
 to link it statically, following this advice:

 http://www.haskell.org/haskellwiki/Practical_web_programming_in_Haskell#Dep
loyin g_statically_linked_applications

 However I get some linking errors:

  ghc --make Installer.hs -static -optl-static

 /usr/lib/ghc-6.10.3/unix-2.3.2.0/libHSunix-2.3.2.0.a(User__143.o)(.text+0xf
1):

 In function `s7Tu_info':
 : warning: Using 'getgrnam_r' in statically linked applications requires at

 runtime the shared libraries from the glibc version used for linking
 /usr/lib/gcc-lib/i586-suse-linux/3.3.3/../../../libedit.a(readline.o)(.text
+0x7b 2):

 In function `username_completion_function':
 /home/oswald/build/libedit-20090610-3.0/src/readline.c:1467:0:
  warning: Using 'getpwent' in statically linked applications requires
 at runtime the shared libraries from the glibc version used for linking

 src/dlmalloc.c:2486:0:  undefined reference to `pthread_mutex_lock'
 /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x132):src/dlmalloc.c:2493:
 undefined reference to `pthread_mutex_unlock'
 /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x184):src/dlmalloc.c:2490:
 undefined reference to `pthread_mutex_init'
 /usr/lib/ghc-6.10.3/libffi.a(closures.o)(.text+0x227): In function
 `ffi_closure_free':


 Because of the undefined references to pthread_mutex_lock I then
 tried various versions of

 ghc --make Installer.hs -static -optl-static -lpthread -lrt

 and reordered the -l switches, but neither combination helped. I always get
 the same error.

 Does somebody know how to correctly specify the pthread library for this?

Hi,
Try:
ghc --make Installer.hs -static -optl-static -optl-pthread

If that doesn't work, you can always do a ghc -v, find the command it uses for 
linking, modify it and run it manually.

Thanks!
Marcin Kosiba


signature.asc
Description: This is a digitally signed message part.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] static linking failure -- can't find crt0

2008-09-14 Thread Jason Dusek
  I'm building a really static executable on OS X with options
  `-optl-static -static` and, while the libraries seem to link
  fine, the executable itself does not -- it can't find the C
  runtime.

  This is actually by design -- Apple does not support static
  binaries. There is a work around -- just symlink stuff till
  the errors go away -- but it might be better if I could
  statically link only those C libraries that I knew were not on
  stock Macs. Are there GHC options for that?

  I assume this all works fine on Linux and Windows, but I'll
  know soon enough...

--
_jsn


 |...can't find the C runtime.|
  ld_classic: can't locate file for: -lcrt0.o
  collect2: ld returned 1 exit status

 |does not support|
  http://developer.apple.com/qa/qa2001/qa1118.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe