yk-choi-yk / cusp-library

Automatically exported from code.google.com/p/cusp-library
Apache License 2.0
0 stars 0 forks source link

#include <cusp/blas.h> breaks gcc compilation #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Consider a simple test case cusp_test.cpp:

#include <cusp/blas.h>

int main()
{
  return 0;
}

2. compile with

g++ -I /path/to/cusp -I /path/to/thrust -I /usr/local/cuda/include cusp_test.cpp

What is the expected output? What do you see instead?

compiler error:
In file included from /path/to/cusp/cusp/blas.h:199,
                 from cusp_test.cpp:1:
/path/to/cusp/cusp/detail/blas.inl: In function 'typename 
thrust::iterator_value<Iterator>::type cusp::blas::nrm2(InputIterator, 
InputIterator)':
/path/to/cusp/cusp/detail/blas.inl:395: error: 'sqrt' is not a member of 'std'

What version of the product are you using? On what operating system?

Tested on:

thrust 1150:9f5c19852f16
cusp 259:9fdf9bde9f6d

Ubuntu 8.04 2.6.24-24-server #1 SMP Wed Apr 15 15:41:09 UTC 2009 x86_64 
GNU/Linux
Ubuntu 9.10 2.6.31-22-generic #61-Ubuntu SMP Wed Jul 28 02:02:56 UTC 2010 
x86_64 GNU/Linux

g++-4.4 (Ubuntu 4.4.1-4ubuntu9) 4.4.1
g++-4.3 (Ubuntu 4.3.4-5ubuntu1) 4.3.4
g++-4.2 (GCC) 4.2.4 (Ubuntu 4.2.4-5ubuntu1)

Original issue reported on code.google.com by florian....@gmail.com on 12 Aug 2010 at 12:21

GoogleCodeExporter commented 8 years ago
Note that it's generally a bad idea to compile Cusp files with g++ in .cpp 
files.  You generally want to compile with nvcc and .cu files.  In this 
particular case, though, it happens to work.

In any case, I believe the fix to this problem is to put

#include <cmath>

at the top of cusp/detail/blas.inl.  That resolves the problem on my Linux 
machine.  Could you confirm that it fixes it for you as well?

Original comment by mjgarl...@gmail.com on 17 Aug 2010 at 8:31

GoogleCodeExporter commented 8 years ago

Original comment by mjgarl...@gmail.com on 17 Aug 2010 at 8:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I know cusp is meant to be compiled by nvcc. But I have some glue code to a C++ 
library I'm using which needs to include some cusp headers (otherwise I'd have 
to do nasty forward declarations and the like).

Funny that I tried the same solution yesterday and can confirm it works. The 
issue is fixed for me.

Original comment by florian....@gmail.com on 18 Aug 2010 at 7:06

GoogleCodeExporter commented 8 years ago
Good.  This is fixed in Revision 50462ab4e9.

Original comment by mjgarl...@gmail.com on 18 Aug 2010 at 2:33