Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Trying to compile IrRegex with Gambit-C on OSX

51 views
Skip to first unread message

Armando Blancas

unread,
Apr 20, 2012, 7:23:51 PM4/20/12
to
gcc: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
gsc: v4.6.4 20120210052234 i386-apple-darwin10.8.0 "./configure '--enable-single-host' '--enable-shared'"
os: Darwin 10.8.0 x86_64 i386

I've been trying to compile IrRegex 0.8.3 with the following commands as shown in section 3.4.3, page 18, Building a shared-library, with the following warning at the end:

$ gsc -c irregex.scm
$ gsc -link irregex.c
$ gsc -obj -cc-options "-D___SHARED" irregex.c
$ gcc -shared irregex.o -o irregex.so
ld: warning: in irregex.o, file was built for i386 which is not the architecture being linked (x86_64)

I tried to fix the problem by compiling with -arch x86_64, but then the problem is a lot of symbols not found:

gcc -arch x86_64 -no-cpp-precomp -Wno-unused -Wno-write-strings -O2 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fno-move-loop-invariants -fPIC -fno-common -mieee-fp -D___SINGLE_HOST -I"/usr/local/Gambit-C/include" -o "irregex.o" -D___SHARED irregex.c

If, instead, I add the switch -arch i386 to the last command, I get some other symbols not found:

gcc -shared -arch i386 irregex.o -o irregex.so

Now, despite the warning in my first attempt, I actually got an .so file:
$ ls -l irregex.so
-rwxr-xr-x 1 ablancas staff 4168 Apr 20 16:06 irregex.so

So I wrote a test program to see if the new lib was usable and it turned out that the test program as well as libgambc.dylib produce the same warning.

~/xtra/hacks/scheme/scripting $ gsc -link irtest.scm
*** WARNING -- "irregex-replace" is not defined,
*** referenced in: ("/Users/ablancas/xtra/hacks/scheme/scripting/irtest.c")
*** WARNING -- "string->irregex" is not defined,
*** referenced in: ("/Users/ablancas/xtra/hacks/scheme/scripting/irtest.c")
~/xtra/hacks/scheme/scripting $ gsc -obj irtest.c irtest_.c
irtest.c:
irtest_.c:
$ gcc irtest.o irtest_.o irregex.so -lgambc -L/usr/local/Gambit-C/lib
ld: warning: in irtest.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in irtest_.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /usr/local/Gambit-C/lib/libgambc.dylib, file was built for i386 which is not the architecture being linked (x86_64)
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

At this point I'm stuck and will appreciate some help.

Brad Lucier

unread,
Apr 20, 2012, 7:49:37 PM4/20/12
to
I don't understand why you want a .so file.

It's fairly easy to get a compiled library you can "load" into gambit.

% gsc irregex

should work.

I've installed Gambit with too much optimization levels, so this
command doesn't work (it takes about 8GB of RAM and I got impatient
with waiting), so I write a small wrapper, irregex-gambit.scm, which
defines some options to make the compiled C file smaller:


[Bradley-Luciers-MacBook-Pro:~/Downloads/irregex-0.8.3] lucier% cat
irregex-gambit.scm
(declare (standard-bindings)
(extended-bindings)
(block)
(fixnum)
(not safe))
(include "irregex.scm")

With this it compiles fine:


[Bradley-Luciers-MacBook-Pro:~/Downloads/irregex-0.8.3] lucier% gsc
irregex-gambit.scm
[Bradley-Luciers-MacBook-Pro:~/Downloads/irregex-0.8.3] lucier% gsi
Gambit v4.6.5

> (load "irregex-gambit")
"/Users/lucier/Downloads/irregex-0.8.3/irregex-gambit.o1"
> irregex
#<procedure #2 irregex>

Does this help?

Brad

Armando Blancas

unread,
Apr 20, 2012, 10:49:14 PM4/20/12
to
That helped very much indeed. In less than a minute I'm up and running; nice and quick. Thanks.
> Does this help?
>
> Brad

0 new messages