Aharoni-Lab / Miniscope-DAQ-QT-Software

Software for streaming and controlling neural and behavioral data from freely behaving animals
GNU General Public License v3.0
119 stars 29 forks source link

Embedded python issues #44

Closed jonsy11 closed 3 years ago

jonsy11 commented 3 years ago

Hello all,

I would like to modify the QT software, but I've been struggling to build it due to issues with the files with embedded python. I switched all the directories in the .pro file to my own, shown below, and I don't get any errors that the header cannot be found, but none of the python included function references are said to be defined. I know in 3.8 that I have to specify to GCC that I want to use the embedded config of python, but that doesn't seem to be a thing in 3.7. Any ideas on what's happening?

Below is my project file:

Thanks, Ian

QT += qml quick widgets
CONFIG += c++11

QT += 3dcore

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Refer to the documentation for the
# deprecated API to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

#DEFINES += DEBUG
#DEFINES += USE_USB
DEFINES += USE_PYTHON

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        backend.cpp \
        behaviorcam.cpp \
        behaviortracker.cpp \
        behaviortrackerworker.cpp \
        controlpanel.cpp \
        datasaver.cpp \
        main.cpp \
        miniscope.cpp \
        newquickview.cpp \
        tracedisplay.cpp \
        videodevice.cpp \
        videodisplay.cpp \
        videostreamocv.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =

# Add Icon
RC_ICONS = miniscope_icon.ico

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

HEADERS += \
    backend.h \
    behaviorcam.h \
    behaviortracker.h \
    behaviortrackerworker.h \
    controlpanel.h \
    datasaver.h \
    miniscope.h \
    newquickview.h \
    tracedisplay.h \
    videodevice.h \
    videodisplay.h \
    videostreamocv.h

DISTFILES += \
    ../Python/DLCwrapper.py \
    ../Scripts/DLCwrapper.py \
    ../deviceConfigs/behaviorCams.json \
    ../deviceConfigs/miniscopes.json \
    ../deviceConfigs/userConfigProps.json \
    ../deviceConfigs/videoDevices.json

win32 {
    # Path to your openCV .lib file(s) TODO
    #LIBS += -LC:/opencv-4.4.0/build/lib/Release -lopencv_world440
    LIBS += -LC:/opencv/build/x64/vc15/lib -lopencv_world453

#    LIBS += -LC:/opencv-4.4.0/build/lib/Debug -lopencv_world440d

    # Path to openCV header files TODO
    INCLUDEPATH += C:/opencv/build/include

    # Do we need DEPENDPATH ????
#    #DEPENDPATH +=

    # For libusb
#    LIBS += -LC:/libusb-1.0.24/VS2017/MS64/dll/ -llibusb-1.0
#    INCLUDEPATH += C:/libusb-1.0.24/include/libusb-1.0

#    LIBS += -LC:/libusb-1.0.23/MS64/dll/ -llibusb-1.0
#    INCLUDEPATH += C:/libusb-1.0.23/include/libusb-1.0

    # For Python TODO
    INCLUDEPATH += C:/Users/ianjones/Anaconda3/envs/py3.7/include
#    LIBS += -LC:/Python38/libs -lpython38 TODO possibly done

    #INCLUDEPATH += C:/Users/dbaha/.conda/envs/basepy37/include
    # LIBS += -LC:/Users/dbaha/.conda/envs/basepy37/libs -lpython37 TODO
    LIBS += -LC:/Users/ianjones/Anaconda3/envs/py3.7/libs -lpython37

    # For numpy TODO
    #INCLUDEPATH += C:/Users/dbaha/.conda/envs/basepy37/Lib/site-packages/numpy/core/include
    INCLUDEPATH += C:/Users/ianjones/Anaconda3/envs/py3.7/Lib/site-packages/numpy/core/include

} else {
    CONFIG += link_pkgconfig
    PKGCONFIG += opencv4
}

# Move user and device configs to build directory
copydata.commands = $(COPY_DIR) \"$$shell_path($$PWD\\..\\deviceConfigs)\" \"$$shell_path($$OUT_PWD\\release\\deviceConfigs)\"
copydata2.commands = $(COPY_DIR) \"$$shell_path($$PWD\\..\\userConfigs)\" \"$$shell_path($$OUT_PWD\\release\\userConfigs)\"
copydata3.commands = $(COPY_DIR) \"$$shell_path($$PWD\\..\\Scripts)\" \"$$shell_path($$OUT_PWD\\release\\Scripts)\"
first.depends = $(first) copydata copydata2 copydata3
export(first.depends)
export(copydata.commands)
export(copydata2.commands)
export(copydata3.commands)

QMAKE_EXTRA_TARGETS += first copydata copydata2 copydata3
daharoni commented 3 years ago

Unfortunately I am no expert when it comes to compiling with embedded QT (I was a bit surprised I was able to get it to work myself in the first place). Have you placed the python dll in the folder containing the compiled software?

jonsy11 commented 3 years ago

I tried that this morning and was met with no changes. After more digging, I came to wonder if I was just using a different compiler than you. I switched to mingw 64 bit from 32 bit and it worked. Thanks for the suggestions. Now I'm off to go build opencv and pray that everything compiles after!