jazzycamel / PyMyLabel

A minimal example of using SIP to create a Python wrapper for a C++ Qt5 library.
MIT License
9 stars 1 forks source link

Error in `make` after `python configure.py` #2

Closed heatblazer closed 7 years ago

heatblazer commented 7 years ago

Hello, I am on linux Python3.4, I am getting the following error:

Entering directory '/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/modules'
g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -DMYLABEL_LIBRARY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -I/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/src -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include -I/home/ilian/git-projects/prosfitdesktop/include/python3.4m -I/usr/include/python3.4m -o sipPyMyLabelcmodule.o sipPyMyLabelcmodule.cpp
In file included from sipPyMyLabelcmodule.cpp:7:0:
sipAPIPyMyLabel.h:12:21: fatal error: QMetaType: No such file or directory
compilation terminated.
Makefile:17: recipe for target 'sipPyMyLabelcmodule.o' failed
make[1]: *** [sipPyMyLabelcmodule.o] Error 1
make[1]: Leaving directory '/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/modules'
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 2
jazzycamel commented 7 years ago

Looks like the compiler can't find the Qt includes directory (there is no -I/path/to/Qt/include in the command). My honest answer is that I have not tested this on Linux and the configure.py script does not take any special measures for this platform (unlike Windows or Mac). If you look in configure.py from line 44 onwards you will see how extra flags/paths etc. are added if you fancy fixing this yourself (pull requests gratefully received), otherwise I will spin up a Linux environment when I have time and have a go myself.

heatblazer commented 7 years ago

I have added the -I/<path to my Qt headers/include but I still fail in the build. I was able to fix the SIP/C++ example in PyQt4 and I have to do this in PyQt5 but I'll try to figure out.

heatblazer commented 7 years ago

It would be great if you can provide a minimal example for a custom QWidget minimal, with the simplest configure.py script that just shows a hardcoded example, like the original in Riverbank, that can work in linux, I haven't been able to find anybody who is fighting this.

jazzycamel commented 7 years ago

I've updated the configure script and this example now runs successfully on Ubuntu 16.04.

heatblazer commented 7 years ago

Great news! I will report tomorrow on Fedora builds.

heatblazer commented 7 years ago

Hello, I am still getting this error on Fedora and Ubuntu:

Entering directory '/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/modules'
g++ -c -std=c++11 -pipe -fPIC -O2 -Wall -W -DNDEBUG -DMYLABEL_LIBRARY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -I/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/src -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include/QtGui -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include/QtWidgets -I/home/ilian/git-projects/prosfitdesktop/include/python3.4m -I/usr/include/python3.4m -o sipPyMyLabelcmodule.o sipPyMyLabelcmodule.cpp
In file included from sipPyMyLabelcmodule.cpp:7:0:
sipAPIPyMyLabel.h:526:8: error: ‘sipImportedTypeDef’ does not name a type
 extern sipImportedTypeDef sipImportedTypes_PyMyLabel_QtCore[];
        ^
sipAPIPyMyLabel.h:527:8: error: ‘sipImportedVirtErrorHandlerDef’ does not name a type
 extern sipImportedVirtErrorHandlerDef sipImportedVirtErrorHandlers_PyMyLabel_Qt
        ^
sipAPIPyMyLabel.h:594:8: error: ‘sipImportedTypeDef’ does not name a type
 extern sipImportedTypeDef sipImportedTypes_PyMyLabel_QtGui[];
        ^
sipAPIPyMyLabel.h:607:8: error: ‘sipImportedTypeDef’ does not name a type
 extern sipImportedTypeDef sipImportedTypes_PyMyLabel_QtWidgets[];
        ^
/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/modules/sipPyMyLabelcmodule.cpp: In function ‘void sipVH_PyMyLabel_35(sip_gilstate_t, sipVirtErrorHandlerFunc, sipSimpleWrapper*, PyObject*, const QMetaMethod&)’:
sipAPIPyMyLabel.h:340:55: error: ‘const sipAPIDef {aka const struct _sipAPIDef}’ has no member named ‘api_call_procedure_method’
 #define sipCallProcedureMethod      sipAPI_PyMyLabel->api_call_procedure_method
                                                       ^
/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/modules/sipPyMyLabelcmodule.cpp:249:5: note: in expansion of macro ‘sipCallProcedureMethod’
     sipCallProcedureMethod(sipGILState, sipErrorHandler, sipPySelf, sipMethod, 
     ^
jazzycamel commented 7 years ago

That would suggest it can't find the SIP types... How have you built/installed Qt/SIP/PyQt? This has been tested (on MacOS/Linux) by using the Qt installer and then building SIP and PyQt5 from source.

heatblazer commented 7 years ago

Tough one, I am using a virtualenv I have to check it out. What tool chain did you used when building SIP, PyQt and Qt? Something from requiremetns.txt or the official guide?

jazzycamel commented 7 years ago

I use virtualenv too, but I don't use SIP/PyQt5 wheels via pip. Is sip.h installed in either of these include directories:

/home/ilian/git-projects/prosfitdesktop/include/python3.4m
/usr/include/python3.4m
heatblazer commented 7 years ago

Yes, it's present in both directories.

jazzycamel commented 7 years ago

Hmmm... the types that being reported as missing are defined in sip.h that is imported into sipPyMyLabelcmodule.cpp via sipAPIPyMyLabel.h. The fact that sip.h is in both directories may be causing a conflict...

heatblazer commented 7 years ago

You sure that I don't have to move the C++ .so files from the Qt project (src) to /usr/lib /usr/lib64 I had to do something similar for PyQt4 example from Riverbank.

heatblazer commented 7 years ago

Here is the makefile generated by configure.py

TARGET = PyMyLabel.so
OFILES = sipPyMyLabelcmodule.o sipPyMyLabelMyLabel.o
HFILES = sipAPIPyMyLabel.h 

CC = gcc
CXX = g++
LINK = g++
CPPFLAGS = -DNDEBUG -DMYLABEL_LIBRARY -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -I/home/ilian/git-projects/pyqtlibtest/PyMyLabel-master/src -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include/QtGui -I/home/ilian/opt/Qt5.7.1/5.7/gcc_64/include/QtWidgets -I/home/ilian/git-projects/prosfitdesktop/include/python3.4m -I/usr/include/python3.4m
CFLAGS = -pipe -fPIC -O2 -Wall -W
CXXFLAGS = -pipe -fPIC -O2 -Wall -W
LFLAGS = -shared -Wl,-rpath,/home/ilian/opt/Qt5.7.1/5.7/gcc_64/lib -Wl,--version-script=PyMyLabel.exp
LIBS = -L/home/ilian/opt/Qt5.7.1/5.7/gcc_64/lib -L../src -lMyLabel
.SUFFIXES: .c .o .cpp .cc .cxx .C

.cpp.o:
    $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<

.cc.o:
    $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<

.cxx.o:
    $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<

.C.o:
    $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -o $@ $<

.c.o:
    $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

all: $(TARGET)

$(OFILES): $(HFILES)

$(TARGET): $(OFILES)
    @echo '{ global: PyInit_PyMyLabel; local: *; };' > PyMyLabel.exp
    $(LINK) $(LFLAGS) -o $(TARGET) $(OFILES) $(LIBS)

install: $(TARGET)
    @test -d $(DESTDIR)PyMyLabel || mkdir -p $(DESTDIR)PyMyLabel
    cp -f $(TARGET) $(DESTDIR)PyMyLabel/$(TARGET)
    strip $(DESTDIR)PyMyLabel/$(TARGET)

clean:
    -rm -f $(TARGET)
    -rm -f sipPyMyLabelcmodule.o
    -rm -f sipPyMyLabelMyLabel.o
    -rm -f PyMyLabel.exp
jazzycamel commented 7 years ago

No need to move .so files yet, you're still compiling not linking.

jazzycamel commented 7 years ago

Makefile looks good. I really think the issue is here is with the configuration/location (and possible duplication) of dependencies.

jazzycamel commented 7 years ago

I just spun up a Fedora VM and everything worked fine:

Additionally I had to install some dependencies before installing PyQt5:

sudo dnf install libGL-devel mesa-libGL-devel python3-devel
heatblazer commented 7 years ago

Just to ask, how did you install PyQt and SIP?

jazzycamel commented 7 years ago

As described in my previous comment, I got the source tarballs from Riverbank and built them using a virtualenv.