Why am I getting "nvcc fatal: override for" optimize "argument?
I am trying to compile on MacBook Pro Retina with CUDA Driver Version: 7.0.36 and cuda toolkit 7.0 in nVidia GT 750 M, the following code with its makefile, but it gives me this error:
nvcc fatal: override the 'optimize' argument.
Even though I was able to compile and execute other programs with nvcc, with makefiles and so, now I am not.
Also, I haven't been able to find anything useful in this error, so I ask it here if anyone knows how to solve it. I'm new to CUDA, so if you need more information please ask for it.
Here is mine Makefile.inc
:
CXX := nvcc
OPTIM := -O3
DEBUG := -g -DOLB_DEBUG
CXXFLAGS := $(OPTIM)
ARPRG := ar
LDFLAGS := -O3
PARALLEL_MODE := OFF
OMPFLAGS := -fopenmp
BUILDTYPE := precompiled
INPUTDIR := ./input
OUTPUTDIR := ./output
INCDIR := ./inc
OBJDIR := ./obj
SRCDIR := ./HeatTransfer
BINDIR := ./bin
###########################################################################
## defines shell
SHELL := /bin/sh
and Makefile
:
###########################################################################
ROOT := .
include $(ROOT)/Makefile.inc
######################################################## Operational system
OS = $(shell uname -s)
MACH = $(shell uname -m)
HOST = $(shell uname -n)
WHOAMI = $(shell whoami )
###########################################################################
HeatTransfer := \
mesh\
stack
PROGRAM := $(BINDIR)/program
###########################################################################
OBJECTS := $(foreach file, $(HeatTransfer), $(OBJDIR)/$(file).o)
###########################################################################
all : compile link
###########################################################################
compile : $(OBJECTS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cu
@echo Compile $<
$(CXX) $(CXXFLAGS) -I$(INCDIR) -c $< -o $@
###########################################################################
link: $(PROGRAM)
$(PROGRAM): $(OBJECTS)
@echo Link $@
$(CXX) $(LDFLAGS) -I$(INCDIR) $(foreach file, $(HeatTransfer), $(OBJDIR)/$(file).o) $(LDFLAGS) -I$(INCDIR) -o $@
###########################################################################
clean : cleanprog cleanobj
cleanprog:
@echo Clean rubbish files
@rm -f *~ core .tmpfile $(PROGRAM)
cleanobj:
@echo Clean object files
@rm -f $(OBJECTS)
###########################################################################
###########################################################################
The complete messege when I try to compile is as follows:
...Heat_Transfer_CUDA$ make
Compile HeatTransfer/mesh.cu
nvcc -O3 -I./inc -c HeatTransfer/mesh.cu -o obj/mesh.o
Compile HeatTransfer/stack.cu
nvcc -O3 -I./inc -c HeatTransfer/stack.cu -o obj/stack.o
Link bin/program
nvcc -O3 -I./inc ./obj/mesh.o ./obj/stack.o -O3 -I./inc -o bin/program
nvcc fatal : redefinition of argument 'optimize'
make: *** [bin/program] Error 1
source to share
The problem occurs because your bind command points the switch twice -O3
:
nvcc -O3 -I./inc ./obj/mesh.o ./obj/stack.o -O3 -I./inc -o bin/program
^^^ ^^^
And this is unacceptable - it will lead to an error.
The problem comes from your makefile
pointing to use LDFLAGS
here twice:
$(CXX) $(LDFLAGS) -I$(INCDIR) $(foreach file, $(HeatTransfer), $(OBJDIR)/$(file).o) $(LDFLAGS) -I$(INCDIR) -o $@
which shouldn't be necessary. Something like that:
$(CXX) $(LDFLAGS) -I$(INCDIR) $(foreach file, $(HeatTransfer), $(OBJDIR)/$(file).o) -o $@
will probably fix the problem.
source to share