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

  • SEARCH
  • Home
  • 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 8546601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:04:10+00:00 2026-06-11T13:04:10+00:00

I just wanted to try out using OpenCL under Windows. Abstract : I got

  • 0

I just wanted to try out using OpenCL under Windows.

Abstract: I got an “undefined reference to” error when I tried to compile (using the command gcc my.o -o my.exe -L "C:\Program Files (x86)\AMD APP\lib\x86_64" -l OpenCL).


My Code

#include <CL/cl.h>
#include <stdio.h>

int main(void) {   
    cl_platform_id platform;
    int err;

    err = clGetPlatformIDs(1, &platform, NULL);
    if(err < 0) {
        perror("There's No Platform!");
        exit(1);
    }

    /* Some more code... */

    system("PAUSE");
}

Makefile

all: addition

addition:
    gcc -c -I "C:\Program Files (x86)\AMD APP\include" my.c -o my.o
    gcc my.o -o my.exe -L "C:\Program Files (x86)\AMD APP\lib\x86_64" -l OpenCL

Used Programs

  • MinGW’s gcc
  • Visual Studio’s nmake
  • AMD’s OpenCL™ APP SDK (that’s where I took the OpenCL library and the CL.h file from)

The Structure of APP SDK’s Folders

%>tree /F "C:\Program Files (x86)\AMD APP\lib\x86_64"
Auflistung der Ordnerpfade
Volumeseriennummer : D2DC-D765
C:\PROGRAM FILES (X86)\AMD APP\LIB\X86_64
    libOpenCL.a
    OpenCL.lib
    OpenVideo64.lib

Es sind keine Unterordner vorhanden


%>tree /F "C:\Program Files (x86)\AMD APP\include"
Auflistung der Ordnerpfade
Volumeseriennummer : D2DC-D765
C:\PROGRAM FILES (X86)\AMD APP\INCLUDE
├───CAL
│       cal.h
│       calcl.h
│       cal_ext.h
│       cal_ext_counter.h
│       cal_ext_d3d10.h
│       cal_ext_d3d9.h
│
├───CL
│       cl.h
│       cl.hpp
│       cl_d3d10.h
│       cl_ext.h
│       cl_gl.h
│       cl_gl_ext.h
│       cl_platform.h
│       opencl.h
│
└───OpenVideo
        OpenVideo.h
        OVDecode.h
        OVDecodeTypes.h
        OVEncode.h
        OVEncodeTypes.h

Error Message

        gcc addition.o -o addition.exe -L "C:\Program Files (x86)\AMD APP\lib\x86_64" -l OpenCL
addition.o:addition.c:(.text+0x2d): undefined reference to `clGetPlatformIDs@12'
addition.o:addition.c:(.text+0x83): undefined reference to `clGetDeviceIDs@24'
addition.o:addition.c:(.text+0xc2): undefined reference to `clGetDeviceIDs@24'
collect2: ld returned 1 exit status
NMAKE : fatal error U1077: "C:\prog-x86\MinGW\bin\gcc.EXE": Rückgabe-Code "0x1"
Stop.

My Questions

My questions are simple:

  • Why doesn’t my code compile how it is expected to?
  • What can I do to get rid of this problem?

Thanks.


UPDATE: The error message after dropping the spaces like described in @codaddict ‘s answer.

(Makefile)

all: addition

addition:
  gcc -c -I "C:\prog-x86\AMD-APP\include" addition.c -o addition.o
  gcc addition.o -o addition.exe -LC:\prog-x86\AMD-APP\lib\x86_64 -lOpenCL

(Shelldata)

%>nmake

Microsoft (R) Program Maintenance Utility, Version 11.00.50727.1
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

        gcc -c -I "C:\Program Files (x86)\AMD APP\include" addition.c -o addition.o
addition.c: In function 'main':
addition.c:14:9: warning: incompatible implicit declaration of built-in function 'exit' [enabled by d
efault]
addition.c:23:9: warning: incompatible implicit declaration of built-in function 'exit' [enabled by d
efault]
        gcc addition.o -o addition.exe -LC:\prog-x86\AMD-APP\lib\x86_64 -lOpenCL
addition.o:addition.c:(.text+0x2d): undefined reference to `clGetPlatformIDs@12'
addition.o:addition.c:(.text+0x83): undefined reference to `clGetDeviceIDs@24'
addition.o:addition.c:(.text+0xc2): undefined reference to `clGetDeviceIDs@24'
collect2: ld returned 1 exit status
NMAKE : fatal error U1077: "C:\prog-x86\MinGW\bin\gcc.EXE": Rückgabe-Code "0x1"
Stop.

%>
  • 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-06-11T13:04:11+00:00Added an answer on June 11, 2026 at 1:04 pm

    The default MinGW distribution only ships tools for building x86 applications. You cannot link against the x64 version of the OpenCL library. So you either have to use MinGW-w64 or use the x86 version (change the library path to the x86 subfolder of the APP SDK).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just wanted to try out SPDY using the node package node-spdy. My javascript:
I just started out with Python and wanted to try out tornado. Running the
I just discovered forge and wanted to try it out at once. I closely
I just wanted to try out some shaders on a flat image. Turns out
I just wanted to try out this code... #include <iostream> #include <stdio.h> #include <string.h>
I am just starting out on Silverlight using version 2.0. I wanted to show
Just wanted to know if anyone is really using Objects and Collections in Oracle
Wanted to try something new, using the awesome twitter bootstrap and their Less CSS
I've just started using DOM and wanted to parse an Android XML layout file
NOTE: I tried using concat() method, join method and even tried to insert just

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.