# Needs help to build LoopTools using BinaryBuilder

**URL:** <https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260>\
**Category:** General Usage\
**Tags:** binarybuilder\
**Created:** [August 4, 2020, 1:58pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260 "2020-08-04T13:58:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fkguo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fkguo/32/16866_2.png) [@fkguo](https://discourse.julialang.org/u/fkguo)\
**Post date:** [August 4, 2020, 1:58pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/1 "2020-08-04T13:58:57Z")

</div>

Hello,

There is a package called [LoopTools](http://www.feynarts.de/looptools/), for which I succeeded in building a `.so` shared lib locally that I can call in julia.

Now I am trying to build it using `BinaryBuilder.jl` with the following code that was modified from the documentation

```julia
using BinaryBuilder, Pkg

name = "LoopTools"
version = v"2.15"

# Collection of sources required to complete build
sources = [
    ArchiveSource("http://www.feynarts.de/looptools/LoopTools-2.15.tar.gz", "a065ffdc4fe6882aa3bb926134ba8ec875d6c0a633c3d4aa5f70db26542713f2"),
]

# Bash recipe for building across all platforms
script = raw"""
cd ${WORKSPACE}/srcdir/LoopTools-*

./configure
make -j${nproc}
make install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
# platforms = expand_gfortran_versions(supported_platforms())
#
platforms = [
    Linux(:x86_64, libc=:glibc)
]

# The products that we will ensure are always built
products = [
    LibraryProduct("liblooptools", :liblooptools)
]

# Dependencies that must be installed before this package can be built
dependencies = Dependency[
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)

```

but did not have luck to succeed…

The `configure` step already failed with the message:

```julia
[21:37:20] ---> ./configure
[21:37:20] looking for gcc... /opt/bin/cc
[21:37:20] looking for g++... /opt/bin/c++
[21:37:20] looking for fortran... /opt/bin/gfortran
[21:37:20] extracting the Fortran libraries... ok
[21:37:20] does gfortran append underscores... error linking Fortran and C
[21:37:20] ---> ./configure
[21:37:20] Previous command exited with 1
[21:37:21] Child Process exited, exit code 1

```

A successful `./configure` would give a message like the following:

```julia
looking for gcc... /usr/bin/clang
looking for g++... /usr/bin/clang++
looking for fortran... /user/bin/gfortran
extracting the Fortran libraries... ok
does gfortran append underscores... yes
does gfortran support REAL*16... yes
does gfortran need 'external' for U77 routines... no
are we big-endian... no
do we have MathLink... yes
creating makefile

now you must run make

```

In the debug mode of binarybuilder, by `LOGFILE=log.txt`, `export log.txt` and then `./configure`, I got the following log:

```julia
+ shopt -s nullglob
+ export LC_ALL=C
+ LC_ALL=C
+ CONF_DIR=.
++ uname -s
+ CONF_OS=Linux
++ uname -m
+ CONF_MACH=x86_64
+ CONF_DEFPREFIX=x86_64-Linux
+ CONF_PREFIX=x86_64-Linux
+ CONF_TARGET=
+ CONF_STATIC=
+ CONF_STATIC_EXT=
+ CONF_STATIC_GFORTRAN=
+ CONF_QUAD=
+ CONF_QUADSIZE=16
+ CONF_REAL10=
+ CONF_DEBUG=
+ CONF_BITS=
+ CONF_MCLIBS=
+ CONF_ARCH=
+ CONF_AS=
+ CONF_EXE=
+ CONF_LDFLAGS=
+ case "$CONF_OS" in
+ CONF_MCLIBS=' -lpthread -lrt'
+ test=test19
+ trap 'rm -fr test19* =.' 0 1 2 3 15
+ findprog gcc CC clang gcc
+ echo -n 'looking for gcc... '
+ var=CC
+ set -- cc clang gcc
+ test -n ''
+ for prog in "$@"
++ type -P cc
+ full=/opt/bin/cc
+ echo /opt/bin/cc
+ printf -v CONF_CC %q cc
+ return 0
+ findprog g++ CXX clang++ g++
+ echo -n 'looking for g++... '
+ var=CXX
+ set -- c++ clang++ g++
+ test -n ''
+ for prog in "$@"
++ type -P c++
+ full=/opt/bin/c++
+ echo /opt/bin/c++
+ printf -v CONF_CXX %q c++
+ return 0
+ findprog fortran FC ifort pgf90 xlf gfortran g95 f90
+ echo -n 'looking for fortran... '
+ var=FC
+ set -- gfortran ifort pgf90 xlf gfortran g95 f90
+ test -n ''
+ for prog in "$@"
++ type -P gfortran
+ full=/opt/bin/gfortran
+ echo /opt/bin/gfortran
+ printf -v CONF_FC %q gfortran
+ return 0
+ CONF_DEF=-D
++ ++ sed eval gfortran '/^$/d;s/(.*)//;q'
--version -c
+++ gfortran --version -c
+ set -- GNU Fortran 4.8.5
+ case "$1,$2,$3" in
+ eval setflags FFLAGS '-O3 -ffixed-line-length-none -fno-range-check '
++ setflags FFLAGS -O3 -ffixed-line-length-none -fno-range-check
++ rhs=
++ printf -v rhs ' %q' -O3 -ffixed-line-length-none -fno-range-check
++ eval 'CONF_FFLAGS="${rhs//\\,/,}"'
+++ CONF_FFLAGS=' -O3 -ffixed-line-length-none -fno-range-check'
+ echo -n 'extracting the Fortran libraries... '
+ rm -fr
+ tee test19.f
        program test
        integer i
        common /uscore/ i
        call exit(i)
        end
++ eval gfortran ./configure: line 226: /dev/fd/62: No such file or directory++ eval -O3 -ffixed-line-length-none
gfortran -O3 -fno-range-check -v -ffixed-line-length-none -fno-range-check + eval -o test19 -v -o setflags LDFLAGS test19.f
test19 test19.f' '

++ setflags LDFLAGS
++ rhs=
++ eval 'CONF_LDFLAGS="${rhs//\\,/,}"'
+++ CONF_LDFLAGS=
+ echo ok
++ eval cc --version -c
+ [[ +++ cc --version -c
x86_64-linux-gnu-gcc (GCC) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =~ gcc ]]
+ CONF_STATIC_GCC=
+ eval setflags CFLAGS '-O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall '
++ setflags CFLAGS -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall
++ rhs=
++ printf -v rhs ' %q' -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall
++ eval 'CONF_CFLAGS="${rhs//\\,/,}"'
+++ CONF_CFLAGS=' -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall'
+ eval setflags CXXFLAGS '-O3 -g -fomit-frame-pointer -ffast-math -Wall '
++ setflags CXXFLAGS -O3 -g -fomit-frame-pointer -ffast-math -Wall
++ rhs=
++ printf -v rhs ' %q' -O3 -g -fomit-frame-pointer -ffast-math -Wall
++ eval 'CONF_CXXFLAGS="${rhs//\\,/,}"'
+++ CONF_CXXFLAGS=' -O3 -g -fomit-frame-pointer -ffast-math -Wall'
+ echo -n 'does gfortran append underscores... '
+ tee test19-c.c
int uscore_ = 95;
int uscore = 59;
+ for CONF_BITS in ${CONF_BITS:--m64 -m32} ""
+ eval cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m64 -c test19-c.c
++ cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m64 -c test19-c.c
You used one or more of the unsafe flags: -Ofast, -ffast-math, -funsafe-math-optimizations
Please repent.
+ continue
+ for CONF_BITS in ${CONF_BITS:--m64 -m32} ""
+ eval cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m32 -c test19-c.c
++ cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -m32 -c test19-c.c
You used one or more of the unsafe flags: -Ofast, -ffast-math, -funsafe-math-optimizations
Please repent.
+ continue
+ for CONF_BITS in ${CONF_BITS:--m64 -m32} ""
+ eval cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -c test19-c.c
++ cc -O3 -g -fomit-frame-pointer -ffast-math -fPIC -Wall -c test19-c.c
You used one or more of the unsafe flags: -Ofast, -ffast-math, -funsafe-math-optimizations
Please repent.
+ continue
+ ./test19
./configure: line 258: ./test19: No such file or directory
+ case $? in
+ echo 'error linking Fortran and C'
+ exit 1
+ rm -fr test19-c.c test19.f =.

```

It is far beyond my knowledge to make it work, and I would like to ask for your kind help here. Thank you in advance.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 4, 2020, 2:11pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/2 "2020-08-04T14:11:42Z")

</div>

Read the documentation of BinaryBuilder, in particular [Build Tips · BinaryBuilder.jl](https://juliapackaging.github.io/BinaryBuilder.jl/dev/build_tips/#Autoconfigure-builds). You _must_ pass the flags `--prefix=$prefix --build=${MACHTYPE} --host=${target}` to configure.

Anyway, I recommend you opening a pull request to [`Yggdrasil`](https://github.com/JuliaPackaging/Yggdrasil/) with your build recipe so far and we’ll be able to have a look at it more easily. We also already have a [recipe for Cuba](https://github.com/JuliaPackaging/Yggdrasil/blob/5116fe6bb81ee18b62cee7a89b5d81e08b8009e9/C/Cuba/build_tarballs.jl), a library by the same author as LoopTools

---

<div class="post-metadata">

**Author:** ![fkguo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fkguo/32/16866_2.png) [@fkguo](https://discourse.julialang.org/u/fkguo)\
**Post date:** [August 4, 2020, 2:29pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/3 "2020-08-04T14:29:14Z")

</div>

> [@giordano](#):
>
> Read the documentation of BinaryBuilder, in particular [https://juliapackaging.github.io/BinaryBuilder.jl/dev/build\_tips/#Autoconfigure-builds](https://juliapackaging.github.io/BinaryBuilder.jl/dev/build_tips/#Autoconfigure-builds). You _must_ pass the flags `--prefix=$prefix --build=${MACHTYPE} --host=${target}` to configure.

Thanks for your quick reply. I tried ` ./configure --prefix=$prefix --build=${MACHTYPE} --host=${target}`, but no success. I also just tried the recipe for Cuba, no success either…

I’ll open a PR later. Thanks.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 4, 2020, 2:37pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/4 "2020-08-04T14:37:40Z")

</div>

> [@fkguo](#):
>
> I also just tried the recipe for Cuba, no success either…

What do you mean exactly? What’s the problem? You can’t build Cuba using that recipe? I’d be worried if it didn’t work with the latest stable version of BinaryBuilder. In fact, I tried right now and it worked flawless. Please, provide more context (operating system, version of BinaryBuilder, etc…)

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 4, 2020, 2:41pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/5 "2020-08-04T14:41:22Z")

</div>

Well, I opened the `configure` script, it starts with a comment

```nohighlight
# configure script for LoopTools
# note: has nothing to do with GNU autoconf
# last modified 1 Jan 20 th

```

So it’ll be more complicated than expected…

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 4, 2020, 2:59pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/6 "2020-08-04T14:59:40Z")

</div>

Ok, I found the culprit: remove `-ffast-math` from line 240 of the `configure` script. You’ll also need to set the following environment variables:

```nohighlight
export AR=ar
export RANLIB=ranlib

```

---

<div class="post-metadata">

**Author:** ![fkguo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fkguo/32/16866_2.png) [@fkguo](https://discourse.julialang.org/u/fkguo)\
**Post date:** [August 4, 2020, 3:12pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/7 "2020-08-04T15:12:37Z")

</div>

> [@giordano](#):
>
> You can’t build Cuba using that recipe?

Very sorry for the confusion. I meant that I copied the recipe from Cuba for LoopTools… I’ll try your suggestions below.

---

<div class="post-metadata">

**Author:** ![fkguo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fkguo/32/16866_2.png) [@fkguo](https://discourse.julialang.org/u/fkguo)\
**Post date:** [August 4, 2020, 3:21pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/8 "2020-08-04T15:21:38Z")

</div>

Thanks. I tried these modifications in the debug mode, and `./configure` still gives the same error…

BTW, I’m using WSL2, `BinaryBuilder.jl` v0.2.5 with julia 1.5.0.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 4, 2020, 3:23pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/9 "2020-08-04T15:23:10Z")

</div>

Let’s continue in [https://github.com/JuliaPackaging/Yggdrasil/pull/1411](https://github.com/JuliaPackaging/Yggdrasil/pull/1411), it’s wasteful to have two places where to discuss

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 4, 2020, 11:15pm UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/10 "2020-08-04T23:15:18Z")

</div>

For the record, I ended up [heavily patching](https://github.com/JuliaPackaging/Yggdrasil/blob/b85e8f7025385a9258b1950cde9b6a5d91ee761e/L/LoopTools/bundled/patches/simplify-configure.patch) the custom `configure` script and now we can build for all supported platforms.

---

<div class="post-metadata">

**Author:** ![fkguo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fkguo/32/16866_2.png) [@fkguo](https://discourse.julialang.org/u/fkguo)\
**Post date:** [August 5, 2020, 12:11am UTC](https://discourse.julialang.org/t/needs-help-to-build-looptools-using-binarybuilder/44260/11 "2020-08-05T00:11:28Z")

</div>

Thank you!
