gpt4 book ai didi

c++ - 出现错误: “nvlink error : Undefined reference to ' _ZN8Strategy8backtestEPddd'”

转载 作者:行者123 更新时间:2023-12-02 11:01:33 25 4
gpt4 key购买 nike

当我为CUDA(v7.5)应用程序运行make时,出现以下错误:

nvlink error : Undefined reference to '_ZN8Strategy8backtestEPddd'

我不知道为什么。我的Makefile文件似乎有问题。这就是-任何想法可能导致错误的原因?先感谢您!
CC = nvcc
CFLAGS = -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field
LFLAGS = -L/usr/local/lib -Llib $(shell pkg-config --libs libmongoc-1.0 libbson-1.0)
INCLUDES = -I/usr/include -I/usr/local/include -Iinclude $(shell pkg-config --cflags libmongoc-1.0 libbson-1.0)
LIBS = -lgsl -lcblas
BIN = ./bin
OBJDIR = ./obj
OBJ = factories/optimizationStrategyFactory.o positions/callPosition.o positions/putPosition.o \
positions/position.o strategies/reversalsOptimizationStrategy.o strategies/optimizationStrategy.o \
strategies/strategy.o factories/optimizerFactory.o optimizers/reversalsOptimizer.o optimizers/optimizer.o \
factories/dataParserFactory.o dataParsers/oandaDataParser.o dataParsers/dataParser.o \
studies/study.o studies/smaStudy.o studies/emaStudy.o studies/rsiStudy.o \
studies/stochasticOscillatorStudy.o studies/polynomialRegressionChannelStudy.o

all: prepareData optimize

prepareData: src/prepareData.cu $(addprefix lib/,$(OBJ))
@mkdir -p $(BIN)
$(CC) $(CFLAGS) $(INCLUDES) -o $(BIN)/$@ src/prepareData.cu $(addprefix $(OBJDIR)/,$(addprefix lib/,$(OBJ))) $(LFLAGS) $(LIBS)

optimize: src/optimize.cu $(addprefix lib/,$(OBJ))
@mkdir -p $(BIN)
$(CC) $(CFLAGS) $(INCLUDES) -o $(BIN)/$@ src/optimize.cu $(addprefix $(OBJDIR)/,$(addprefix lib/,$(OBJ))) $(LFLAGS) $(LIBS)

%.o: %.cu
@mkdir -p $(OBJDIR)/lib/strategies $(OBJDIR)/lib/positions $(OBJDIR)/lib/factories $(OBJDIR)/lib/optimizers $(OBJDIR)/lib/dataParsers $(OBJDIR)/lib/studies
$(CC) $(CFLAGS) $(INCLUDES) -o $(OBJDIR)/$@ --device-c $<
clean:
rm -rf $(BIN) $(OBJDIR)

这是完整的编译器输出:
rm -rf ./bin ./obj
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/factories/optimizationStrategyFactory.o --device-c lib/factories/optimizationStrategyFactory.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/positions/callPosition.o --device-c lib/positions/callPosition.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/positions/putPosition.o --device-c lib/positions/putPosition.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/positions/position.o --device-c lib/positions/position.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/strategies/reversalsOptimizationStrategy.o --device-c lib/strategies/reversalsOptimizationStrategy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/strategies/optimizationStrategy.o --device-c lib/strategies/optimizationStrategy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/strategies/strategy.o --device-c lib/strategies/strategy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/factories/optimizerFactory.o --device-c lib/factories/optimizerFactory.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/optimizers/reversalsOptimizer.o --device-c lib/optimizers/reversalsOptimizer.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/optimizers/optimizer.o --device-c lib/optimizers/optimizer.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/factories/dataParserFactory.o --device-c lib/factories/dataParserFactory.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/dataParsers/oandaDataParser.o --device-c lib/dataParsers/oandaDataParser.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/dataParsers/dataParser.o --device-c lib/dataParsers/dataParser.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/study.o --device-c lib/studies/study.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/smaStudy.o --device-c lib/studies/smaStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/emaStudy.o --device-c lib/studies/emaStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/rsiStudy.o --device-c lib/studies/rsiStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/stochasticOscillatorStudy.o --device-c lib/studies/stochasticOscillatorStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/polynomialRegressionChannelStudy.o --device-c lib/studies/polynomialRegressionChannelStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./bin/prepareData src/prepareData.cu ./obj/lib/factories/optimizationStrategyFactory.o ./obj/lib/positions/callPosition.o ./obj/lib/positions/putPosition.o ./obj/lib/positions/position.o ./obj/lib/strategies/reversalsOptimizationStrategy.o ./obj/lib/strategies/optimizationStrategy.o ./obj/lib/strategies/strategy.o ./obj/lib/factories/optimizerFactory.o ./obj/lib/optimizers/reversalsOptimizer.o ./obj/lib/optimizers/optimizer.o ./obj/lib/factories/dataParserFactory.o ./obj/lib/dataParsers/oandaDataParser.o ./obj/lib/dataParsers/dataParser.o ./obj/lib/studies/study.o ./obj/lib/studies/smaStudy.o ./obj/lib/studies/emaStudy.o ./obj/lib/studies/rsiStudy.o ./obj/lib/studies/stochasticOscillatorStudy.o ./obj/lib/studies/polynomialRegressionChannelStudy.o -L/usr/local/lib -Llib -L/usr/local/lib -lsasl2 -lssl -lcrypto -lz -lmongoc-1.0 -lbson-1.0 -lgsl -lcblas
nvlink info : Function '_ZN12CallPosition13getProfitLossEv' has address taken but no possible call to it
nvlink info : Function '_ZN12CallPosition18getTransactionTypeEv' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPosition13getProfitLossEv' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPosition18getTransactionTypeEv' has address taken but no possible call to it
nvlink info : Function '_ZN8PositionD1Ev' has address taken but no possible call to it
nvlink info : Function '_ZN8PositionD0Ev' has address taken but no possible call to it
nvlink info : Function '_ZN12CallPositionD1Ev' has address taken but no possible call to it
nvlink info : Function '_ZN12CallPositionD0Ev' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPositionD1Ev' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPositionD0Ev' has address taken but no possible call to it
nvlink info : Function '_ZN29ReversalsOptimizationStrategy8backtestEPddd' has address taken but no possible call to it
nvlink info : Function '_ZN20OptimizationStrategy4tickEPd' has address taken but no possible call to it
nvlink info : Function '_ZN8Strategy8backtestEPddd' has address taken but no possible call to it
nvlink error : Undefined reference to '_ZN8Strategy8backtestEPddd' in './obj/lib/strategies/optimizationStrategy.o'
make: *** [prepareData] Error 255

请注意,这是在我添加 --device-c时开始发生的(某些代码更改要求)。

最佳答案

事实证明,传递给CUDA内核的对象不能具有虚拟功能。请参见this线程。

但是,似乎仅在内核中实例化和使用的对象可以具有虚函数。

关于c++ - 出现错误: “nvlink error : Undefined reference to ' _ZN8Strategy8backtestEPddd'”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37507274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com