Search code examples
cpostgresqlvisual-studio-2019libpqlibssl

Error when executing C program using PostGreSQL libpq in Windows 10. (libssl-1_1-x64.dll and non-existent Avast antivirus)


I have a C program (compiled and built in VisualStudio 2019), which I want to connect to a PostGreSQL DB. I included the libpq header files, put the DLLs in the right place, etc. Compilation and build operations finish with no errors. However, when I try to execute this function, I got an error.

int pgTest() {

    int libpq_ver = PQlibVersion();

    printf("%i\n", libpq_ver);
    return EXIT_SUCCESS;
}

In debugging mode, I can see this error in the debugging console:

C:\Users\JohnDoe\Documents\foo.exe (process 21388) exited with code -1072365566.
Activation context generation failed for "C:\WINDOWS\SYSTEM32\libssl-1_1-x64.dll". Dependent Assembly 

I have also checked out the EventViewer and surprisingly I found a weird error related to Avast antivirus. which I never had installed in my PC:

Activation context generation failed for "C:\WINDOWS\SYSTEM32\libssl-1_1-x64.dll". Dependent Assembly Avast.VC140.CRT,processorArchitecture="amd64",publicKeyToken="fcc99ee6193ebbca",type="win32",version="14.0.23918.0" could not be found. Please use sxstrace.exe for detailed diagnosis.

Sorry if the error looks confusing, that's why I'm asking you, because I can't imagine what libssl-1_1-x64.dll has to do with Avast, taking into account that I never had this antivirus installed, or even tried in my PC.

I'd appreciate any ideas or help.

Thanks in advance


Solution

  • It looks like a side effect of a wrong installation of OpenSSL. I re-installed OpenSSL from scratch and the error dissapeared.