im试图使用msvc2017从github编译essnac-ng库,以在已经存在的qt-Project中使用。
我设法使用msys2(带有make,autoconf,automake,yacc,bison)和powershell对其进行了编译:
cmd.exe /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 `& powershell
cd D:\Projekte\esnacc-ng
bash ./boot.sh
bash ./configure LD=linker.exe
make
make install
问题1:在make期间,仅使用以下警告编译静态库:
warning: undefined symbols not allowed in x86_64-pc-msys shared libraries; building static only
尝试此线程在这里说了什么之后: libtool: undefined symbols not allowed in i686-pc-mingw32 shared 在制作过程中出现错误:
cl : Befehlszeile error D8021 : Ungültiges numerisches Argument /Wl,-DLL,-IMPLIB:cxx-lib/.libs/cxxasn1.dll.lib.
make[1]: *** [Makefile:1641: cxx-lib/libcxxasn1.la] Error 2
make[1]: Leaving directory '/d/Projekte/esnacc-ng'
make: *** [Makefile:1370: all] Error 2
PS D:\Projekte\esnacc-ng>
问题2: 尝试在pri文件中使用这样的静态库:
LIBS += -L$$PWD/cxx-lib/libs/ -lcxxasn1
LIBS += -L$$PWD/cxx-lib/libs/ -lcxxasn1rose
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/cxx-lib/inc
HEADERS += $$PWD/MyAsnFile.h
SOURCES += $$PWD/MyAsnFile.cpp
QMAKE_CFLAGS_MT+=$$PWD/cxx-lib/inc
QMAKE_CXXFLAGS_MT+=$$PWD/cxx-lib/inc
#QMAKE_CFLAGS_RELEASE += /MD
DISTFILES += \
$$PWD/cxx-lib/inc/snacc.h.in
编译时出现错误:
Fehler: LNK2038: Konflikt ermittelt für "RuntimeLibrary": Der Wert "MT_StaticRelease" stimmt nicht mit dem Wert "MD_DynamicRelease" in main.obj überein.
我在这里看到了这个线程,但是不确定如何将其转换为对自己有用的东西: LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj
答案 0 :(得分:0)
我设法解决了这个问题: 我从项目的源代码中删除了 stdafx.h 和 stdafx.cpp ,并删除了包含该行的行(对于esnacc来说是snacdll.cpp)
我编译了静态库,其配置如下:
bash ./configure LD=linker.exe CFLAGS=-MD CXXFLAGS=-MD --build=i686-pc-msys --host=i686-pc-msys
并将库cxxasn1.lib和cxxasn1rose.lib添加到我的qtproject中 但是我仍然会收到链接器错误:LNK2001错误
error lnk2001 unresolved external symbol __imp__closesocket
所以我链接到Ws2_32.lib库:
LIBS += -L$$PWD/cxx-lib/libs/ -lcxxasn1
LIBS += -L$$PWD/cxx-lib/libs/ -lcxxasn1rose
LIBS += -lws2_32
INCLUDEPATH += $$PWD
INCLUDEPATH += $$PWD/cxx-lib/inc
HEADERS += $$PWD/CoopIts.h
SOURCES += $$PWD/CoopIts.cpp
QMAKE_CFLAGS_MT+=$$PWD/cxx-lib/inc
QMAKE_CXXFLAGS_MT+=$$PWD/cxx-lib/inc