Posted: Tue 27 Sep 2011, 14:26
Creating and linking to libraries created with BaCon
here it is with the examples given in the documentation
I added showing the code output
using these two test files
call this libdemo.bac
call this program.bac
let's make the lib using the -f option
Converting 'libdemo.bac'... done.
Compiling 'libdemo.bac'... done.
Program 'libdemo.so' ready.
let's link the lib to the program using the -l option
notice that here you don't use the lib prefix in the command line
but this is the correct way to link libdemo.so to the program
Converting 'program.bac'... done.
Compiling 'program.bac'... done.
Program 'program' ready.
let's check if the library is seen by the ldd command
shows that the documentation is correct the libdemo.so is linked and understood by ldd
as being a real shared library *because it has a lib prefix
let's prove if the program runs
25
the output is 25
everything works as described (there needs to be some "re-thinking" about how this
really works ) in order to benefit from this advantage of having shared libs
Joe
here it is with the examples given in the documentation
I added showing the code output
using these two test files
call this libdemo.bac
Code: Select all
FUNCTION bla (NUMBER n)
LOCAL i
i = 5 * n
RETURN i
END FUNCTION
call this program.bac
Code: Select all
PROTO bla
x = 5
result = bla(x)
PRINT result
let's make the lib using the -f option
Code: Select all
bacon -f libdemo.bac
Compiling 'libdemo.bac'... done.
Program 'libdemo.so' ready.
let's link the lib to the program using the -l option
notice that here you don't use the lib prefix in the command line
but this is the correct way to link libdemo.so to the program
Code: Select all
bacon -l demo program.bac
Compiling 'program.bac'... done.
Program 'program' ready.
let's check if the library is seen by the ldd command
Code: Select all
ldd /root/bacon-examples/program
linux-gate.so.1 => (0xffffe000)
libm.so.6 => /lib/libm.so.6 (0xb7fbc000)
libdl.so.2 => /lib/libdl.so.2 (0xb7fb8000)
libdemo.so => /usr/lib/libdemo.so (0xb7fac000)
libc.so.6 => /lib/libc.so.6 (0xb7eb1000)
/lib/ld-linux.so.2 (0xb7fdf000)
shows that the documentation is correct the libdemo.so is linked and understood by ldd
as being a real shared library *because it has a lib prefix
let's prove if the program runs
Code: Select all
./program
the output is 25
everything works as described (there needs to be some "re-thinking" about how this
really works ) in order to benefit from this advantage of having shared libs
Joe