Windows Boost Python using Gcc compiler; undefined reference to `__imp__Py_NoneStruct'

Viewed 17

I'm newbee to cpp, when I try to build hello world in python boost, I config tasks.json as

            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-I",
                "E:\\boost_1_80_0\\boostpython\\include\\boost-1_80",
                "-I",
                "C:\\ProgramData\\Anaconda3\\include",
                "-L",
                "C:\\ProgramData\\Anaconda3\\libs",
                "-L",
                "E:\\boost_1_80_0\\boostpython\\lib",
        
            ],

console is like

E:\g++64\mingw64\bin\g++.exe -fdiagnostics-color=always -g D:\project_CPP\boostpython\hello.cpp -o D:\project_CPP\boostpython\hello.exe -I E:\boost_1_80_0\boostpython\include\boost-1_80 -I C:\ProgramData\Anaconda3\include -L C:\ProgramData\Anaconda3\libs -L E:\boost_1_80_0\boostpython\lib -l C:\ProgramData\Anaconda3\python.exe

I got errlor below

e:/codelibrarry/g++64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\MICHAE~1\AppData\Local\Temp\ccPaInQ7.o: in function boost::python::api::object::object()': E:/codelibrarry/boost_1_80_0/boostpython/include/boost-1_80/boost/python/object_core.hpp:400: undefined reference to __imp__Py_NoneStruct'

It seems like I miss the -l (small case of L) config to point to python linker library, but the question is, what should I input for -l ?

I see same error in Boost Python - undefined reference to `_Py_NoneStruct'

However, I dont know how to convert his CMakle file in GCC tasks.json

0 Answers
Related