15 Replies Latest reply on Nov 28, 2009 5:40 PM by Nasenbaer

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

    Fr4nz

      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

       

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

          Which version of GCC are you using?

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

               

              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?

                • Unable to compile with Eclipse 3.5 + MinGW 5.16...
                  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.

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

                       

                      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

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

                          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

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

                              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

                               

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

                                  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?

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

                            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!