linux - Can't compile CUDA + OpenGL program on Mac OS X El Capitan -


i writing program includes opengl , cuda codes @ university , can run ubuntu linux. program has got many dependencies use makefile , when i'm @ university linux have no problems. yesterday tried running on macbook @ home , didn't run. set libraries paths properly, when try compile using makefile following lines:

mbp-di-nicolo:matrix_test nico$ make /developer/nvidia/cuda-7.5/bin/nvcc -ccbin g++   -m64  -xcompiler -g -xcompiler -arch -xcompiler x86_64   -g -g -xlinker -rpath -xlinker /developer/nvidia/cuda-7.5/lib   -xlinker -framework -xlinker glut -o matrix_test my_utils2.o matrix_test.o matrix.o -l/system/library  -l/system/library/frameworks/opengl.framework/libraries  -lgl -lglu ../../common/lib/darwin/libglew.a -l. -lrt nvlink fatal   : not find fatbin in 'my_utils2.o' nvlink fatal   : elflink internal error make: *** [matrix_test] error 1 mbp-di-nicolo:matrix_test nico$  

here's makefile:

progname = matrix_test #progname2 = read_file  cc = g++  include ./findcudalib.mk  # location of cuda toolkit cuda_path ?= /developer/nvidia/cuda-7.5   #dek_src = ../pure-dek/src #dek_include = -i../pure-dek/include  # internal flags nvccflags   := -m${os_size}  #nvccflags   := -m${os_size} --keep ccflags     := -g  nvccldflags := -g -g ldflags     :=  # user flags extra_nvccflags   ?= extra_nvccldflags ?= extra_ldflags     ?= extra_ccflags     ?=  # os-specific build flags ifneq ($(darwin),)   ldflags += -rpath $(cuda_path)/lib  ccflags += -arch $(os_arch) $(stdlib)   else  ifeq ($(os_arch),armv7l)  ifeq ($(abi),gnueabi)   ccflags += -mfloat-abi=softfp else   # default gnueabihf   override abi := gnueabihf   ldflags += --dynamic-linker=/lib/ld-linux-armhf.so.3   ccflags += -mfloat-abi=hard endif endif endif  ifeq ($(armv7),1) nvccflags += -target-cpu-arch arm ifneq ($(target_fs),)  ccflags += --sysroot=$(target_fs) ldflags += --sysroot=$(target_fs) ldflags += -rpath-link=$(target_fs)/lib ldflags += -rpath-link=$(target_fs)/usr/lib ldflags += -rpath-link=$(target_fs)/usr/lib/arm-linux-$(abi) endif endif  # debug build flags  ifeq ($(dbg),1)   nvccflags += -g -g   target := debug else   target := release endif  all_ccflags := all_ccflags += $(nvccflags) all_ccflags += $(addprefix -xcompiler ,$(ccflags)) all_ccflags += $(extra_nvccflags) all_ccflags += $(addprefix -xcompiler ,$(extra_ccflags))  all_ldflags := all_ldflags += $(all_ccflags) all_ldflags += $(nvccldflags) all_ldflags += $(addprefix -xlinker ,$(ldflags)) all_ldflags += $(extra_nvccldflags) all_ldflags += $(addprefix -xlinker ,$(extra_ldflags))  # common includes , paths cuda ext_lib = /system/library includes  :=  libraries := -l$(ext_lib)   # makefile include find gl libraries exec            ?= include ./findgllib.mk  # opengl specific libraries  ifneq ($(darwin),) # mac osx specific libraries , paths include  libraries += -l/system/library/frameworks/opengl.framework/libraries   libraries += -lgl -lglu ../../common/lib/darwin/libglew.a  all_ldflags += -xlinker -framework -xlinker glut else  libraries += -l../../common/lib/$(oslower)/$(os_arch) $(gllink)  #libraries += -lglfw3 -lx11 -lxrandr -lxinerama -lxi -lxxf86vm -lxcursor -lgl -lpthread -ldl -lglew -lglut -lglu  libraries += -lglui -lglut -lglu -lgl -lx11 -lxi -lxmu -lglew endif    ################################################################################   # cuda code generation flags ifneq ($(os_arch),armv7l) gencode_sm10    := -gencode arch=compute_11,code=sm_11 endif gencode_sm10    := -gencode arch=compute_11,code=sm_11 gencode_sm20    := -gencode arch=compute_20,code=sm_20 gencode_sm30    := -gencode arch=compute_30,code=sm_30 -gencode          arch=compute_35,code=\"sm_35,compute_35\" gencode_flags   := $(gencode_sm11) $(gencode_sm20) $(gencode_sm30)   ################################################################################  # target rules all: build  build: $(progname)    my_utils2.o: my_utils2.cu my_utils2.h $(nvcc) $(includes) $(all_ccflags) $(gencode_flags) -o $@ -c $<  matrix.o: matrix.cu matrix.h my_utils2.h $(nvcc) $(includes) $(all_ccflags) $(gencode_flags) -o $@ -c $<  matrix_test.o: matrix_test.cu my_utils2.h $(nvcc) $(includes) $(all_ccflags) $(gencode_flags) -o $@ -c $<   $(progname): my_utils2.o matrix_test.o matrix.o   $(nvcc) $(all_ldflags) -o $@ $+ $(libraries) -l. -lrt mkdir -p ./bin/$(os_arch)/$(oslower)/$(target)$(if $(abi),/$(abi)) cp $@ ./bin/$(os_arch)/$(oslower)/$(target)$(if $(abi),/$(abi))  run: build ./$(progname)  clean: rm -f *.o #   rm -rf ./bin/$(os_arch)/$(oslower)/$(target)$(if $(abi),/$(abi))/mergesort  clobber: clean 

i didn't modify makefile used linux, except 2 lines (the following old ones):

# location of cuda toolkit cuda_path ?= "/usr/local/cuda-7.5"  # common includes , paths cuda ext_lib = /usr/local/lib 

could me please?

thanks lot!!

you don't have use nvcc link final program. in fact advise against it. nvcc should used compiling .cu files , rest left gcc/g++/clang.

in general it's bad idea force nvcc using particular compiler. let choose default. don't see in makefile posted (it's in findcuda.mk) definition variable nvcc, suspect there --ccbin flag configured.

furthermore in macos x opengl covered opengl framework. libraries libgl/libglu there support programs running through x11 server (which available in macos x), x11/glx/opengl support of macos x compatibility layer , not support cuda.

hence suggest change following:

libraries += ../../common/lib/darwin/libglew.a ldflags += -framework glut -framework opengl  all: build install  $(progname): my_utils2.o matrix_test.o matrix.o       $(ld) $(ldflags) -o $@ $+ $(libraries) -l.  install: $(progname)     mkdir -p ./bin/$(os_arch)/$(oslower)/$(target)$(if $(abi),/$(abi))     cp $@ ./bin/$(os_arch)/$(oslower)/$(target)$(if $(abi),/$(abi)) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -