0

im trying to compile essnac-ng library from github with msvc2017 to use in an already existing qt-Project.

I managed to compile it using msys2 (with make, autoconf, automake, yacc, bison) and 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

Problem 1: it is only compiling the static libraries with the following warning during make:

warning: undefined symbols not allowed in x86_64-pc-msys shared libraries; building static only

after trying what this thread here says: libtool: undefined symbols not allowed in i686-pc-mingw32 shared i get an error during make:

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>

Problem 2: Trying to use the static library like this in my pri file:

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

i get the Error during compilation:

Fehler: LNK2038: Konflikt ermittelt für "RuntimeLibrary": Der Wert "MT_StaticRelease" stimmt nicht mit dem Wert "MD_DynamicRelease" in main.obj überein.

I saw this thread here but am not sure on how to convert it into something useful for myself: LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in file.obj

momor10
  • 478
  • 3
  • 11
  • [This answer](https://stackoverflow.com/a/28887127/1023911) says what needs to be done. So what is unclear? – Werner Henze Nov 14 '18 at 09:29
  • 3
    Possible duplicate of [LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT\_StaticRelease' doesn't match value 'MD\_DynamicRelease' in file.obj](https://stackoverflow.com/questions/28887001/lnk2038-mismatch-detected-for-runtimelibrary-value-mt-staticrelease-doesn) – Werner Henze Nov 14 '18 at 09:30
  • Im not sure, i dont use any /mt /md arguments in either of the two. how do i even find out the status quo to see which one is compiled with which settings? how do i add the /mt or /md arguements when compiling esnacc? – momor10 Nov 14 '18 at 09:40
  • i tried adding CFLAGS=-MD or CXXFLAGS with the same result (with MT also) – momor10 Nov 14 '18 at 09:41

1 Answers1

0

I managed to solve it like this: i removed stdafx.h and stdafx.cpp from the source code of the project and removed the line where it was included (for esnacc it was the snacdll.cpp)

i compiled the static lib, configured like this:

bash ./configure LD=linker.exe CFLAGS=-MD CXXFLAGS=-MD --build=i686-pc-msys --host=i686-pc-msys

and added the libs cxxasn1.lib and cxxasn1rose.lib to my qtproject however i would still get Linker errors: LNK2001 Errors

error lnk2001 unresolved external symbol __imp__closesocket

so i linked against the Ws2_32.lib library:

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
momor10
  • 478
  • 3
  • 11