jts / sga

de novo sequence assembler using string graphs
http://genome.cshlp.org/content/22/3/549
237 stars 82 forks source link

Error at `make`: VariantIndex.cpp:89:16: error: call to 'abs' is ambiguous #141

Closed evanbiederstedt closed 6 years ago

evanbiederstedt commented 6 years ago

All dependencies appear to be installed correctly, in the "default" locations with sudo privileges. (I am not using the jemalloc memory allocator.)

Within /sga-master/src, I first ran ./configure via

$ ./configure  --with-sparsehash=/usr/local/include/sparsehash --with-bamtools=/usr/local/

whereby all checks pass successfully. Then I try make in the same location:


$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in bin
make[2]: Nothing to be done for `all'.
Making all in Thirdparty
make[2]: Nothing to be done for `all'.
Making all in Util
g++ -DHAVE_CONFIG_H -I. -I..  -I../Bigraph -I../Thirdparty -I/usr/local/include/sparsehash/include -I/usr/local//include -I/usr/local//include/bamtools -Wall -Wextra  -Wno-unknown-pragmas -std=c++98 -O3 -MT libutil_a-VariantIndex.o -MD -MP -MF .deps/libutil_a-VariantIndex.Tpo -c -o libutil_a-VariantIndex.o `test -f 'VariantIndex.cpp' || echo './'`VariantIndex.cpp
VariantIndex.cpp:89:16: error: call to 'abs' is ambiguous
            if(abs(record.position - position) < distance)
               ^~~
/usr/include/stdlib.h:129:6: note: candidate function
int      abs(int) __pure2;
         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:115:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:117:44: note: candidate function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:693:1: note: candidate function
abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:697:1: note: candidate function
abs(double __lcpp_x) _NOEXCEPT {return ::fabs(__lcpp_x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:701:1: note: candidate function
abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
^
1 error generated.
make[2]: *** [libutil_a-VariantIndex.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

Resolutions?

jts commented 6 years ago

I suspect you're using gcc >4? Do you get an error if you use one of the 4.x gcc versions?

evanbiederstedt commented 6 years ago

I suspect you're using gcc >4?

I don't think so. I'm trying this on my MacOS:

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

$ gcc -dumpversion
4.2.1

So it looks like I get this via gcc 4.2.1

jts commented 6 years ago

It is probably due to clang. Could you try installing using homebrew? SGA hasn't been updated in awhile so homebew should give you the latest version.

evanbiederstedt commented 6 years ago

It is probably due to clang.

The above via gcc -v looks like it's using clang version: Apple LLVM version 9.0.0 (clang-900.0.38)

Brew currently installs:

$ brew install gcc
Warning: gcc 7.2.0 is already installed

Could you try installing using homebrew?

I think you mean use the newest version of gcc installed via Homebrew. Homebrew places this in /usr/local/bin, it appears

I've tried export PATH=/usr/local/bin:$PATH before make clean and make, as well as creating a symbolic link from the Homebrew version, e.g.

cd /usr/local/bin
ln -s gcc-7 gcc

I'm still getting the same error with make:


g++ -DHAVE_CONFIG_H -I. -I..  -I../Bigraph -I../Thirdparty -I/usr/local/include/sparsehash/include -I/usr/local//include -I/usr/local//include/bamtools -Wall -Wextra  -Wno-unknown-pragmas -std=c++98 -O3 -MT libutil_a-VariantIndex.o -MD -MP -MF .deps/libutil_a-VariantIndex.Tpo -c -o libutil_a-VariantIndex.o `test -f 'VariantIndex.cpp' || echo './'`VariantIndex.cpp
VariantIndex.cpp:89:16: error: call to 'abs' is ambiguous
            if(abs(record.position - position) < distance)
               ^~~
/usr/include/stdlib.h:129:6: note: candidate function
int      abs(int) __pure2;
         ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:115:44: note: candidate
      function
inline _LIBCPP_INLINE_VISIBILITY long      abs(     long __x) _NOEXCEPT {return  labs(__x);}
                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h:117:44: note: candidate
      function
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);}
                                           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:693:1: note: candidate
      function
abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:697:1: note: candidate
      function
abs(double __lcpp_x) _NOEXCEPT {return ::fabs(__lcpp_x);}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:701:1: note: candidate
      function
abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
^
1 error generated.
make[2]: *** [libutil_a-VariantIndex.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
jts commented 6 years ago

I meant to install sga with homebrew, sorry for being unclear:

brew install sga
evanbiederstedt commented 6 years ago

Oh, I see

Hmmm. It doesn't like that:

$ brew install sga
Error: No available formula with the name "sga" 
==> Searching for a previously deleted formula...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...

This similarly named formula was found:
vorbisgain
To install it, run:
  brew install vorbisgain
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

Brew is upgraded/updated.

evanbiederstedt commented 6 years ago

I meant to install sga with homebrew, sorry for being unclear:

Also, just to clarify, as I'm installing soon on Linux as well: what would be the correct gcc/clang versions to use?

jts commented 6 years ago

Ah sorry, you need to install the homebrew science formulas first:

brew tap homebrew/science
brew install sga

For linux gcc-4.7 or gcc-4.8 should be fine.

Jared

evanbiederstedt commented 6 years ago

It works, thanks!

I'll let you know if there's an installation on Linux in a new Issue. Consider this closed I suppose (though it might be a good idea to tell Mac OS users just to try brew, or to specify the correct gcc, e.g. if they already use MacPorts/whatever)

Thanks, Evan

jts commented 6 years ago

Great, glad I could help.

sjackman commented 6 years ago

Here's a PR to fix this error call to 'abs' is ambiguous: https://github.com/jts/sga/pull/148

sjackman commented 6 years ago

@evanbiederstedt Once PR https://github.com/brewsci/homebrew-bio/pull/67 has been merged, you can install sga on both Linux and macOS using Linuxbrew and Homebrew.

brew install brewsci/bio/sga

See http://linuxbrew.sh and https://brew.sh

evanbiederstedt commented 6 years ago

This is good to know! Thanks!

On Tue, Feb 27, 2018 at 12:31 AM Shaun Jackman notifications@github.com wrote:

@evanbiederstedt https://github.com/evanbiederstedt Once PR brewsci/homebrew-bio#67 https://github.com/brewsci/homebrew-bio/pull/67 has been merged, you can install sga on both Linux and macOS using Linuxbrew and Homebrew.

brew install brewsci/bio/sga

See http://linuxbrew.sh and https://brew.sh

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/jts/sga/issues/141#issuecomment-368752664, or mute the thread https://github.com/notifications/unsubscribe-auth/AGpTgbPjTaPY4e4MjvtRZI7vXjmh1mFWks5tY5NAgaJpZM4Q4l8X .