#5101: GHC and GHCi use different syntax for dynamic libraries
---------------------------------------------------+------------------------
Reporter: mcandre | Owner:
Type: feature request | Status: infoneeded
Priority: normal | Milestone: 7.2.1
Component: Compiler | Version: 7.0.3
Keywords: ghc ghci dylib load compile c2hs c | Testcase:
Blockedby: | Difficulty:
Os: MacOS X | Blocking:
Architecture: Unknown/Multiple | Failure: Incorrect
warning at compile-time
---------------------------------------------------+------------------------
Changes (by mcandre):
* keywords: => ghc ghci dylib load compile c2hs c
* architecture: x86 => Unknown/Multiple
Comment:
{{{
$ gcc -march=i686 -m32 -lcharm hellocharm.c
Undefined symbols:
"_start_charm", referenced from:
_main in ccfP9YO9.o
"_end_charm", referenced from:
_main in ccfP9YO9.o
"_vcenter_string", referenced from:
_main in ccfP9YO9.o
"_get_key", referenced from:
_main in ccfP9YO9.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
}}}
{{{
$ gcc -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5
-lcharm hellocharm.c
ld: library not found for -lcharm
collect2: ld returned 1 exit status
}}}
The {{{ -search_paths_first }}} one seems to work, producing an {{{ a.out
}}} that works just like https://github.com/mcandre/charm#readme
{{{
$ gcc -lcharm -Wl,-search_paths_first hellocharm.c
wonko:charm andrew$ mate .
wonko:charm andrew$ ./a.out
}}}
{{{
$ gcc -march=i686 -m32 -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-
version-min=10.5 -lcharm -Wl,-search_paths_first hellocharm.c
ld: library not found for -lcharm
collect2: ld returned 1 exit status
}}}
The makefile that works for me:
https://github.com/mcandre/charm/blob/master/Makefile
{{{
gcc -c charm.c charm.h
gcc -arch i386 -arch x86_64 -dynamiclib -o libcharm.dylib -flat_namespace
charm.o
ld: warning: in charm.o, file was built for unsupported file format which
is not the architecture being linked (i386)
gcc -o hellocharm hellocharm.c -Wall -I/usr/include -L. -lcharm
}}}
Apple does a poor job explaining how to create dylibs, so I don't expect
my makefile to be the best.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5101#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs