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
).
#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");
}
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
gcc
nmake
CL.h
file from)%>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
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 are simple:
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. %>
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With