Using 3rd party dll with defined global variables
-
wrote on 12 Jun 2018, 16:05 last edited by sykac 6 Dec 2018, 16:16
The .dlls are 3rd party, I just downloaded them and have no idea what compiler made them, so it could be the problem. If it is so, do I even have some chance to compile it?
About the headers:
My app is cpp. The problem headers (which are 3rd party and so not made by myself) are for c files and there is this in the headers:ifdef __cplusplus extern "C" { endif extern const int A; #ifdef __cplusplus } // extern "C" static const int B = A; endif
And my .pro file. There are both the .lib and .dll in x64/lib. I copied the .dlls also to the build directory.
TEMPLATE = app TARGET = test_xsens INCLUDEPATH += . CONFIG += console DEFINES += QT_DEPRECATED_WARNINGS DEFINES += XSENS_RELEASE DEFINES += XSTYPES_STATIC_LIB LIBS += -L$$PWD/x64/lib/ -lxstypes64 LIBS += -L$$PWD/x64/lib/ -lxsensdeviceapi64 INCLUDEPATH += $$PWD/include INCLUDEPATH += $$PWD/include/xsens INCLUDEPATH += $$PWD/include/xcommunication HEADERS += ..... SOURCES += .....
-
Hi
Are you using visual studio compiler ? -
wrote on 13 Jun 2018, 06:02 last edited by
Yes, I'm using msvc.
-
@sykac
Where you download the library from.
Dont it mention what compilers are supported ? -
wrote on 13 Jun 2018, 08:09 last edited by
@mrjj
I downloaded it from the official web pages of the hardware the library is for. I checked everywhere and didn't find anything about supported compilers.But I just found that there are the problem causing .c files in the library so I compilled them and used the rest of the library from the .dlls. It seems to be working, but I'm facing some runtime heap problems with some methods from the library. I don't know if it is connected to these linking and library problem which this question is about. I need to examine it a little bit more.
-
@mrjj
I downloaded it from the official web pages of the hardware the library is for. I checked everywhere and didn't find anything about supported compilers.But I just found that there are the problem causing .c files in the library so I compilled them and used the rest of the library from the .dlls. It seems to be working, but I'm facing some runtime heap problems with some methods from the library. I don't know if it is connected to these linking and library problem which this question is about. I need to examine it a little bit more.
@sykac
Hi
It does sound like a c type library which can be used from
other compilers since no object/class types need be resolved.Im not sure if you mixing would cause heap issues but make sure not mixing
debug and release modes as that might fool it.Do you have all code for the DLLs ?
-
wrote on 13 Jun 2018, 10:00 last edited by
No, that's the problem. I have only some files, the rest is only in the dlls. And the class ending with heap corruption is not from the files I have source code of, it's just in a dll so I cannot check what's happening there.
-
@mrjj
And what do you mean by mixing debug and release modes? (I'm using just the Debug mode in qtcreator)@sykac Is this lib build in debug or release mode?
Usually it is not a good idea to mix binaries build in debug and release mode. -
@jsulm
That was it. I built my app in release mode and now it works fine :-) Thank you very much.wrote on 13 Jun 2018, 12:49 last edited by@sykac if your issue is solved, please don't forget to mark your post as such. Thanks.
13/14