cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Fr4nz
Journeyman III

Unable to compile with Eclipse 3.5 + MinGW 5.16...

Hello all,

I've recently downloaded the latest stream 2.0 beta4 in order to play with OpenCL. Unfortunately, I'm encountering some problems when compiling, so I hope to find some help here.

First of all a description of my system: CPU is an Intel E6750, GPU an ATI 3870, 2GB of RAM, Windows XP SP3, and so on.

I was trying to compile a simple "Hello World" OpenCL program with Eclipse 3.5 and the GCC compiler provided by MinGW 5.16; my OS is Windows XP SP3. These are the steps I've followed in order to compile correctly:

1) Set the ATI Stream OpenCL "include" folder;

2) Set the ATI Stream OpenCL library folder (the one which contains OpenCL.lib)

3) Set the additional library to use, OpenCL.lib;

I think these are the only steps required, because if I follow what I've written above I can compile my "Hello World" without problems under MS Visual Studio 2008.

Anyway, my hello world program is simply this:

#include

int main(int argc, char *argv[]) {
    return(1);
}

...and these are the error messages reported in Eclipse Console:

**** Build of configuration Release for project DCIOpenCL ****

**** Internal Builder is used for build               ****
gcc -IC:\Programmi\ATI Stream\include -O0 -osrc\main.o ..\src\main.c
In file included from ..\src\main.c:1:
C:/Programmi/ATI Stream/include/CL/cl.h:62: error: syntax error before "cl_context_properties"
C:/Programmi/ATI Stream/include/CL/cl.h:62: warning: data definition has no type or storage class
C:/Programmi/ATI Stream/include/CL/cl.h:437: error: syntax error before '*' token
C:/Programmi/ATI Stream/include/CL/cl.h:440: error: `clCreateContext' declared as function returning a function
C:/Programmi/ATI Stream/include/CL/cl.h:441: error: syntax error before "void"
C:/Programmi/ATI Stream/include/CL/cl.h:445: error: syntax error before '*' token
C:/Programmi/ATI Stream/include/CL/cl.h:447: error: `clCreateContextFromType' declared as function returning a function
C:/Programmi/ATI Stream/include/CL/cl.h:448: error: syntax error before "void"
Build error occurred, build is stopped
Time consumed: 62  ms.

As you can see errors start at line 62 of cl.h, which is:

typedef intptr_t            cl_context_properties;

Any idea? Thank you for any answer!

Fr4nz

 

0 Likes
15 Replies
omkaranathan
Adept I

Which version of GCC are you using?

0 Likes

Originally posted by: omkaranathan Which version of GCC are you using?

 

 

If I'm correct, MinGW 5.16 installs GCC 3.4.5...maybe it is too old?

0 Likes

Originally posted by: Fr4nz 

 

If I'm correct, MinGW 5.16 installs GCC 3.4.5...maybe it is too old?

 

Yes, it is.

ATI StreamSDK beta4 need GCC version 4.3 or later.

0 Likes

Originally posted by: omkaranathan
Originally posted by: Fr4nz 

 

 

 

If I'm correct, MinGW 5.16 installs GCC 3.4.5...maybe it is too old?

 

 

 

 

Yes, it is.

 

ATI StreamSDK beta4 need GCC version 4.3 or later.

 

 

Got it!

Thank you for your quick answer! I'm gonna try GCC 4.4.0...have a nice day!

Fr4nz

0 Likes

Unfortunately also GCC 4.4.0 doesn't seem to work properly.

After following these steps in order to use latest GCC:

http://mingw.org/wiki/Getting_Started

if I try to compile this source...

#include
#include
#include
#include

int main(void) {
    puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */
    return EXIT_SUCCESS;
}


...I get the following output in Eclipse:

**** Build of configuration Debug for project DCIOpenCL ****

**** Internal Builder is used for build               ****
gcc -IC:\Programmi\ATI Stream\include -O0 -g3 -Wall -c -fmessage-length=0 -osrc\DCIOpenCL.o ..\src\DCIOpenCL.c
In file included from ..\src\DCIOpenCL.c:14:
C:\Programmi\ATI Stream\include/CL/cl.h:62: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cl_context_properties'
C:\Programmi\ATI Stream\include/CL/cl.h:437: warning: type defaults to 'int' in declaration of 'cl_context_properties'
C:\Programmi\ATI Stream\include/CL/cl.h:437: error: expected ';', ',' or ')' before '*' token
C:\Programmi\ATI Stream\include/CL/cl.h:445: warning: type defaults to 'int' in declaration of 'cl_context_properties'
C:\Programmi\ATI Stream\include/CL/cl.h:445: error: expected ';', ',' or ')' before '*' token
Build error occurred, build is stopped

Time consumed: 62  ms.



Maybe it's useful to underline that the first error in cl.h happens at row 62, which contains:

typedef intptr_t            cl_context_properties;


Any idea?

Fr4nz

0 Likes

Thanks to a friend of mine I've solved my problem.

I've commented these 2 lines in cl_platform.h (row 96-98):

// #if !defined(_WIN32)
# include <stdint.h>
// #endif /* !_WIN32 */


That was causing my problems.

Bye!

Fr4nz

 

0 Likes

Other strange errors with GCC 4.4.0. If it's true that I've solved previous compiling errors, now when I try to compile this code:

#include
#include
#include

int main(int argc, char* argv[]) {
    // Variabili usate da OpenCL (ambiente, coda dei comandi, ...)
    cl_platform_id platforms;
    cl_uint num_platforms;

    cl_device_id devices;
    cl_uint num_devices;

    // cl_command_queue codaComandi; // Coda dei comandi
    // cl_device_id idDisp; // ID dei dispositivi

    clGetPlatformIDs(1, &platforms, &num_platforms);
    clGetDeviceIDs(platforms,CL_DEVICE_TYPE_CPU,1,&devices,&num_devices);

    printf("Numero di piattaforme disponibili: %d", num_devices); /* prints !!!Hello World!!! */

    return EXIT_SUCCESS;
}


Eclipse console returns this:

**** Build of configuration Debug for project DCIOpenCL ****

**** Internal Builder is used for build               ****
gcc -IC:\Programmi\ATI Stream\include -O3 -g3 -Wall -c -fmessage-length=0 -osrc\main.o ..\src\main.c
..\src\main.c: In function 'main':
..\src\main.c:26: warning: 'platforms' is used uninitialized in this function
..\src\main.c:26: warning: 'num_platforms' is used uninitialized in this function
gcc -LC:\Programmi\ATI Stream\lib\x86 -oDCIOpenCL.exe src\main.o -lOpenCL
src\main.o: In function `main':
C:\eclipse\workspace\DCIOpenCL\Debug/../src/main.c:26: undefined reference to `clGetPlatformIDs'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 125  ms.


Why undefined reference?? If I compile under Visual Studio I don't get that error...

 

EDIT: Solved; the solution is to use OpenCL.dll as library instead of OpenCL.lib. So summarizing all:

1) You have to use GCC > 4.3.0

2) You have to modify cl_platform.h if you want to compile with minGW GCC;

3) You have to use OpenCL.dll as library;

Anyway there are still strange differences between GCC 4.4.0 and Visual Studio executables: for example the number of CPU devices returned by the Visual studio exe (stored in num_devices) is "1" (which is correct theoretically, given that I have an SS3 capable CPU), while the exe produced by GCC returns 4146080 devices available (which is crazy)...any ideas? Maybe a problem between GCC and the OpenCL.dll lib?

0 Likes
elq
Journeyman III

How can I use OpenCL.dll as library in Eclipse?

 

Update: Solved. 'dlltool' can create an import library from the DLL.

But I have same problem. (abnormal num_devices value)

 

Now, I'm trying to build CLInfo, HelloCL in SDK sample.

 

Update 2: CLInfo build OK, but have problem.

HelloCL build failed.

 

I use Eclipse 3.5.1 + TDM/MinGW (GCC 4.4.1).

 

Update 3: Oops, Forgot to copy OpenCL.dll to CLInfo folder.

but have problem...

1. CLInfo C:\workspace\CLInfo\Debug>CLInfo.exe For test only: Expires on Sun Feb 28 00:00:00 2010 Number of platforms: 1 Plaform Profile: Plaform Version: Plaform Name: Plaform Vendor: Plaform Name: Number of devices: 0 C:\workspace\CLInfo\Debug> 2. HelloCL g++ -oHelloCL.exe src\HelloCL.o -lOpenCL src\HelloCL.o: In function `main': C:\workspace\HelloCL\Debug/../src/HelloCL.cpp:33: undefined reference to `streamsdk::SDKFile::open(char const*)' collect2: ld returned 1 exit status Build error occurred, build is stopped

0 Likes

Have you included SDKUtil.lib in libraries to be linked with?

0 Likes

I tried to use SDKUtil.lib, but failed.

Please, AMD add support TDM/MinGW (GCC 4.4.1)!

http://stackoverflow.com/questions/1138170/use-libraries-compiled-with-visual-studio-in-an-application-compiled-by-g-ming If the library is written in C++ and exposes a C++ interface: no (because the name-mangling differs between g++ and VC++).

0 Likes

Originally posted by: elq I tried to use SDKUtil.lib, but failed.

 

Getting the same error? Could you post the output?

0 Likes

Originally posted by: omkaranathan

Getting the same error? Could you post the output?



 

I renamed SDKUtil.lib to LibSDKUtil.a (MinGW library naming format: LibBlah.a) and copy to lib folder.

Try to compile again, yes, same error. (undefined reference to `streamsdk::SDKFile::open(char const*)')

 

Need MinGW compatible library file! (SDKUtil, OpenCL)

 

0 Likes
Fr4nz
Journeyman III

Q]Originally posted by: elq

Originally posted by: omkaranathan

 

Getting the same error? Could you post the output?



 

 

 

I renamed SDKUtil.lib to LibSDKUtil.a (MinGW library naming format: LibBlah.a) and copy to lib folder.

 

Try to compile again, yes, same error. (undefined reference to `streamsdk::SDKFile:pen(char const*)')

 

 

Need MinGW compatible library file! (SDKUtil, OpenCL) 

I confirm what elq is saying: under Windows it would be nice to have libs that are MinGW compatible...current libs are not compatible (they work only with MSVS2005/2008).

0 Likes

Maybe you can try to setup Eclipse to use the microsoft compiler (AFAIK its available for free on microsoft.com). Google finds many threads related to this topic - maybe its possible to use msvc toolchain with Eclipse CDT

0 Likes

The Beta program page states as compatible linux compilers:

GNU Compiler Collection (GCC) 4.3 or later
Intel® C Compiler (ICC) 11.x

So, I think 3.4.x may just not be supported.

 

Edit: beaten!

0 Likes