Duchamp Source Finder is an astrophysical application, described here. This is the most complicated example listed on this site. It uses 2 external libraries and illustrates how to produce ll files with multiple sources, it uses a reasonable amount of the C++ STL libraries.

Note that the ll file is provided so you may skip the production of this. It was produced using the 1.1.13 version of Duchamp, cfitsio 3.2 and wcslib 4.7, on an Ubuntu 10 system.

Produce the ll file

Download all files and extract such that the following directory structure is produced
/home/user/dev/cfitsio/ /home/user/dev/wcslib/ /home/user/dev/Duchamp-1.1.13/
Also create these folders
/home/user/dev/install/ /home/user/dev/install/bc
Run configure and make all of the programs and capture the output
cd /home/user/dev/cfitsio/ ./configure --prefix=/home/user/dev/install make &> cfitsio.txt make install cd ../wcslib ./configure --prefix=/home/user/dev/install --without-pgplot --with-cfitsiolib=/home/user/dev/install/lib --with-cfitsioinc=/home/user/dev/install/include make &> wcslib.txt make install cd ../Duchamp-1.1.13 ./configure --prefix=/home/user/dev/install --without-pgplot --with-cfitsio=/home/user/dev/install --with-wcslib=/home/user/dev/install make &> duchamp.txt make install
Combine these txt files and carry out the following replacements
gcc => llvm-gcc -c --emit-llvm
g++ => llvm-g++ -c --emit-llvm
-o path-to-.o => -o path-to.bc
Instead of building libraries we wish to build a single ll file. This can be made simpler by combining the ll files together without removing unused code. This can be achieved using the -link-as-library option of llvm-ld. Therefore, after the compilation of the cfitsio files to object files, paste in the following and remove the library generation and compilation of the test program.
llvm-ld -link-as-library -o libcfitsio.bc buffers.bc cfileio.bc checksum.bc drvrfile.bc drvrmem.bc drvrnet.bc drvrsmem.bc drvrgsiftp.bc editcol.bc edithdu.bc eval_l.bc eval_y.bc eval_f.bc fitscore.bc getcol.bc getcolb.bc getcold.bc getcole.bc getcoli.bc getcolj.bc getcolk.bc getcoll.bc getcols.bc getcolsb.bc getcoluk.bc getcolui.bc getcoluj.bc getkey.bc group.bc grparser.bc histo.bc iraffits.bc modkey.bc putcol.bc putcolb.bc putcold.bc putcole.bc putcoli.bc putcolj.bc putcolk.bc putcoluk.bc putcoll.bc putcols.bc putcolsb.bc putcolu.bc putcolui.bc putcoluj.bc putkey.bc region.bc scalnull.bc swapproc.bc wcssub.bc wcsutil.bc imcompress.bc quantize.bc ricecomp.bc pliocomp.bc fits_hcompress.bc fits_hdecompress.bc zuncompress.bc zcompress.bc adler32.bc crc32.bc inffast.bc inftrees.bc trees.bc zutil.bc deflate.bc infback.bc inflate.bc uncompr.bc f77_wrap1.bc f77_wrap2.bc f77_wrap3.bc f77_wrap4.bc cp libcfitsio.bc /home/user/dev/install/bc/ cd /home/user/dev/wcslib
After the wcslib compilation, paste the following and remove the generation of the library
llvm-ld -link-as-library -strip-all -o libwcslib.bc cel.bc fitshdr.bc lin.bc log.bc prj.bc spc.bc sph.bc spx.bc tab.bc wcs.bc wcsbth.bc wcsfix.bc wcshdr.bc wcspih.bc wcsprintf.bc wcstrig.bc wcsulex.bc wcsunits.bc wcsutil.bc wcsutrn.bc cp libwcslib.bc /home/user/dev/install/bc/ cd /home/user/dev/Duchamp-1.1.13/
After the Duchamp compilation, paste the following and remove the generation of the native executable
llvm-ld -disable-opt -o Duchamp ./src/mainDuchamp.bc ./src/duchamp.bc ./src/param.bc ./src/fitsHeader.bc ./src/PixelMap/Voxel.bc ./src/PixelMap/Scan.bc ./src/PixelMap/Object2D.bc ./src/PixelMap/Object3D.bc ./src/ATrous/filter.bc ./src/ATrous/atrous_1d_reconstruct.bc ./src/ATrous/atrous_2d_reconstruct.bc ./src/ATrous/atrous_3d_reconstruct.bc ./src/ATrous/baselineSubtract.bc ./src/ATrous/ReconSearch.bc ./src/Detection/detection.bc ./src/Detection/columns.bc ./src/Detection/ObjectGrower.bc ./src/Detection/areClose.bc ./src/Detection/growObject.bc ./src/Detection/lutz_detect.bc ./src/Detection/mergeIntoList.bc ./src/Detection/outputDetection.bc ./src/Detection/sorting.bc ./src/Detection/spectrumDetect.bc ./src/Cubes/cubes.bc ./src/Cubes/cubes_extended.bc ./src/Cubes/baseline.bc ./src/Cubes/CubicSearch.bc ./src/Cubes/detectionIO.bc ./src/Cubes/existingDetections.bc ./src/Cubes/getImage.bc ./src/Cubes/invertCube.bc ./src/Cubes/Merger.bc ./src/Cubes/momentMap.bc ./src/Cubes/readRecon.bc ./src/Cubes/readSmooth.bc ./src/Cubes/saveImage.bc ./src/Cubes/smoothCube.bc ./src/Cubes/spectraUtils.bc ./src/Cubes/trimImage.bc ./src/Cubes/VOTable.bc ./src/FitsIO/Beam.bc ./src/FitsIO/DuchampBeam.bc ./src/FitsIO/dataIO.bc ./src/FitsIO/headerIO.bc ./src/FitsIO/subsection.bc ./src/FitsIO/wcsIO.bc ./src/Utils/Section.bc ./src/Utils/Statistics.bc ./src/Utils/feedback.bc ./src/Utils/GaussSmooth1D.bc ./src/Utils/Hanning.bc ./src/Utils/getStats.bc ./src/Utils/getNormalStats.bc ./src/Utils/getRobustStats.bc ./src/Utils/linear_regression.bc ./src/Utils/position_related.bc ./src/Utils/sort.bc ./src/Utils/string_related.bc ./src/Utils/wcsFunctions.bc ./src/Utils/zscale.bc /home/user/dev/install/bc/libwcslib.bc /home/user/dev/install/bc/libcfitsio.bc opt -S -disable-inlining -O2 -std-compile-opts -std-link-opts -o Duchamp.ll Duchamp.bc
Final text file should look something like this
Execute the text file contents (bash shell example shown)
source ./make_duchamp.txt
We now have Duchamp.ll which an example is available here

Compile with Proteus

Now using this ll file generate an executable jar

Because Duchamp is a signicantly size program, it requires more memory to compile it. If you are using a '32 bit' version of the JDK you may need to specify the -Xmx512m on the command line.
java -Xmx512m -jar dist\bin\Proteus.jar duchamp.ll

Run the generated java executable

Note that this example uses command line arguments, it also may require more memory than the default settings therefore, the below example uses

This will display the help message
java -jar duchamp.jar
This will display the version number
java -jar duchamp.jar -- -v
To allocate more memory to the Proteus Runtime environment the -memory.size option is used to pass arguments to the underlying program use '--' to indicate the start of program arguments. Note that if the -memory.size argument was passed to the original Proteus compilation its value would be the default one.
java -Xmx1024m -jar duchamp.jar -memory.size 512 -- -p parameters.txt