Link against cutil on a Mac

I tried to use cutil.h in one of my programs. I’m building with cmake, so far what I have

if(APPLE)

	set(CUDA_64_BIT_DEVICE_CODE OFF)	# Does not work on a Mac currently

	set(CMAKE_C_FLAGS -m32)

	set(CMAKE_CXX_FLAGS -m32)

	# cutil.h is there on a Mac

	include_directories("/Developer/GPU Computing/C/common/inc")

	link_directories("/Developer/GPU Computing/C/common/obj/i386/release")

endif()

and

target_link_libraries(PerfTest cutil)

I also tried to link against cutil_i386, the file is called cutil.cpp.o. I always end up with ld not finding the lib specified in target_link_libraries. What am I doing wrong?

If you are generating a make file target on OSX, then ‘make VERBOSE=1’ will show you all the commands that will be run. This is useful to see what is being fed to the linker.

Have you tried target_link_libraries(PerfTest cuilt.cpp.o)? If that doesn’t work, try specifying the full path to the file you want to link against. I’m pretty sure ld is going to get confused if you try -L/Developer/GPU…/release -lcuda_i386. Though I’m not sure you want to link against an object file. Does the CUDA SDK create libraries? In that case you can do:

find_library(CUDA_CUTIL_LIBRARY cutil "/Developer/GPU Computing/C/common/obj/i386/release")

target_link_library(PerfTest "${CUDA_CUTIL_LIBRARY}")

If you are generating a make file target on OSX, then ‘make VERBOSE=1’ will show you all the commands that will be run. This is useful to see what is being fed to the linker.

Have you tried target_link_libraries(PerfTest cuilt.cpp.o)? If that doesn’t work, try specifying the full path to the file you want to link against. I’m pretty sure ld is going to get confused if you try -L/Developer/GPU…/release -lcuda_i386. Though I’m not sure you want to link against an object file. Does the CUDA SDK create libraries? In that case you can do:

find_library(CUDA_CUTIL_LIBRARY cutil "/Developer/GPU Computing/C/common/obj/i386/release")

target_link_library(PerfTest "${CUDA_CUTIL_LIBRARY}")

This worked for me: [url=“予約インフォメーション”]予約インフォメーション

This worked for me: [url=“予約インフォメーション”]予約インフォメーション