I am going to confirm the examples and make notes
with the goal to have a quick reference to any problems
such as missing dependencies or such to get all the examples
solved in one post in one place
all the easy examples that have no problems will be excluded
basically a walk though of some of the tricky things
I encountered getting the apps to run
main official website http://www.basic-converter.org/
Import definitions when using HUG as a shared object= hug_imports.bac :http://www.basic-converter.org/hug_imports.bac
the HUG abstraction layer= hug.bac http://www.basic-converter.org/hug.bac
Bacon 101 using only the official *.bac files used here
Bacon 101 using only the official *.bac files used here
Last edited by big_bass on Sun 02 Oct 2011, 16:58, edited 10 times in total.
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
curl bacon
focus on curldemo3.bac
Interfaces are straight imports from external libraries into BaCon.
instead of reviewing some standard linux package differences
between compiling static and compiling shared
the focus here is what does all this mean when we use BaCon
"most" of the binaries we compile in BaCon have no dependencies
they are stand alone apps without statically compiled libs
some apps have a dependency of hug.so as being the only
"special" shared dependency (this method produces the smallest binaries )
but we can link to a shared library in the next example using curl
the linux app curl http://curl.haxx.se/download.html (not the bacon curl.bac)
-----------------------------------------------------------
using the official demo from the main bacon website ( the error you may get) after compiling
Symbol not found in library /usr/lib/libcurl.so.3: undefined symbol: curl_easy_pause
this means that you dont have curl the "real program" installed
for me I compiled and made this package curl-7.21.4-i486-1.txz you can use your own curl package
the error reads no shared lib--> libcurl.so.3
for this reason the BaCon program curldemo3 can not read the library and get the needed info
now install the curl-7.21.4-i486-1.txz package and try again (or your curl package)
Downloaded 'documentation.pdf' using CURL version: libcurl/7.21.4 OpenSSL/0.9.8e zlib/1.2.3
this shows that BaCon compiled apps can and do utilize the shared libraries
in the same way that when you install other linux programs
Joe
Interfaces are straight imports from external libraries into BaCon.
instead of reviewing some standard linux package differences
between compiling static and compiling shared
the focus here is what does all this mean when we use BaCon
"most" of the binaries we compile in BaCon have no dependencies
they are stand alone apps without statically compiled libs
some apps have a dependency of hug.so as being the only
"special" shared dependency (this method produces the smallest binaries )
but we can link to a shared library in the next example using curl
the linux app curl http://curl.haxx.se/download.html (not the bacon curl.bac)
-----------------------------------------------------------
using the official demo from the main bacon website ( the error you may get) after compiling
Code: Select all
./curldemo3
Symbol not found in library /usr/lib/libcurl.so.3: undefined symbol: curl_easy_pause
this means that you dont have curl the "real program" installed
for me I compiled and made this package curl-7.21.4-i486-1.txz you can use your own curl package
the error reads no shared lib--> libcurl.so.3
for this reason the BaCon program curldemo3 can not read the library and get the needed info
now install the curl-7.21.4-i486-1.txz package and try again (or your curl package)
Code: Select all
./curldemo3
this shows that BaCon compiled apps can and do utilize the shared libraries
in the same way that when you install other linux programs
Joe
auto download compile install bacon with the files auto modified
to allow for shared libraries (this sets up everything needed for the examples )
*minor update to save all the old files in /usr/share/BaCon/old-version-saved as a safety
thanks to GatorDog for the kind warning
to allow for shared libraries (this sets up everything needed for the examples )
*minor update to save all the old files in /usr/share/BaCon/old-version-saved as a safety
thanks to GatorDog for the kind warning
Code: Select all
#!/bin/bash
# Joe Arose big_bass 12-14-2010 last update 11-1-2011
# call this auto-build-compile-bacon2
# auto download compile install
# so you can easily update when needed
# thanks "mechanic" for the speed tip using bacon instead of bacon.bash for compiling
# thanks seaside for the bash version test
BASHV=$(bash --version | head -1)
VN=$(echo $BASHV | cut -f1 -d. | sed 's/^.*\(.\)$/\1/')
[ $VN -lt 4 ] && Xdialog --title "bash version test " \
--infobox "\nBash Version Problem $BASHV installed
---------------> Bash must be version 4 or above for BaCon <-------------------" "\n" 0 0
# =====================================
# downoad ,compile and install BaCon
# =====================================
Xdialog --wrap --title "bacon instlaller" \
--yesno "Do you want to install bacon " 0 0
case $? in
0)
echo "Yes chosen."
mkdir -p /usr/share/BaCon/old-version-saved
mkdir -p /usr/share/BaCon/
cd /usr/share/BaCon/
mv bacon.bash* bacon* hug.bac* hug_imports* bacon.lang* bacon.* *.c *.h *.log /usr/share/BaCon/old-version-saved || true
# bacon.bash
xterm -geometry 40x30+150+40 -e wget -N http://www.basic-converter.org/stable/bacon.bash
chmod a+x bacon.bash
# bacon.bac
xterm -geometry 40x30+150+40 -e wget -N http://www.basic-converter.org/stable/bacon.bac
chmod a+x bacon.bac
# fix for bash if you have a different version you compiled
# depends on the replace app
#replace '#!/usr/bin/env bash' '#!/bin/bash' bacon.bash
# use sed (#!/usr/bin/env bash change to #!/bin/bash)
sed -i 's/\#\!\/usr\/bin\/env bash/\#\!\/bin\/bash/' /usr/share/BaCon/bacon.bash
# much faster with a pre installed bacon ( use this if you have bacon installed )
# to compile a fresh bacon binary with a pre installed bacon
#xterm -geometry 40x30+150+40 -e bacon bacon.bac
# very slow *without* a pre installed bacon (default for a safety )
# to compile a fresh bacon binary *without* a pre installed bacon
xterm -geometry 40x30+150+40 -e '. /usr/share/BaCon/bacon.bash bacon.bac'
# copy bacon bin into the path
cp bacon /usr/sbin
# hug.bac
xterm -geometry 40x30+150+40 -e wget -N http://www.basic-converter.org/hug.bac
# hug_imports.bac
xterm -geometry 40x30+150+40 -e wget -N http://www.basic-converter.org/hug_imports.bac
# auto edit the hug_imports.bac must have the replace command installed
#replace 'CONST HUG_lib$ = "./hug.so"' 'CONST HUG_lib$ = "/usr/lib/libhug.so"' hug_imports.bac
# auto edit the hug_imports.bac
sed -i 's/\.\/hug.so/\/usr\/lib\/libhug.so/' hug_imports.bac
# use the new bacon binary to make the new libhug.so
cp hug.bac libhug.bac
xterm -geometry 40x30+150+40 -e bacon -f libhug.bac
md5sum libhug.so >md5sum_libhug.txt
# add a md5sum in the sources
MD=$(<md5sum_libhug.txt)
sed -i "2a \'$MD " hug_imports.bac
cp libhug.so /usr/lib
# bacon.lang
xterm -geometry 40x30+150+40 -e wget -N http://www.basic-converter.org/bacon.lang
Xdialog --title "Complete" \
--infobox "\nInstalling bacon has finished.\n" 0 0 3000
#clean up C crap
rm -f *.c
rm -f *.h
;;
1)
echo "No chosen."
exit
;;
255)
echo "Box closed."
exit
;;
esac