I'm porting a big C++ project from Linux to Windows. The project consists of several libraries as well as a battery of unit tests.
Being inexperienced with development for Windows I had a lot of trouble figuring out how to do all the __declspec(dllimport)
and __declspec(dllexport)
stuff to properly make all the symbols from my shared library visible. As such, I decided to temporarily make all my libraries static while working through the compilation errors I encountered when compiling in windows.
Once everything was working and all unit tests where passing I changed my CMake setup to again compile the libraries into DLL's instead of static libraries. Now everything builds, but when I run my unit tests again a few are failing with errors like:
Exception thrown at 0x00007FFA7CAB754B (MyLibrary.dll) in MyTest_gTest.exe: 0xC0000005: Access violation reading location 0x000001153D6C9000.
Summary & Question: When my test is linked against the dll version of my library it fails with an access violation, but when it is linked against the static version of my library it passes. The code for both test and library are 100% identical in both cases. What could explain this? Could it be related to improper use of dllimport/dllexport? (As I said, I'm inexperienced with development for windows)
User contributions licensed under CC BY-SA 3.0