EgoRusMarch
@EgoRusMarch
C++ Developer

Как собрать библиотеку .lib [muParser]?

Мне нужно подключить библиотеку muParser (GitHub) к проекту Qt Creator.
В файле Install.txt читаю:
1. Installation on win32
========================
muParser supports various win32 command-line compilers:
    -> mingw
    -> watcom
    -> microsoft CL
and provides also the project files for MSVC6 IDE.

In order to compile muParser from makefiles, open an MSDOS prompt and
then move to the muParser/build directory and type:
    mingw32-make -fmakefile.mingw    for mingw
    nmake -fmakefile.vc              for msvc
    make -fmakefile.bcc              for borland
    wmake -fmakefile.wat             for watcom

All makefiles supports the following options:
    # Set to 1 to build debug version [0,1]
    #   0 - Release
    #   1 - Debug
    DEBUG = 0
    # Set to 1 to build shared (DLL) version [0,1]
    #   0 - Static
    #   1 - DLL
    SHARED = 0
    # Set to 1 to compile samples [0,1]
    SAMPLES = 1

The muParser library is created in the 'lib' folder and the sample binaries are
created in samples\example1 or samples\example2.

  • у меня установлен компилятор MinGW
  • добавлен в переменную среды PATH
  • я захожу в CMD
  • перемещаюсь в каталог .../muparser/build
  • пишу mingw32-make -fmakefile.mingw
  • и получаю:
    mingw32-make: makefile.mingw: No such or directory
    mingw32-make: *** No rule to make target 'makefile.mingw'. Stop.


Подскажите, пожалуйста, что я не так делаю? Как исправить?
Также я не понял, где и как мне нужно указывать параметры DEBUG, SHARED и SAMPLES?

UPD: Да, так как библиотека собрана на системе сборки CMake, то проект Qt я тоже создал на этой системе.
  • Вопрос задан
  • 477 просмотров
Решения вопроса 2
vt4a2h
@vt4a2h Куратор тега C++
Senior software engineer (C++/Qt/boost)
Так там же CMakeLists.txt в корне есть. Что-то вроде "mkdir build && cd build && cmake .. && make" (виндовый аналог этого) не работает?
Ответ написан
Комментировать
@Mercury13
Программист на «си с крестами» и не только
Ну, раз уж решил пойти третьим путём (Как подкючить библиотеку [muParser] к Qt? ) — лови проект.

Как вы видите, в большинстве случаев проект библиотеки строится тривиально: ищем, что надо включить в DEFINES, и затыкаем предупреждения.
CONFIG -= qt

TEMPLATE = lib
CONFIG += staticlib

CONFIG += c++11

# 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). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS MUPARSER_STATIC

QMAKE_CXXFLAGS += -Wno-deprecated-copy -Wno-cast-function-type

# 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 += \
    src/muParser.cpp \
    src/muParserBase.cpp \
    src/muParserBytecode.cpp \
    src/muParserCallback.cpp \
    src/muParserError.cpp \
    src/muParserInt.cpp \
    src/muParserTest.cpp \
    src/muParserTokenReader.cpp

HEADERS +=

INCLUDEPATH += include


(ВНИМАНИЕ! Я использую новейший MinGW из MSYS, он на две версии новее, и, возможно, некоторые из предупреждений, которые я заглушил, не нужны.)

В программе придётся указать
DEFINES += MUPARSER_STATIC

INCLUDEPATH += ../MuParser/include

LIBS += -L$$PWD -lmuparser


Если что, в MSYS тоже есть MuParser, хотя он у меня не установлен.
pacboy sync muparser:i muparser:x
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
Nipheris
@Nipheris Куратор тега C++
Почему бы не посмотреть CI скрипты, например для AppVeyor?
Версия с мастер-бранча :
version: 1.0.{build}
os: Visual Studio 2015
clone_folder: C:\projects\muParser
test: off
branches:
  only:
    - master
environment:
  matrix:
    - CMAKE_PLATFORM: Visual Studio 14 2015
build_script:
  - cmake -LAH -G "%CMAKE_PLATFORM%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install" .
  - cmake --build . --config Release --target install
  - ctest -C Release --output-on-failure

Мне кажется вызовы cmake в конце (кроме ctest) будут вам полезны. Да, вместо CMAKE_PLATFORM можно указать другой генератор, например MinGW Makefiles.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы