PostgreSQL La base de donnees la plus sophistiquee au monde.

Forums PostgreSQL.fr

Le forum officiel de la communauté francophone de PostgreSQL

Vous n'êtes pas identifié(e).

#1 15/01/2015 13:26:42

LIBPQ.DLL version 64 bits

Bonjour (et bonne année 2015)
Environnement  : Windows : 64 bits

- J'ai téléchargé postgresql-9.4.0-1-windows-binaries.zip et postgresql-9.4.0-1-windows-x64-binaries.zip pour avoir
libpq.dll et libintl.dll (32 bits)
libpq.dll et libintl-8.dll (64 bits)

- Avec dumpbin de Visual Studio 12.0 j'ai bien vérifié que j'avais bien des versions 32 bits et 64 bits

- Avec Windev version 18

1° je compile mon application pour du 32bits : tout fonctionne à 100%

2° je compile mon application pour du 64 bits : Impossible de charger la dll libpq.dll
                                        Message d'erreur : "libpq.dll n'est pas une application Win32 valide"

Si je test avec la fonction : LoadLibraryA au lieu d'utiliser la fonction LoadDll() de Windev :

DLLName1 est une chaîne = PathOfDll + "libintl-8.dll"
handleDLL1 est un entier système = API("Kernel32.dll", "LoadLibraryA", &DLLName1)               // ---> handleDLL <> 0 c'est OK

DLLName2 est une chaîne = PathOfDll + "libpq.dll"
handleDLL2 est un entier système = API("Kernel32.dll", "LoadLibraryA", &DLLName2)               // ---> handleDLL = 0    c'est bad

J'avoue que je sèche lamentablement...

Hors ligne

#2 15/01/2015 18:52:31

Re : LIBPQ.DLL version 64 bits

Test fait en VB avec Visual Studio 12 :

Module Module1
    Private Declare Function LoadLibraryA Lib "kernel32" Alias "LoadLibraryA" (ByVal lpFileName As String) As Long

    Sub Main()
        Dim hnd As Long
        Dim DllName As String

        DllName = "D:\Mes Projets\LIBPQ\Exe\Exécutable Windows 64 bits\EnCours-libpq64\libintl-8.dll"
        hnd = LoadLibraryA(DllName)
        MsgBox(hnd, MsgBoxStyle.Information, "libintl-8.dll")

        DllName = "D:\Mes Projets\LIBPQ\Exe\Exécutable Windows 64 bits\EnCours-libpq64\libpq.dll"
        hnd = LoadLibraryA(DllName)
        MsgBox(hnd, MsgBoxStyle.Information, "libpq.dll")

    End Sub
End Module

------ Début de la génération : Projet : ConsoleApplication2, Configuration : Debug x64 ------
  ConsoleApplication2 -> D:\VS2013\ConsoleApplication2\ConsoleApplication2\bin\x64\Debug\ConsoleApplication2.exe
========== Génération : 1 a réussi, 0 a échoué, 0 mis à jour, 0 a été ignoré ==========

libintl-8.dll renvoi hnd <> 0
libpq.dll     renvoi hnd =  0

le problème ne semble pas lié à Windev

Hors ligne

#3 16/01/2015 13:17:08

Re : LIBPQ.DLL version 64 bits

Test fait en VC avec Visual Studio 12 :
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <conio.h>

int _tmain(int argc, _TCHAR* argv[])
{
    HINSTANCE hinstLib;
    DWORD nErrorCode;
    CHAR* msg;

    //LPCSTR DllName = "D:\\Mes Projets\\LIBPQ\\Exe\\Exécutable Windows 64 bits\\EnCours-libpq64\\libintl-8.dll";
    LPCSTR DllName = "D:\\Mes Projets\\LIBPQ\\Exe\\Exécutable Windows 64 bits\\EnCours-libpq64\\libpq.dll";
    hinstLib = LoadLibraryA(DllName);

    if (hinstLib == NULL)
    {
        nErrorCode = GetLastError();
        FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                       NULL,
                       nErrorCode,
                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                       (LPSTR)&msg,
                       0,
                       NULL);
        printf("Erreur : %d\n%s\n", nErrorCode, msg);            // nErrorCode = 193
    }
    else
    {
        FreeLibrary(hinstLib);
        printf("%s\n", "Ok");
    }
    return 0;
}
1>------ Début de la génération : Projet : ConsoleApplication4, Configuration : Debug x64 ------
1>  ConsoleApplication4.cpp
1>  ConsoleApplication4.vcxproj -> D:\VS2013\ConsoleApplication4\x64\Debug\ConsoleApplication4.exe
========== Génération : 1 a réussi, 0 a échoué, 0 mis à jour, 0 a été ignoré ==========
pour libintl-8.dll -> ok
pour libpq.dll -> Erreur : 193
                        %1 n'est pas une application Win32 valide. (message identique !)

Sauf erreur de ma part, le problème me semble de moins en moins lié au langage mais plus à libpq.dll version 64 bits.

Hors ligne

#4 17/01/2015 13:52:23

Re : LIBPQ.DLL version 64 bits

Problème résolu.
Mon pc ayant plusieurs versions en 32 et 64 plus divers programmes utilisant chacun libpq, je pense qu'il se mélangeait les pinceaux...
Avec "Dependency walker for Win64" j'ai regardé la liste des dll que libpq.dll utilisait et j'ai testé les différentes combinaisons et voici l'ordre de chargement qui fonctionne
1° libeay32.dll
2° libintl-8.dll
3° ssleay32.dll
4° libpq.dll"

Hors ligne

Pied de page des forums