Ich versuche, die MATLAB-Engine für C ++ in QT zu verwenden (basierend auf https://www.mathworks.com/help/matlab/m ... nment.html) und ein Problem haben. Wenn ich die Datei ändere .pro wie dieses < /p>
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Thêm đường dẫn đến file tiêu đề (header)
INCLUDEPATH += "E:/soft ware/engineering/matlab/extern/include"
# Thêm đường dẫn đến thư viện và liên kết với libmatlabengine
LIBS += -L"E:/soft ware/engineering/matlab/extern/lib/win64/mingw64" -lMatlabEngine
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
# Thêm cấu hình cho Windows (release/debug)
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/'../../soft ware/engineering/matlab/extern/lib/win64/release/' -lMatlabEngine
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/'../../soft ware/engineering/matlab/extern/lib/win64/debug/' -lMatlabEngine
else:unix: LIBS += -L$$PWD/'../../soft ware/engineering/matlab/extern/lib/win64/' -lMatlabEngine
INCLUDEPATH += $$PWD/'../../soft ware/engineering/matlab/extern/include'
DEPENDPATH += $$PWD/'../../soft ware/engineering/matlab/extern/include'
< /code>
Dann füge ich die Header -Datei in main.cpp wie dieses < /p>
hinzu#include "mainwindow.h"
#include
#include"MatlabEngine.hpp"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
< /code>
Es zeigt den Fehler wie diesen < /p>
g++ -Wl,-subsystem,windows -mthreads -o debug\untitled1.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"E:\soft ware\engineering\matlab\extern\lib\win64\mingw64" -L"E:\soft ware\engineering\matlab\extern\lib\win64\debug" -lMatlabEngine E:\software1\QT\6.8.2\mingw_64\lib\libQt6Widgets.a E:\software1\QT\6.8.2\mingw_64\lib\libQt6Gui.a E:\software1\QT\6.8.2\mingw_64\lib\libQt6Core.a -lmingw32 E:\software1\QT\6.8.2\mingw_64\lib\libQt6EntryPoint.a -lshell32
E:/software1/QT/Tools/mingw1310_64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o: in function `void (*matlab::data::detail::resolveFunction(matlab::data::detail::FunctionType))(matlab::data::detail::ReferenceImpl*)':
E:/soft ware/engineering/matlab/extern/include/MatlabDataArray/detail/ExceptionHelpers.hpp:124: undefined reference to `get_function_ptr'
E:/software1/QT/Tools/mingw1310_64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o: in function `void (*matlab::data::detail::resolveFunction(matlab::data::detail::FunctionType))(matlab::data::impl::ArrayImpl*)':
E:/soft ware/engineering/matlab/extern/include/MatlabDataArray/detail/ExceptionHelpers.hpp:124: undefined reference to `get_function_ptr'
E:/software1/QT/Tools/mingw1310_64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o: in function `int (*matlab::data::detail::resolveFunction(matlab::data::detail::FunctionType))(matlab::data::impl::ArrayImpl*, int*)':
E:/soft ware/engineering/matlab/extern/include/MatlabDataArray/detail/ExceptionHelpers.hpp:124: undefined reference to `get_function_ptr'
E:/software1/QT/Tools/mingw1310_64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o: in function `unsigned long long (*matlab::data::detail::resolveFunction(matlab::data::detail::FunctionType))(matlab::data::impl::ArrayImpl*)':
E:/soft ware/engineering/matlab/extern/include/MatlabDataArray/detail/ExceptionHelpers.hpp:124: undefined reference to `get_function_ptr'
E:/software1/QT/Tools/mingw1310_64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o: in function `bool (*matlab::data::detail::resolveFunction(matlab::data::detail::FunctionType))(matlab::data::impl::ArrayImpl*, bool, matlab::data::impl::ArrayImpl**)':
E:/soft ware/engineering/matlab/extern/include/MatlabDataArray/detail/ExceptionHelpers.hpp:124: undefined reference to `get_function_ptr'
E:/software1/QT/Tools/mingw1310_64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o:E:/soft ware/engineering/matlab/extern/include/MatlabDataArray/detail/ExceptionHelpers.hpp:124: more undefined references to `get_function_ptr' follow
< /code>
Kann mir jemand helfen, dieses Problem zu beheben? Vielen Dank für Ihre Hilfe.>
So verknüpfen Sie den Matlab -Motor in C ++ [Duplikat] ⇐ C++
-
- Similar Topics
- Replies
- Views
- Last post