OrsoStefano / opencl-book-samples

Automatically exported from code.google.com/p/opencl-book-samples
0 stars 0 forks source link

problem compiling Convolution.cpp #55

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am using AMD APP SKD v2.6 on Ubuntu 10.04 on 32bit Intel CPU, with 
compiler gcc version 4.4.5.

After generating the Makefile and running make, the code for Convolution.cpp 
stops compiling with the following error:

[ 30%] Building CXX object 
src/Chapter_3/OpenCLConvolution/CMakeFiles/OpenCLConvolutionChap3.dir/Convolutio
n.cpp.o
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp: In function ‘void checkErr(cl_int, const char*)’:
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp:70: error: ‘EXIT_FAILURE’ was not declared in this scope
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp:70: error: ‘exit’ was not declared in this scope
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp: In function ‘void contextCallback(const char*, const void*, 
size_t, void*)’:
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp:84: error: ‘exit’ was not declared in this scope
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp: In function ‘int main(int, char**)’:
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp:112: error: ‘alloca’ was not declared in this scope
/home/devel/opencl-book-samples-read-only/src/Chapter_3/OpenCLConvolution/Convol
ution.cpp:152: error: ‘exit’ was not declared in this scope
make[2]: *** 
[src/Chapter_3/OpenCLConvolution/CMakeFiles/OpenCLConvolutionChap3.dir/Convoluti
on.cpp.o] Error 1
make[1]: *** 
[src/Chapter_3/OpenCLConvolution/CMakeFiles/OpenCLConvolutionChap3.dir/all] 
Error 2
make: *** [all] Error 2

It seems that the compiler does not find the functions exit and alloca because 
the corresponding C headers are not included. If I add the line

#include<cstdlib>

the program compiles, but on running it exits with the error:

ERROR: reading Convolution.cl (-1)

Any help would be appreciated.

Original issue reported on code.google.com by aripak...@gmail.com on 24 Jan 2012 at 4:30

GoogleCodeExporter commented 8 years ago
The problem is that I was using Ubuntu 10.04 and the supported versions are 
11.xx

Original comment by aripak...@gmail.com on 24 Jan 2012 at 6:32

GoogleCodeExporter commented 8 years ago
I get this error when running and i am using 12.04, any help?

Original comment by caspercp...@gmail.com on 3 Oct 2012 at 12:27

GoogleCodeExporter commented 8 years ago
The file is simply missing from the build directory

Original comment by caspercp...@gmail.com on 3 Oct 2012 at 1:03

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
The kernel file Convolution.cl is read at run time of the executable 
OpenCLConvolutionChap3, so must be present in the same folder as that 
executable. In the HelloWorld example of Chapter 2, the HelloWorld.cl file is 
read into a string at compile time of the HelloWorld executable, so this was 
not an issue there.

Having a separate build tree for these examples isn't necessary, since these 
examples can be built simply in the src tree itself. For example in the 
src/Chapter_3/OpenCLConvolution folder (on a Mac) by 

$ c++ -o OpenCLConvolutionChap3 -framework openCL Convolution.cpp

and then running the example with

$ ./OpenCLConvolutionChap3

gives the proper output.

Original comment by haj.kos...@gmail.com on 11 Jan 2014 at 12:52