cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

dravisher
Journeyman III

Trying to compile hello world program

Lots of error messages that I don't understand

Hi. I'm trying to compile the hello world program presented here:

http://developer.amd.com/gpu/ATIStreamSDK/pages/TutorialOpenCL.aspx

I've copied everything up to and including the 5 first lines of the main function, and added return 0 at the end. The code is attached.

I'm using Visual Studio 2008 Professional SP1, on Windows 7 x64 (with 64-bit version of Stream SDK v2.01). I've appended the errors generated by Visual Studio at the end of the attached code.

It does seem like I've added the Stream SDK include directory correctly (since there are no errors pertaining to the include statements), and I've also tried to add opencl.lib as a dependency, but to no avail. Please note that I'm certainly a newbie at this. Though I have programmed several C++ applications in numerical physics using MPI, that is the extent of my programming knowledge, so I may have missed something trivial here.

If anyone would be bothered to point me in the right direction that would be great . I haven't been able to find any other tutorial for writing a first OpenCL application, but if anyone can recommend one that goes more in detail in how to actually make the code compile, that would be very helpfull too.

 

#include <utility> #define __NO_STD_VECTOR // Use cl::vector and cl::string and #define __NO_STD_STRING // not STL versions, more on this later #include <CL/cl.hpp> #include <cstdio> #include <cstdlib> #include <fstream> #include <iostream> #include <string> #include <iterator> const std::string hw("Hello World\n"); inline void checkErr(cl_int err, const char * name) { if (err != CL_SUCCESS) { std::cerr << "ERROR: " << name << " (" << err << ")" << std::endl; exit(EXIT_FAILURE); } } int main(void) { cl_int err; std::vector< cl::Platform > platformList; cl::Platform::get(&platformList); checkErr(platformList.size()!=0 ? CL_SUCCESS : -1, "cl::Platform::get"); std::cerr << "Platform number is: " << platformList.size() << std::endl; return 0; } /* ERRORS: 1>------ Build started: Project: OCLTest, Configuration: Debug x64 ------ 1>Compiling... 1>OCLTest.cpp 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1388) : error C3861: 'alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1407) : error C3861: 'alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1658) : error C3861: 'alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3379) : error C3861: 'alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3380) : error C3861: 'alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3459) : error C3861: 'alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3460) : error C3861: 'alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3708) : error C3861: 'alloca': identifier not found 1>.\OCLTest.cpp(28) : error C2039: 'vector' : is not a member of 'std' 1>.\OCLTest.cpp(28) : error C2065: 'vector' : undeclared identifier 1>.\OCLTest.cpp(28) : error C2275: 'cl::Platform' : illegal use of this type as an expression 1>.\OCLTest.cpp(28) : error C2065: 'platformList' : undeclared identifier 1>.\OCLTest.cpp(29) : error C2065: 'platformList' : undeclared identifier 1>.\OCLTest.cpp(30) : error C2065: 'platformList' : undeclared identifier 1>.\OCLTest.cpp(30) : error C2228: left of '.size' must have class/struct/union 1> type is ''unknown-type'' 1>.\OCLTest.cpp(31) : error C2065: 'platformList' : undeclared identifier 1>.\OCLTest.cpp(31) : error C2228: left of '.size' must have class/struct/union 1> type is ''unknown-type'' */

0 Likes
8 Replies
omkaranathan
Adept I

Add the follwing lines before including cl.hpp,

#include

#define alloca _alloca

also use cl::vector and cl::string if you are using

#define __NO_STD_VECTOR
#define __NO_STD_STRING

as said in the tutorial.
0 Likes

Thanks for your reply.

Is something missing in your lines? Having just #include alone on a line is not accepted.

Using #define alloca _alloca before including cl.hpp just gives me the attached error messages. Getting closer at least

 

1>------ Build started: Project: OCLTest, Configuration: Debug x64 ------ 1>Compiling... 1>OCLTest.cpp 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1388) : error C3861: '_alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1407) : error C3861: '_alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(1658) : error C3861: '_alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3379) : error C3861: '_alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3380) : error C3861: '_alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3459) : error C3861: '_alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3460) : error C3861: '_alloca': identifier not found 1>C:\Program Files (x86)\ATI Stream\include\CL/cl.hpp(3708) : error C3861: '_alloca': identifier not found 1>Build log was saved at "file://d:\My Dropbox\Annet\Visual Studio Projects\OCLTest\OCLTest\x64\Debug\BuildLog.htm" 1>OCLTest - 8 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

0 Likes

Sorry, its #include <malloc.h>

0 Likes

Thanks a lot for your help, it's finally compiling. Now I can start to actually explore a bit

0 Likes

Hi

I've copied and try to compile the code but  it has a error.

I'm beginning to learning OpenCL and my English is bad.

Help me!!!

thanks!

0 Likes

sorry, error :

1>------ Build started: Project: helloworld1, Configuration: Debug Win32 ------ 1>Compiling... 1>hello.cpp 1>c:\program files\ati stream\include\cl\helloworld1\helloworld1\hello.cpp(10) : fatal error C1083: Cannot open include file: 'CL/cl.hpp': No such file or directory 1>Build log was saved at "file://c:\Program Files\ATI Stream\include\CL\helloworld1\helloworld1\Debug\BuildLog.htm" 1>helloworld1 - 1 error(s), 0 warning(s)

0 Likes

You need to change your project settings to set include path. Take a look at the project settings of samples shipping with Stream SDK.

0 Likes

thanks so much!!

0 Likes