0

I am new to gcc. I am trying to compile a C file created by Cython with help from this site: Compile main Python program using Cython

The C file was created successfully with following command:

cython --embed -o mycode.c mycode.py

I then used following gcc command:

gcc -Os -I E:\WinPython\python-3.6.5\include\ -o mycode mycode.c -L E:\WinPython\python-3.6.5\libs -lpython36 -lpthread -lm -lutil -ldl

But it gives following error:

C:/MinGW-W64/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lutil
C:/MinGW-W64/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -ldl
collect2.exe: error: ld returned 1 exit status

Where is the problem and how can it be solved?

jxh
  • 69,070
  • 8
  • 110
  • 193
rnso
  • 23,686
  • 25
  • 112
  • 234
  • Best solution: switch to Linux:). On a more serious note: That is seldom the case that workflows for Linux are working on Windows. You need to find tutorials for Windows. – ead Jul 12 '18 at 10:46
  • I fully agree but for distribution, one has to build for Windows because that is what everyone has. I am sure you can find the problem here. – rnso Jul 12 '18 at 10:56
  • 1
    `lutil`, `ldl` and others are Linux libraries, not sure where or whether they are on Windows. – ead Jul 12 '18 at 11:00
  • I think there is also another problem: When build with minwg there is no guarantee, that the extension can be used by Python build with MSVS – ead Jul 12 '18 at 11:01
  • @ead AFAIK Python exposes a C only interface, which is well defined for windows. – Rudi Jul 12 '18 at 11:36
  • 1
    @Rudi https://wiki.python.org/moin/WindowsCompilers states "Some alternative compilers exist like MinGW, but incompatibilities may occur with a CPython official distribution that is built with Microsoft Visual C++. " I remember some Cython-questions on SO which were resolved by switching to MSVC, but because I don't use Windows I never have verfied them. – ead Jul 12 '18 at 11:48
  • Sometimes you can compile under windows using mingw, or you can use visual stupidity, it has a special command line called nuget in which you can install meaningful non microsoft libraries that actually work. – Owl Jul 12 '18 at 12:32

0 Answers0