Results 1 to 2 of 2

Thread: Getting undefined reference Errors

  1. #1
    Junior Member
    Join Date
    May 2012

    Getting undefined reference Errors

    I am trying to run the Opencl version of kmeans but getting some linking errors while running.

    kmeans_clustering.o: In function `kmeans_clustering':
    kmeans_clustering.c.text+0x7d2): undefined reference to `clCreateBuffer'
    kmeans_clustering.c.text+0x814): undefined reference to `clCreateBuffer'
    kmeans_clustering.c.text+0x85a): undefined reference to `clCreateBuffer'
    kmeans_clustering.c.text+0x88f): undefined reference to `clSetKernelArg'
    kmeans_clustering.c.text+0x8b0): undefined reference to `clSetKernelArg'
    kmeans_clustering.c.text+0x8d1): undefined reference to `clSetKernelArg'
    kmeans_clustering.c.text+0x8f1): undefined reference to `clSetKernelArg'
    kmeans_clustering.c.text+0x911): undefined reference to `clSetKernelArg'
    kmeans_clustering.o:kmeans_clustering.c.text+0x931): more undefined references to `clSetKernelArg' follow
    kmeans_clustering.o: In function `kmeans_clustering':
    kmeans_clustering.c.text+0xbb6): undefined reference to `clEnqueueNDRangeKernel

    This is my Makefile

    OPENCL_OPTS = -I ~/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc/ -L ~/NVIDIA_GPU_Computing_SDK/OpenCL/common/lib/ -l OpenCL

    DFLAGS =

    OPTFLAGS = -O2
    LDFLAGS = -lm -pg

    # CC = cc -g -non_shared -taso -DANSI -D__STDC__
    CC = gcc
    # CC = icc -openmp

    H_FILES = fuzzy_kmeans.h

    SRC = fuzzy_kmeans.c \
    cluster.c \
    kmeans_clustering.c \

    OBJ = $(SRC:%.c=%.o)

    $(CC) $(CFLAGS) -c $<

    all: example

    example: $(OBJ) $(H_FILES)
    $(CC) $(OPTFLAGS) -o example $(OBJ) $(LDFLAGS)

    Please someone help me..

  2. #2
    Senior Member
    Join Date
    Aug 2011

    Re: Getting undefined reference Errors

    this stuff is for the linker:
    -L ~/NVIDIA_GPU_Computing_SDK/OpenCL/common/lib/ -l OpenCL

    It needs to go into LDFLAGS, not CFLAGS.

Similar Threads

  1. Replies: 9
    Last Post: 01-11-2011, 02:20 PM
  2. Replies: 0
    Last Post: 11-09-2005, 09:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean