cuda不支持最新版gcc解决方案

方案1:

      可以使用 nvcc –compiler-bindir 来指定另外的编译器目录

方案2:

      使用

sudo ln -s /usr/local/gcc46/bin/gcc46 /usr/local/cuda/bin/gcc
sudo ln -s /usr/local/gcc46/bin/g++46 /usr/local/cuda/bin/g++

  当然,上面的gcc46是我安装gcc-4.6的目录

方案3:

    修改/installdir/cuda/include/host_config.h ,改变80行的 “__GNUC_MINOR__ > X” 表达式,使用一个更高的minor版本。如下:

80: #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7)


Right now, if you try to compile the examples, you will get an error saying “/usr/bin/ld: cannot find -lcuda“.

There is an easy solution for that problem: make some symbolic links to the CUDA libraries.

su -c ‘ln -s /usr/lib64/nvidia/libcuda.so /usr/lib64/libcuda.so && ln -s /usr/lib64/nvidia/libcuda.so.1 /usr/lib64/libcuda.so.1’

reference:

http://reset.etsii.upm.es/en/users/peque/installing-cuda-in-fedora-16/sudo ln s /usr/local/gcc46/bin/gcc46 /usr/local/cuda/bin/gcc sudo ln s /usr/local/gcc46/bin/gcc46 /usr/local/cuda/bin/gcc

cudalib for myself

printf(“last error %d@%dn”, cudaGetLastError(), __LINE__);

#include <time.h>
#include <sys/time.h>
static inline double time_diff (
    timespec const& end, timespec const& begin)
{
#ifdef TIMING
    double result;
    result = end.tv_sec - begin.tv_sec;
    result += (end.tv_nsec - begin.tv_nsec) / (double)1000000000;
    return result;
#else
    return 0;
#endif
}
static inline void get_time (timespec& ts)
{
#ifdef TIMING
    volatile long noskip;
    #if _POSIX_TIMERS > 0
        clock_gettime(CLOCK_REALTIME, &ts);
    #else
        struct timeval tv;
        gettimeofday(&tv, NULL);
        ts.tv_sec = tv.tv_sec;
        ts.tv_nsec = tv.tv_usec*1000;
    #endif
    noskip = ts.tv_nsec;
#endif
}
static inline timespec get_time()
{
    timespec t;
#ifdef TIMING
    get_time(t);
#endif
    return t;
}
static inline double time_elapsed(timespec const& begin)
{
#ifdef TIMING
    timespec now;
    get_time(now);
    return time_diff(now, begin);
#else
    return 0;
#endif
}
static inline void print_time (char const* prompt, timespec const& begin, timespec const& end)
{
#ifdef TIMING
    printf("%s : %.3fn", prompt, time_diff(end, begin));
#endif
}
static inline void print_time (char const* prompt, double diff)
{
#ifdef TIMING
    printf("%s : %.3fn", prompt, diff);
#endif
}
static inline void print_time_elapsed (char const* prompt, timespec const& begin)
{
#ifdef TIMING
    printf("%s : %.3fn", prompt, time_elapsed(begin));
#endif
}
#endif // STDDEFINES_H_