CUDA OpenGL Compilation w/o SDK

Howdy fellow forum-ers. Has anyone built CUDA code without including the SDK? I.e. I want to write a Makefile that doesn’t use the line
include …/…/common/common.mk

but instead uses -lopengl flags.

I have come close with the following line
GLFLAGS=-L/System/Library/Frameworks/GLUT.framework -Xlinker -framework,OpenGL,-framework,GLUT

however, I get linker errors which say various openGL functions such as glBindBuffer are not recognized. Any help is greatly appreciated! Thanks.

Mac OS 10.6.8, 2.4 GHz Intel Core 2 Duo, GeForce 320M.

So I figured out how to write a standalone app via cmake. Here’s an example CMakeLists.txt:

cmake_minimum_required (VERSION 2.8)

project (CUDA_OPENGL)

find_package(“CUDA”)
find_package(“OpenGL”)
find_package(“GLUT”)

cuda_include_directories({CUDA_SDK_ROOT_DIR}/common/inc {CUDA_SDK_ROOT_DIR}/…/shared/inc
/usr/local/cuda/include)
include_directories(${CUDA_SDK_ROOT_DIR}/common/inc)

set(CMAKE_CXX_LINK_FLAGS
“-framework OpenGL -framework GLUT”)

set(CUDA_SDK_LIB_DIR
{CUDA_SDK_ROOT_DIR}/common/lib {CUDA_SDK_ROOT_DIR}/lib
${CUDA_SDK_ROOT_DIR}/…/shared/lib)

if (CMAKE_SIZEOF_VOID_P MATCHES “8”)
set(CMAKE_SYSTEM_PROCESSOR “x86_64”)
set(arch “x86_64”)
else()
set(CMAKE_SYSTEM_PROCESSOR “i386”)
set(arch “i386”)
endif()

message(“CMAKE_SYSTEM_PROCESSOR = {CMAKE_SYSTEM_PROCESSOR}") message("ARCH = {arch}”)

Find path to shared opengl libraries

find_library(LIBPARAMGL NAME paramgl_{CMAKE_SYSTEM_PROCESSOR} PATHS {CUDA_SDK_LIB_DIR})
message(“LIBPARAMGL = {LIBPARAMGL}") find_library(LIBRENDERCHECKGL NAME rendercheckgl_{CMAKE_SYSTEM_PROCESSOR} PATHS {CUDA_SDK_LIB_DIR}) message("LIBRENDERCHECKGL = {LIBRENDERCHECKGL}”)

Find path to shrutil libs, from CUDA SDK

find_library(LIBSHRUTIL NAME shrutil_{CMAKE_SYSTEM_PROCESSOR} PATHS {CUDA_SDK_LIB_DIR})
find_library(LIBSHRUTIL_DBG NAME shrutil_{CMAKE_SYSTEM_PROCESSOR}D PATHS {CUDA_SDK_LIB_DIR})
message(“LIBSHRUTIL = ${LIBSHRUTIL}”)

Find path to cutil libs, from CUDA SDK

find_library(LIBCUTIL NAMES cutil_{CMAKE_SYSTEM_PROCESSOR} PATHS {CUDA_SDK_LIB_DIR})
find_library(LIBCUTIL_DBG NAMES cutil_{CMAKE_SYSTEM_PROCESSOR}D PATHS {CUDA_SDK_LIB_DIR})
message(“LIBCUTIL = ${LIBCUTIL}”)

Build kernels for desired compute capabilities

macro(set_compute_capability cc)
list(APPEND CUDA_NVCC_FLAGS “-gencode=arch=compute_{cc},code=sm_{cc}”)
list(APPEND CUDA_NVCC_FLAGS “-gencode=arch=compute_{cc},code=compute_{cc}”)
endmacro(set_compute_capability)

set_compute_capability(“11”)

FIND_LIBRARY( GLEW_LIBRARY
    NAMES GLEW glew
    PATHS
    /usr/lib64
    /usr/lib
    /usr/local/lib64
    /usr/local/lib
    /sw/lib
    /opt/local/lib
    DOC "The GLEW library")

IF (LIBCUTIL AND OPENGL_FOUND)
cuda_add_executable(Exe Exe.cu)
# simpleGL_kernel.cu)

target_link_libraries(.Exe 
	${GLEW_LIBRARY} 
	${LIBRENDERCHECKGL} 
	${LIBPARAMGL} 
	${LIBCUTIL} 
	${LIBSHRUTIL} 
	${GLUT_LIBRARIES}
	${OPENGL_GLU_LIBRARY})

ENDIF ()

¡¡¡Hope this helps someone!!!

It did help me realize that opengl dependencies cannot be satisfied by cuda opengl static libraries alone and the OS X frameworks are required.

Thanks.

–8