Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6042985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:51:01+00:00 2026-05-23T06:51:01+00:00

I’m trying to compile something to try out openCl, but i’m having a few

  • 0

I’m trying to compile something to try out openCl, but i’m having a few problems..

Here the code

prova.c

#include <stdio.h>
#include <CL/opencl.h>
#include "Utils\util.h"
#include <malloc.h>

int main(){
    cl_int error = 0;   // Used to handle error codes
    cl_int max_platforms = 1; // The maximum number of platforms
    cl_uint adviable_platforms = 0; //The adviable number of platforms
    cl_platform_id* platform;

    error = clGetPlatformIDs(0, NULL, &adviable_platforms);
    if(adviable_platforms == 0)
    {
        printf("No adviable platforms.\n");
        return -1;
    } else {
        platform = (cl_platform_id*)malloc(adviable_platforms * sizeof(cl_platform_id));
    }

    error = clGetPlatformIDs(adviable_platforms, platform, NULL);


    printf("clGetPlatformIDs: %s\n", clErrorString(error));
    return 0;
}

I’m compiling on win 7 64 with mingw32. The opencl headers are in the include directory of mingw while utils.h(inside the directory Utils inside the directory of prova.c) defines clErrorString(that simply convert the error into a more human readable string).

To compile i use

gcc -L\Utils prova.c

But i always get

C:\[stuff]\ccEjYQbj.o:prova.c:(.text+0x42): undefined reference to 'clGetPlatformIDs@12'
C:\[stuff]\ccEjYQbj.o:prova.c:(.text+0x8d): undefined reference to 'clGetPlatformIDs@12'
C:\[stuff]\ccEjYQbj.o:prova.c:(.text+0x9e): undefined reference to 'clErrorString'

I’m not so good with compilers, so i image i’m missing something, but i really don’t know what..

EDIT:
Sincerely, i tried every command come to my mind. using -L to include directories, -l to link to files, using ar..

This is the last “script” i tried

set PATH=%PATH%;C:\Python26;C:\MinGW\bin;C:\MinGW\lib

cd Utils
gcc -c util.c -l"C:\Program Files (x86)\AMD APP\lib\x86_64\libOpenCL.a" -o util.o
ar rcs libutil.a util.o

cd..
pause

gcc -c prova.c -l"Utils\libutil.a" -o prova.exe

pause

EDIT2:

@echo off
set PATH=%PATH%;C:\Python26;C:\MinGW\bin;C:\MinGW\lib

cd Utils
gcc -Wall -c util.c -L"C:\Program Files (x86)\AMD APP\lib\x86_64\" -o util.o
ar rcs libutil.a util.o

cd..
pause

gcc -Wall -c prova.c -L"C:\Program Files (x86)\AMD APP\lib\x86_64\" -l"Utils\libutil.a" -o prova.exe

pause

No errors, the only warning is max_platform is unused. Then i find util.o and libutil.a(size 5kb) in Utils and prova.o(size 1kb). If i try to run prova.o, it says that the file version is not compatible with the current windows version, check the system version (x86 or x64) and contact the software distributor

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:51:01+00:00Added an answer on May 23, 2026 at 6:51 am

    Try something like this:

    set PATH=%PATH%;C:\Python26;C:\MinGW\bin;C:\MinGW\lib
    
    cd Utils
    gcc -W -Wall -c util.c -o util.o
    ar rcs libutil.a util.o
    
    cd..
    
    gcc -W -Wall -c prova.c -o prova.o
    gcc -o prova.exe prova.o Utils\libutil.a
    
    # Using a standard library
    gcc -o prog.exe myprog.o -lzip  # e.g. /usr/lib/libz.a
    
    # Using a nonstandard library
    gcc -o prog.exe myprog.o -lfoo -L/tmp/libfoo  # uses /tmp/libfoo/libfoo.a
    gcc -o prog.exe myprog.o /tmp/libfoo/libfoo.a # same effect
    

    In general:

    • Compile single source files with -c:
      gcc -c myfile.c -o myfile.o.
      This creates object files.

    • Link all the object files to an executable (or shared library):
      gcc -o prog.exe myfile.o yourstuff.o sha257.o

    • You can combine object files into a static library, which you treat just like a single object file when linking:
      ar rcs libcoolstuff.a yourstuff.o sha257.o
      gcc -o prog.exe myfile.o libcoolstuff.a
      Alternatively:
      gcc -o prog.exe myfile.o -lcoolstuff
      The latter syntax (automatic library linking with -l) requires either libcoolstuff.a or libcoolstuff.so to be findable in the library path (which you can amend with -L at linktime).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.