Re: [Haskell-cafe] Failed link to mixed-language shared object
ghc -dynamic -o ami_test -L. -lami ami_test.o ./libami.so: undefined reference to `__stginit_haskell98_MarshalArray_' ./libami.so: undefined reference to `__stginit_haskell98_MarshalError_' collect2: ld returned 1 exit status I was able to solve this by changing these lines: import MarshalArray import MarshalError to read: import Foreign.Marshal.Array import Foreign.Marshal.Error I don't understand why this worked, since the available symbols in the 2 respective libraries appear totally similar: dbanas@dbanas-eeepc:/usr/lib/ghc-6.12.3$ nm -g haskell98-1.0.1.1/libHShaskell98-1.0.1.1.a | grep 'MarshalArray' MarshalArray__1.o: 0030 T __stginit_haskell98_MarshalArray T __stginit_haskell98_MarshalArray_ dbanas@dbanas-eeepc:/usr/lib/ghc-6.12.3$ nm -g -D haskell98-1.0.1.1/libHShaskell98-1.0.1.1-ghc6.12.3.so | grep 'MarshalArray' 2b68 T __stginit_haskell98_MarshalArray 2b24 T __stginit_haskell98_MarshalArray_dyn dbanas@dbanas-eeepc:/usr/lib/ghc-6.12.3$ nm -g base-4.2.0.2/libHSbase-4.2.0.2.a | grep '__stginit_.*Foreign.*Marshal.*Array' 006c T __stginit_base_ForeignziMarshalziArray T __stginit_base_ForeignziMarshalziArray_ {Some output omitted.} dbanas@dbanas-eeepc:/usr/lib/ghc-6.12.3$ nm -g -D base-4.2.0.2/libHSbase-4.2.0.2-ghc6.12.3.so | grep '__stginit_.*Foreign.*Marshal.*Array' 003dc8cc T __stginit_base_ForeignziMarshalziArray 003dc834 T __stginit_base_ForeignziMarshalziArray_dyn Can anyone shed some light on this? Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Failed link to mixed-language shared object.
On Thu, 2011-08-18 at 20:32 -0700, David Banas wrote: Hi all, Does this trigger recollection in anyone: dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ make ghc -dynamic -o ami_test -L. -lami ami_test.o ./libami.so: undefined reference to `__stginit_haskell98_MarshalArray_' ./libami.so: undefined reference to `__stginit_haskell98_MarshalError_' collect2: ld returned 1 exit status make: *** [ami_test] Error 1 dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ ? Know what I need to do? Thanks, -db So, I was able to make my link errors go away, by adding `-shared' to my command line: dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ make ghc -no-hs-main -shared -dynamic -o ami_test -L. -lami ami_test.o However, when I try to execute the resultant program, I get a segmentation fault: dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ ./ami_test test.ami Segmentation fault Tracing this shows that the `main' pointer of the program appears to be NULL: dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ gdb --args ./ami_test test.ami GNU gdb (GDB) 7.1-ubuntu Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i486-linux-gnu. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /home/dbanas/prj/haskell/AMIParse/trunk/ami_test...done. (gdb) l 2 #include stdlib.h 3 #include string.h 4 //#include HsFFI.h 5 #include ami_model.h 6 7 #define DEF_AMI_FILE test.ami 8 #define VEC_SIZE 8 9 #define MAX_LINE_LEN 256 10 11 int main(int argc, char *argv[]) { (gdb) b 11 Breakpoint 1 at 0x87d: file ami_test.c, line 11. (gdb) run Starting program: /home/dbanas/prj/haskell/AMIParse/trunk/ami_test test.ami Program received signal SIGSEGV, Segmentation fault. 0x0002 in ?? () I assume that's because of the `-shared' flag. Any thoughts? Thanks, -db ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Failed link to mixed-language shared object.
Hi all, Does this trigger recollection in anyone: dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ make ghc -dynamic -o ami_test -L. -lami ami_test.o ./libami.so: undefined reference to `__stginit_haskell98_MarshalArray_' ./libami.so: undefined reference to `__stginit_haskell98_MarshalError_' collect2: ld returned 1 exit status make: *** [ami_test] Error 1 dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ ? Know what I need to do? Thanks, -db ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Failed link to mixed-language shared object.
On Thu, Aug 18, 2011 at 23:32, David Banas dba...@banasfamily.net wrote: Does this trigger recollection in anyone: dbanas@dbanas-eeepc:~/prj/haskell/AMIParse/trunk$ make ghc -dynamic -o ami_test -L. -lami ami_test.o ./libami.so: undefined reference to `__stginit_haskell98_MarshalArray_' ./libami.so: undefined reference to `__stginit_haskell98_MarshalError_' First thing to try is always --make; GHC's default behavior is, shall we say, not optimal otherwise. (I consider it highly broken; somewhere in there the default is *supposedly* going to change to --make, I believe.) If you want to try to make it work the ugly old way, the symbol names suggest to me that -package haskell98 would help. -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe