1

我有 make 4.2.1 和以下 make 文件,它应该运行编译 PyRubix.cpp 的步骤,其中有我需要的所有 pybind11 函数

BASIC_CPP=src/Rubix/RxBasic.cpp
BASIC_O=obj/RxBasic.o

CUBE_CPP=src/Rubix/RCube.cpp
CUBE_O=obj/RCube.o

XUTILITY_CPP=src/Rubix/RxXUtility.cpp
XUTILITY_O=obj/RxXUtility.o

UTILITY_CPP=src/Rubix/RxUtility.cpp
UTILITY_O=obj/RxUtility.o

PYRUBIX_CPP=src/PyRubix.cpp
PYRUBIX_O=obj/PyRubix.o

FINAL_TARGET=release/PyRubix.cpython-38-x86_64-linux-gnu.so

PYBIND11_PATH=/home/kubuntu/.local/lib/python3.8/site-packages/pybind11/include
CPYTHON_PATH=/usr/include/python3.8

$(FINAL_TARGET) : $(PYRUBIX_O) $(UTILITY_O) $(XUTILITY_O) $(CUBE_O) $(BASIC_O)
    g++ -O3 -Wall -shared -std=c++11 -fPIC $(PYRUBIX_O) $(UTILITY_O) $(XUTILITY_O) $(CUBE_O) $(BASIC_O) -o $(FINAL_TARGET)
    
$(BASIC_O) : $(BASIC_CPP)
    g++ -c -o $(BASIC_O) $(BASIC_CPP)
    
$(CUBE_O) : $(CUBE_CPP)
    g++ -c -o $(CUBE_O) $(CUBE_CPP)

$(XUTILITY_O) : $(XUTILITY_CPP)
    g++ -c -o $(XUTILITY_O) $(XUTILITY_CPP)

$(UTILITY_O) : $(UTILITY_CPP)
    g++ -c -o $(UTILITY_O) $(UTILITY_CPP)

$(PYRUBIX_O) : $(PYRUBIX_CPP)
    g++ -c -I$(CPYTHON_PATH) -I$(PYBIND11_PATH) -o $(PYRUBIX_O) $(PYRUBIX_CPP)

我收到了这个错误:

g++ -O3 -Wall -shared -std=c++11 -fPIC obj/PyRubix.o obj/RxUtility.o obj/RxXUtility.o obj/RCube.o obj/RxBasic.o -o release/PyRubix.so
/usr/bin/ld: obj/PyRubix.o: relocation R_X86_64_PC32 against undefined symbol `PyExc_ImportError' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:22: release/PyRubix.so] Error 1

我不知道我做错了什么,有人可以帮助我吗?

4

0 回答 0