Unable to compile sample boost::compute on VS2015

138 views
Skip to first unread message

Mat Frugo

unread,
Apr 4, 2017, 8:45:49 AM4/4/17
to boost-compute
#include <iostream>
#include <boost/compute/core.hpp>
namespace compute = boost::compute;
int main()
{   
    compute::device device = compute::system::default_device();
    std::cout << "hello from " << device.name() << std::endl;
    return 0;
}

compiler outputs: c:\program files (x86)\microsoft visual studio 14.0\vc\include\xutility(2372): error C4996: 'std::copy::_Unchecked_iterators::_Deprecate': Call to 'std::copy' with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'

but sample opencl program:
#include<stdio.h>
#include<CL/cl.h>
int main(void)
{
    cl_int err;
    cl_uint numPlatforms;
    err = clGetPlatformIDs(0, NULL, &numPlatforms);
    if (CL_SUCCESS == err)
        printf("\nDetected OpenCL platforms: %d", numPlatforms);
    else
        printf("\nError calling clGetPlatformIDs. Error code: %d", err);
    return 0;
}

Works just fine.

How to run boost::compute on windows?
Any tips? Or help?

Regards

Jakub Szuppe

unread,
Apr 4, 2017, 4:30:03 PM4/4/17
to boost-compute
I would recommend to pass to VS C++ compiler options mentioned in https://github.com/boostorg/compute/blob/master/CMakeLists.txt#L88 

Mat Frugo

unread,
Apr 6, 2017, 6:36:57 AM4/6/17
to boost-compute
Adding _SCL_SECURE_NO_WARNINGS at beginning of source file seems to solve the problem.

Thank You for your help :)
Reply all
Reply to author
Forward
0 new messages