From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 888AA385803E for ; Mon, 23 May 2022 21:35:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 888AA385803E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x434.google.com with SMTP id t6so23127763wra.4 for ; Mon, 23 May 2022 14:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=BdEcAYqjqFL1yuZLEkwX8yW8eoUcW9ei+NrWrVycZGY=; b=lsOxsByfNo9pEq1Eevaj4J1sHUtZsjJFTabOp3RLyF1zRCANtNDswg9xlUPI++4U+I MWi/lCgvpJ0iC3Y6wNhGcq/jpIngd7QFG0KWlufwQrVYllr/kCuIMDaYN1aMQzSil/3d AchfcburbkafaCy13C4wWI+v6ytqKX/jJnQWtkNf9G4VLoXeg3RPiQjH3+gmH37qbIWi typ57gB+Sd7x/MnF7U1kQPWz0WuxnEu5V9+ZFhEs/Zc5m0sG7QUa0ImxBMDpj6FAwr+I U8NlHZBgu4AEtEbxctNBHirkh8uCGI2NRUx9qMzaqObrNvI3XFXTLMB8eXnobVbFycFy 9HQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BdEcAYqjqFL1yuZLEkwX8yW8eoUcW9ei+NrWrVycZGY=; b=jrm1eafzj88OedLLVbRJeNz1lWjFbiEge/uxJOUJLCvZuK7h9dw5ueTudEZ8NoSHeO IYVxAQx906Qs2Fz+fgJW4Sl/Qc7SY5wVr0rWtBJD3tJs647qafUiaZIgp9DXGErCIccn w2dBI6z5CQCAAlyt8sb7WWPi1o8RcbYWkv4K4vg/uGHo1l85RWyPuAScpOKer5zwPyPz Y9Gy/9aOLqmXJb65g4m4iIp+K/xhDVSGu1A4aoDoDPExE3cOkA/p21irW+mXni9Hjumi ZgoN1lkOdFssayo0WJ/SxUg6dTKDrh7jbV59WA7K5qP7nw5xNYXb7YvgaSnN8YhezJig 1REA== X-Gm-Message-State: AOAM532N/T3/IDfob13p32D2EBYHy0NnRozQhlVgcFw3qs2GBdJkg9G6 A2ydabLscGTa3Xe4ykIbNcBmvc8cK/WwlDqwRKZx2xYdX7W7dQ== X-Google-Smtp-Source: ABdhPJwhHGKEDuS9LbpsbzPYvEgDvVqXZpY+tm3XGsFtblZQzRAIK7a00+rzhTxHWgorR0pyJRzETRSZgN4XNreoyjU= X-Received: by 2002:a05:6000:1866:b0:20f:c0d2:a25c with SMTP id d6-20020a056000186600b0020fc0d2a25cmr13591053wri.457.1653341729881; Mon, 23 May 2022 14:35:29 -0700 (PDT) MIME-Version: 1.0 From: Yclept Nemo Date: Mon, 23 May 2022 17:35:21 -0400 Message-ID: Subject: Unable to use SetDefaultDllDirectories/LOAD_LIBRARY_SEARCH_USER_DIRS To: cygwin@cygwin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2022 21:35:33 -0000 I'm trying to add a new DLL search path. I don't have any problems with 'SetDllDirectory' but I cannot use it as the directory is not permanent; a subsequent call will remove it. The function 'SetDefaultDllDirectories' offers many configuration flags, the ones I care about are: LOAD_LIBRARY_SEARCH_DEFAULT_DIRS LOAD_LIBRARY_SEARCH_SYSTEM32 LOAD_LIBRARY_SEARCH_APPLICATION_DIR LOAD_LIBRARY_SEARCH_USER_DIRS LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR If DLL_LOAD_DIR is set then cygwin DLL lookups work as usual but any directories added with 'AddDllDirectory' are ignored. If DLL_LOAD_DIR is not set, then cygwin DLLs cannot be found. To use SEARCH_USER_DIRS I must omit DLL_LOAD_DIR as well as reimplement cygwin DLL lookup by adding every directory (recursively) beneath "/usr/lib" and "/usr/bin" (using 'AddDllDirectory') as well as the directory I initially wanted to add. Which at 1687 directories is not ideal. I am testing with "_umath_linalg.cpython-38-x86_64-cygwin.dll" (from numpy) and "vtkCommonCore.cpython-38-x86_64-cygwin.dll" from VTK, both copied to a test directory. The missing VTK libraries exist in the directory I wish to add. They are python modules and the module loading process is not compatible with 'SetDllDirectory'. $ ldd _umath_linalg.cpython-38-x86_64-cygwin.dll ... cygblas-0.dll => /usr/bin/cygblas-0.dll (0x3da3a0000) cyglapack-0.dll => /usr/lib/lapack/cyglapack-0.dll (0x3b8040000) ... $ ldd vtkCommonCore.cpython-38-x86_64-cygwin.dll ... vtkCommonCore.cpython-38-x86_64-cygwin.dll => /.../test/vtkCommonCore.cpython-38-x86_64-cygwin.dll (0x522a10000) cygvtkCommonCore.dll => not found cygvtkWrappingPythonCore3.8.dll => not found cygvtksys.dll => not found ... This is my test program: #include #include #include #include #include int main(int argc, char** argv) { //SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); //SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); //SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); //SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_USER_DIRS); SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); //SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS); //SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_USER_DIRS | LOAD_LIBRARY_SEARCH_SYSTEM32); //SetDefaultDllDirectories(LOAD_WITH_ALTERED_SEARCH_PATH); // Cygwin paths do not work //AddDllDirectory(L"/bin"); //AddDllDirectory(L"/lib"); //AddDllDirectory(L"/usr/bin"); //AddDllDirectory(L"/usr/lib"); //AddDllDirectory(L"/usr/lib/lapack"); //AddDllDirectory(L"/cygdrive/c/WINDOWS"); //AddDllDirectory(L"/cygdrive/c/WINDOWS/SYSTEM32"); //AddDllDirectory(L"/cygdrive/c/Users/.../test"); //AddDllDirectory(L"/cygdrive/c/Users/.../pyvenv38/lib/python3.8/site-packages/vtkmodules"); AddDllDirectory(L"C:\\cygwin64\\bin"); AddDllDirectory(L"C:\\cygwin64\\lib"); //AddDllDirectory(L"C:\\cygwin64\\lib\\lapack"); //AddDllDirectory(L"C:\\Windows"); //AddDllDirectory(L"C:\\Windows\\System32"); //AddDllDirectory(L"C:\\Users\\...\\test"); AddDllDirectory(L"C:\\Users\\...\\pyvenv38\\lib\\python3.8\\site-packages\\vtkmodules"); //SetDllDirectoryW(L"C:\\Users\\...\\pyvenv38\\lib\\python3.8\\site-packages\\vtkmodules"); if (argc != 2) { printf("Error: one argument accepted: filepath to a DLL\n"); return 2; } if (!argv[1][0]) { printf("Error: Path must not be empty\n"); return 2; } printf("Testing dlopen with '%s'\n", argv[1]); void* sh = LoadLibraryA(argv[1]); //void* sh = LoadLibraryEx(argv[1], NULL, 0x0); //void* sh = dlopen(argv[1], RTLD_NOW); if (!sh) { char* dle = dlerror(); printf("Symbol table handle was null: %s\n", dle); return 1; } else { printf("Succeeded: not null\n"); return 0; } } Please advise. Thanks,