Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Undefined reference to `__imp_PyComplex_AsCComplex' on windows #195
Comments
|
the first error being you should look into the generated link options (the |
|
I was having the same issue but I've managed to get something working. I first ran In # Makefile for python interface for package hi.
# File is generated by gopy. Do not edit.
# gopy gen -output=out github.com/go-python/gopy/_examples/hi
GOCMD=go
GOBUILD=$(GOCMD) build
GOIMPORTS=goimports
PYTHON=C:\Users\MrBBot\AppData\Local\Programs\Python\Python37\python.exe
LIBEXT=.pyd
# get the CC and flags used to build python:
GCC = $(shell $(GOCMD) env CC)
CFLAGS = -IC:/Users/MrBBot/AppData/Local/Programs/Python/Python37/include
LDFLAGS = -LC:/Users/MrBBot/AppData/Local/Programs/Python/Python37/libs -lpython37
all: gen build
gen:
gopy gen github.com/go-python/gopy/_examples/hi
build:
# build target builds the generated files -- this is what gopy build does..
# this will otherwise be built during go build and may be out of date
- rm hi.c
# goimports is needed to ensure that the imports list is valid
$(GOIMPORTS) -w hi.go
# generate hi_go$(LIBEXT) from hi.go -- the cgo wrappers to go functions
$(GOBUILD) -buildmode=c-shared -o hi_go$(LIBEXT) hi.go
# use pybindgen to build the hi.c file which are the CPython wrappers to cgo wrappers..
# note: pip install pybindgen to get pybindgen if this fails
$(PYTHON) build.py
# build the _hi$(LIBEXT) library that contains the cgo and CPython wrappers
# generated hi.py python wrapper imports this c-code package
$(GCC) hi.c hi_go$(LIBEXT) -o _hi$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -wI also changed the LDFLAGS in /*
cgo stubs for package hi.
File is generated by gopy. Do not edit.
gopy gen -output=out github.com/go-python/gopy/_examples/hi
*/
package main
/*
#cgo CFLAGS: -IC:/Users/MrBBot/AppData/Local/Programs/Python/Python37/include
#cgo LDFLAGS: -LC:/Users/MrBBot/AppData/Local/Programs/Python/Python37/libs -lpython37
...
*/Then I ran A fix shouldn't be too hard but I'm not sure if adding these specific relatives paths for the linker flags would break anything on platforms other than Windows. |
|
Thanks guys! @mrbbot, your local fix worked. It gave me a clue on where to look for the problem. @sbinet you were right. Originally I got This is what I get from {
"LIBDEST": "C:\\dev\\tools\\anaconda3\\Lib",
"BINLIBDEST": "C:\\dev\\tools\\anaconda3\\Lib",
"INCLUDEPY": "C:\\dev\\tools\\anaconda3\\include",
"EXT_SUFFIX": ".cp36-win_amd64.pyd",
"EXE": ".exe",
"VERSION": "36",
"BINDIR": "C:\\dev\\tools\\anaconda3",
"prefix": "C:\\dev\\tools\\anaconda3",
"exec_prefix": "C:\\dev\\tools\\anaconda3",
"SO": ".cp36-win_amd64.pyd",
"srcdir": "C:\\dev\\tools\\anaconda3"
}With pypy even less: {
"LIBDEST": "C:\\Users\\amit\\Desktop\\pypy3.6-v7.1.1-win32\\lib-python\\3",
"BINLIBDEST": "C:\\Users\\amit\\Desktop\\pypy3.6-v7.1.1-win32\\lib-python\\3",
"INCLUDEPY": "C:\\Users\\amit\\Desktop\\pypy3.6-v7.1.1-win32\\include",
"EXT_SUFFIX": ".pypy3-71-win32.pyd",
"EXE": ".exe",
"VERSION": "36",
"BINDIR": "C:\\Users\\amit\\Desktop\\pypy3.6-v7.1.1-win32",
"prefix": "C:\\Users\\amit\\Desktop\\pypy3.6-v7.1.1-win32",
"exec_prefix": "C:\\Users\\amit\\Desktop\\pypy3.6-v7.1.1-win32"
}One possible solution is to craft those values manually on windows. Something like: if raw.LibDir == "" {
raw.LibDir = prefix + "libs"
}
if raw.LibPy == "" {
raw.LibPy = "python" + versionWithMinor
}What do you think? |
|
Hello, @mrbbot fixes compilation errors in Windows. But making them manually is exhausting. There may be common mistakes for a developer, I think these errors need to be fixed for Windows. The project is not actively developed, #201 . There also seems to be these errors. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Using go1.11, anaconda 3 and mingw-w64 gcc.
Got:
I am not sure how to debug this. Happy to look into it if you have any leads for me.