Linux/wine: Difference between revisions
< Linux
No edit summary |
No edit summary |
||
| Line 26: | Line 26: | ||
If you are still stuck, you can generate a cleaner log file to parse by running your app with standard Wine debugging output: | If you are still stuck, you can generate a cleaner log file to parse by running your app with standard Wine debugging output: | ||
WINEDEBUG=-all,err+all wine your_application.exe | WINEDEBUG=-all,err+all wine your_application.exe | ||
== Wine Console Test == | |||
winetest.cpp :: | |||
<pre> | |||
#include <iostream> | |||
#include <windows.h> | |||
#include <fstream> | |||
#include <string> | |||
int main() { | |||
std::cout << "========================================\n"; | |||
std::cout << " Wine Windows Console Test \n"; | |||
std::cout << "========================================\n\n"; | |||
// 1. Test Windows API Version Detection | |||
std::cout << "[1] Checking Windows API Memory Status...\n"; | |||
MEMORYSTATUSEX memInfo; | |||
memInfo.dwLength = sizeof(MEMORYSTATUSEX); | |||
if (GlobalMemoryStatusEx(&memInfo)) { | |||
std::cout << " -> Success! Total Physical Memory: " | |||
<< memInfo.ullTotalPhys / (1024 * 1024) << " MB\n\n"; | |||
} else { | |||
std::cout << " -> Failed to retrieve memory status.\n\n"; | |||
} | |||
// 2. Test Environment Variables | |||
std::cout << "[2] Checking Environment Variables...\n"; | |||
char username[256]; | |||
DWORD username_len = sizeof(username); | |||
if (GetUserNameA(username, &username_len)) { | |||
std::cout << " -> Current User: " << username << "\n\n"; | |||
} else { | |||
std::cout << " -> Failed to get username.\n\n"; | |||
} | |||
// 3. Test File System Write/Read under Wine | |||
std::cout << "[3] Testing File System I/O...\n"; | |||
std::string testFilename = "wine_test_file.txt"; | |||
std::ofstream outFile(testFilename); | |||
if (outFile.is_open()) { | |||
outFile << "Wine compatibility test successful!"; | |||
outFile.close(); | |||
std::cout << " -> Successfully wrote to " << testFilename << "\n"; | |||
std::ifstream inFile(testFilename); | |||
std::string fileContent; | |||
if (std::getline(inFile, fileContent)) { | |||
std::cout << " -> Successfully read: \"" << fileContent << "\"\n"; | |||
} | |||
inFile.close(); | |||
// Clean up | |||
DeleteFileA(testFilename.c_str()); | |||
} else { | |||
std::cout << " -> Failed file I/O test.\n"; | |||
} | |||
std::cout << "\n"; | |||
// 4. Test Registry Read (Optional but good for Wine) | |||
std::cout << "[4] Testing Registry Access (HKLM)...\n"; | |||
HKEY hKey; | |||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { | |||
char prodName[256]; | |||
DWORD bufferSize = sizeof(prodName); | |||
if (RegQueryValueExA(hKey, "ProductName", NULL, NULL, (LPBYTE)prodName, &bufferSize) == ERROR_SUCCESS) { | |||
std::cout << " -> Reported OS: " << prodName << "\n\n"; | |||
} else { | |||
std::cout << " -> Opened key, but failed to read ProductName.\n\n"; | |||
} | |||
RegCloseKey(hKey); | |||
} else { | |||
std::cout << " -> Failed to open registry key.\n\n"; | |||
} | |||
std::cout << "Tests completed. Press ENTER to exit."; | |||
std::cin.get(); | |||
return 0; | |||
} | |||
</pre> | |||
On Linux cross compile with: | |||
x86_64-w64-mingw32-g++ -o winetest.exe winetest.cpp -static | |||
# apt install g++-mingw-w64-x86-64-posix # version 13.2.0-6ubuntu1+26.1, or | |||
# apt install g++-mingw-w64-x86-64-win32 # version 13.2.0-6ubuntu1+26.1 | |||
On Windows compile with: | |||
cl /EHsc winetest.cpp | |||
Rune in wine: | |||
wine winetest.exe | |||
xvfb-run -a wine winetest.exe | |||
== keywords == | == keywords == | ||
Revision as of 05:41, 25 September 2026
Wine
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install --install-recommends winehq-staging
<pre>
Rebuild Wine Prefix (~/.wine)
wineboot -u
Test new wine prefix:
WINEPREFIX=~/my_new_prefix wine your_executable.exe
Test wine with executable:
xvfb-run -a wine your_executable.exe
Reconfig your wine prfix:
rm -rf .wine
winecfg
# or if headless...
xvfg-run wincfg
== Debug Wine ==
If you are still stuck, you can generate a cleaner log file to parse by running your app with standard Wine debugging output:
WINEDEBUG=-all,err+all wine your_application.exe
== Wine Console Test ==
winetest.cpp ::
<pre>
#include <iostream>
#include <windows.h>
#include <fstream>
#include <string>
int main() {
std::cout << "========================================\n";
std::cout << " Wine Windows Console Test \n";
std::cout << "========================================\n\n";
// 1. Test Windows API Version Detection
std::cout << "[1] Checking Windows API Memory Status...\n";
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
if (GlobalMemoryStatusEx(&memInfo)) {
std::cout << " -> Success! Total Physical Memory: "
<< memInfo.ullTotalPhys / (1024 * 1024) << " MB\n\n";
} else {
std::cout << " -> Failed to retrieve memory status.\n\n";
}
// 2. Test Environment Variables
std::cout << "[2] Checking Environment Variables...\n";
char username[256];
DWORD username_len = sizeof(username);
if (GetUserNameA(username, &username_len)) {
std::cout << " -> Current User: " << username << "\n\n";
} else {
std::cout << " -> Failed to get username.\n\n";
}
// 3. Test File System Write/Read under Wine
std::cout << "[3] Testing File System I/O...\n";
std::string testFilename = "wine_test_file.txt";
std::ofstream outFile(testFilename);
if (outFile.is_open()) {
outFile << "Wine compatibility test successful!";
outFile.close();
std::cout << " -> Successfully wrote to " << testFilename << "\n";
std::ifstream inFile(testFilename);
std::string fileContent;
if (std::getline(inFile, fileContent)) {
std::cout << " -> Successfully read: \"" << fileContent << "\"\n";
}
inFile.close();
// Clean up
DeleteFileA(testFilename.c_str());
} else {
std::cout << " -> Failed file I/O test.\n";
}
std::cout << "\n";
// 4. Test Registry Read (Optional but good for Wine)
std::cout << "[4] Testing Registry Access (HKLM)...\n";
HKEY hKey;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
char prodName[256];
DWORD bufferSize = sizeof(prodName);
if (RegQueryValueExA(hKey, "ProductName", NULL, NULL, (LPBYTE)prodName, &bufferSize) == ERROR_SUCCESS) {
std::cout << " -> Reported OS: " << prodName << "\n\n";
} else {
std::cout << " -> Opened key, but failed to read ProductName.\n\n";
}
RegCloseKey(hKey);
} else {
std::cout << " -> Failed to open registry key.\n\n";
}
std::cout << "Tests completed. Press ENTER to exit.";
std::cin.get();
return 0;
}
On Linux cross compile with:
x86_64-w64-mingw32-g++ -o winetest.exe winetest.cpp -static
# apt install g++-mingw-w64-x86-64-posix # version 13.2.0-6ubuntu1+26.1, or # apt install g++-mingw-w64-x86-64-win32 # version 13.2.0-6ubuntu1+26.1
On Windows compile with:
cl /EHsc winetest.cpp
Rune in wine:
wine winetest.exe xvfb-run -a wine winetest.exe