I am trying to include MuParser in my Qt Creator project, but I have been struggling for quite a while to get it working properly.
Where I am now, it appears to be unable to find several symbols in the MuParser library for whatever reason, and I am not really sure what to do about this. Does anyone have any idea what I might want to do to resolve this?
I downloaded the source code as a .zip file from the official website. After extracting the contents, I added a “build” directory to the folder. In MSYS2 MINGW64, I ran
cd (path to muparser folder)/build
cmake .. -DENABLE_SAMPLES=ON -DENABLE_OPENMP=ON -DENABLE_WIDE_CHAR=OFF -DBUILD_SHARED_LIBS=OFF
make
from the build directory. This produced the static library “libmuparser.a”.
I added this file, along with the headers, into my project folder in the following file structure:
(Project File)->libs->muparser->lib->libmuparser.a
(Project File)->libs->muparser->include->(MuParser Header Files)
Then, in my .pro file, I added
INCLUDEPATH += $$PWD/libs/muparser/include
LIBS += -L$$PWD/libs/muparser/lib -lmuparser
However, when I attempt to build the project, I get the following error messages:
collect2.exe:-1: error: ld returned 1 exit status
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o: in function `qMain(int, char**)':
C:/Qt/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: debug/main.o: in function `mu::Parser::~Parser()':
collect2.exe: error: ld returned 1 exit status
C:UsersAidan BeecherDesktopQt ProjectsTestMuParsermain.cpp:16: error: undefined reference to `__imp__ZN2mu6ParserC1Ev'
:-1: error: C:UsersAidan BeecherDesktopQt ProjectsTestMuParserbuildDesktop_Qt_6_7_2_MinGW_64_bit-Debug/../../main.cpp:17: undefined reference to `__imp__ZN2mu10ParserBase9DefineVarERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEEPd'
:-1: error: C:UsersAidan BeecherDesktopQt ProjectsTestMuParserbuildDesktop_Qt_6_7_2_MinGW_64_bit-Debug/../../main.cpp:18: undefined reference to `__imp__ZN2mu10ParserBase7SetExprERKNSt7__cxx1112basic_stringIwSt11char_traitsIwESaIwEEE'
:-1: error: C:UsersAidan BeecherDesktopQt ProjectsTestMuParserbuildDesktop_Qt_6_7_2_MinGW_64_bit-Debug/../../main.cpp:20: undefined reference to `__imp__ZNK2mu10ParserBase4EvalEv'
C:UsersAidan BeecherDesktopQt ProjectsTestMuParserlibsmuparserincludemuParser.h:50: error: undefined reference to `__imp__ZTVN2mu6ParserE'
:-1: error: C:UsersAidan BeecherDesktopQt ProjectsTestMuParserbuildDesktop_Qt_6_7_2_MinGW_64_bit-Debug/../../libs/muparser/include/muParser.h:50: undefined reference to `__imp__ZN2mu10ParserBaseD2Ev'
:-1: error: [Makefile.Debug:72: debug/TestMuParser.exe] Error 1
Error while buildingdeploying project TestMuParser (kit:-1: Desktop Qt 6.7.2 MinGW 64-bit)
As stated before, it appears unable to locate several MuParser library symbols, for whatever reason, though I have not edited any of the header files from how they were downloaded. Could this be an issue with the build of libmuparser.a?
EDIT: It was suggested to remove the previous update with my additional errors and locate the linkage command that caused my initial errors. While I am not seeing any command with the exact form of /some/path/x86_64-w64-mingw32-g++ -o debug/TestMuParser.exe...
, I do see some similar looking lines. Are any of these the linker command? Particularly, the first line of the fourth box below looks as though it may be the linker command.
C:/Qt/Tools/mingw1120_64/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/Aidan Beecher/Desktop/Qt
Projects/TestMuParser/build/Desktop_Qt_6_7_2_MinGW_64_bit-Debug'
g++ -c -fno-keep-inline-dllexport -g -std=gnu++1z -Wall -Wextra -Wextra -fexceptions -mthreads -
DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_QML_DEBUG -DQT_WIDGETS_LIB -
DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I../../../TestMuParser -I. -
I../../libs/muparser/include -IC:/Qt/6.7.2/mingw_64/include -
IC:/Qt/6.7.2/mingw_64/include/QtWidgets -IC:/Qt/6.7.2/mingw_64/include/QtGui -
IC:/Qt/6.7.2/mingw_64/include/QtCore -Idebug -I. -IC:/VulkanSDK/1.3.290.0/include -
IC:/Qt/6.7.2/mingw_64/mkspecs/win32-g++ -o debugmain.o ....main.cpp
g++ -Wl,-v -Wl,-subsystem,windows -mthreads -o debugTestMuParser.exe debug/main.o
debug/mainwindow.o debug/moc_mainwindow.o -L"C:UsersAidan BeecherDesktopQt
ProjectsTestMuParserlibsmuparserlib" -lmuparser C:Qt6.7.2mingw_64liblibQt6Widgets.a
C:Qt6.7.2mingw_64liblibQt6Gui.a C:Qt6.7.2mingw_64liblibQt6Core.a -lmingw32
C:Qt6.7.2mingw_64liblibQt6EntryPoint.a -lshell32
Aidan Beecher is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.