Why are static X11 apps failing on other machines? - x11

I built X11R5 libs statically on a 32-bit Fedora Core 9 machine. Then I built an app which uses X11 and linked it statically. So far, so good. ldd reports it's a statically-linked app. I can run it locally just fine. But when I copy it over to a 64-bit FC9 machine, it fails as follows:
assistant.static: xcb_io.c:228: _XSend: Assertion `!dpy->xcb->request_extra' failed.
Aborted
When I run strace, it seems to be trying to open libXfixes.so:
...
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libXfixes.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes.so", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447) = 0
open("libXfixes", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 8
fstat64(0x8, 0xff86a9e8) = 0
mmap2(NULL, 123447, PROT_READ, MAP_PRIVATE, 8, 0) = 0xfffffffff7bf9000
close(8) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libXfixes", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447) = 0
open("libXfixes.so.4", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 8
fstat64(0x8, 0xff86a9e8) = 0
mmap2(NULL, 123447, PROT_READ, MAP_PRIVATE, 8, 0) = 0xfffffffff7bf9000
close(8) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libXfixes.so.4", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes.so.4", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447) = 0
open("libXfixes", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 8
fstat64(0x8, 0xff86a9e8) = 0
mmap2(NULL, 123447, PROT_READ, MAP_PRIVATE, 8, 0) = 0xfffffffff7bf9000
close(8) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/libXfixes", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/libXfixes", O_RDONLY) = -1 ENOENT (No such file or directory)
munmap(0xf7bf9000, 123447) = 0
write(2, "assistant.static: xcb_io.c:228: "..., 85assistant.static: xcb_io.c:228: _XSend: Assertion `!dpy->xcb->request_extra' failed.
I don't understand why a statically-linked application would be trying to open shared X libs. Shouldn't everything needed to run the app be included via static linking (except of course for any Linux system calls the app makes, which need to be handled externally).
Thanks for any explanations!

I seem to be having the same problem and found the coolest hack around this! The problem is that it's only trying to load libXcursor.so.1, which ends up dragging libX11 & all friends in too.
My solution: edit the EXE and rename libXcursor.so.1 or libXfixes.so to libREMOVED.so or something with the same # letters. Then it will skip loading those optional extensions.

One of the libraries you use is dlopening libXfixes. This is quite popular these days. You may
Track it down, replace dlopening/dlsyming with regular function calls, and link against a static version of libXfixes.
Link your program dynamically, make sure its runtime library search path consists of your own directory, e.g. /opt/yourappname/lib, and place all your .sos in that directory. Or alternatively, if you want the users to be able to install anywhere, use a startup shell script that sets LD_LIBRARY_PATH.
The assertion failure may or may not be related to libXfixes, you may check it quickly by copying libXfixes.so to your target machine.

X11 dynamically loads libraries and it's may be loading the 64 bits libraries instead of the 32 bits version.
It's normal to load modules at runtime - like when loading plugins or drivers. And since the modules are dynamically linked to X11 itself, you're going to find yourself in a mess.
Personally, I never had luck linking X11 statically - is is really needed for you?

Related

install_name_tool: can't open input file: *.dylib for writing (Permission denied)

I can clearly see that libopenvdb.dylib file exists and I'm the owner. But install_name_tool throws this error:
install_name_tool: can't open input file: libopenvdb.dylib for writing (Permission denied)
Terminal commands:
aec#mojaves-Mac Frameworks % pwd
/Users/aec/Documents/myapp-mac/myapp.app/Contents/Frameworks
aec#mojaves-Mac Frameworks % ls -lh libopenvdb.dylib
-r--r--r-- 1 aec staff 3.7M May 1 00:03 libopenvdb.dylib
aec#mojaves-Mac Frameworks % install_name_tool -change /usr/local/opt/boost/lib/libboost_iostreams-mt.dylib #rpath/libboost_iostreams-mt.dylib libopenvdb.dylib
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't open input file: libopenvdb.dylib for writing (Permission denied)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't lseek to offset: 0 in file: libopenvdb.dylib for writing (Bad file descriptor)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't write new headers in file: libopenvdb.dylib (Bad file descriptor)
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: can't close written on input file: libopenvdb.dylib (Bad file descriptor)
aec#mojaves-Mac Frameworks %
What could be the cause? I couldn't figure out.
As commented by #Siguza seems like the problem is due to write permission. Not tested yet.
% ls -lh libopenvdb.dylib
-r--r--r-- 1 aec staff 3.7M May 1 00:03 libopenvdb.dylib
Notice -r--r--r--

No output from spice simulation via netlist with Xyce

I am trying to use Xyce for a project and am running into this issue. I am copying the DC sweep netlist example from the Xyce user guide on page 39 to notepad and saving it as test2c.cir. I then copy it over into the Xyce directory and run the Xyce terminal and run the simulate command and am unable to generate any output. Is there a step I am missing to be able to run the Diode Clipper Circuit DC Sweep file? Am I saving the cir file in the right directory? It seems that the circuit "loads properly" and the syntax is fine, but I am not getting a figure output I am expecting. I believe the issue might be that my PC doesnt have a way to open prn files, in that case, how would I fix that?
Diode Clipper Circuit
** Voltage Sources
VCC 1 0 5V
VIN 3 0 0V
* Analysis Command
.DC VIN -10 15 1
* Output
.PRINT DC V(3) V(2) V(4)
* Diodes
D1 2 1 D1N3940
D2 0 2 D1N3940
* Resistors
R1 2 3 1K
R2 1 2 3.3K
R3 2 0 3.3K
R4 4 0 5.6K
* Capacitor
C1 2 4 0.47u
.MODEL D1N3940 D(
+ IS=4E-10 RS=.105 N=1.48 TT=8E-7
+ CJO=1.95E-11 VJ=.4 M=.38 EG=1.36
+ XTI=-8 KF=0 AF=1 FC=.9
+ BV=600 IBV=1E-4)
.END
And this is the directory...
UPDATE:
I changed the Analysis Command to save files as different formats (csv, raw, dat) and it still gives me the same error. Aborts because it cant open test.cir.___. Is the problem maybe something to do with where the program directory is located?
I was informed what a possible fix would be and it worked. The Xyce installation was in a location without admin permission (by default after serial installation). The easiest thing to try that worked was to cd to another directory with the netlist file and run Xyce in that other directory. That generated the output file correctly!

Not able to robocopy single file from Windows XP SP3 workstation

Hi Robocopy Specialists,
I am not able to transfer a backup file to server using robocopy from Windows XP SP3 workstation with the following batch file:
#echo off
………..
set "LOCAL_BACKUP_PATH=H:\Backup\%LOCALDATESTAMP%"
set "REMOTE_BACKUP_PATH=X:\Backup\%REMOTEDATESTAMP%"
md "H:\Backup\%DATESTAMP%" 2 > nul
rem "%ProgramFiles%\7-Zip\7z.exe" a -tzip "%LOCAL_BACKUP_PATH%\%BACKUP_FILE%" "H:\Backup\%LOCALDATESTAMP%\Images.db" "H:\Backup\%LOCALDATESTAMP%\Images.log" >> "H:\Backup\blog.txt"
c:\robocopy\robocopy.exe "%LOCAL_BACKUP_PATH%" "%REMOTE_BACKUP_PATH%" "%BACKUP_FILE%" /COPY:DATS /w:1 >> "H:\Backup\blog.txt"
Below is the robocopy output:
----------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows :: Version XP010
----------------------------------------------------------------------------
Started : Thu Dec 29 18:00:22 2017
Source = H:\Backup\171229_1800\
Dest : X:\Backup\171229\
Files : Backup_171229180022.zip
Options : /COPY:DATS /R:1000000 /W:1
----------------------------------------------------------------------------
NOTE: NTFS Security may not be copied - Source may not be NTFS.
0 H:\Backup\171229_1800\
----------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 1 0 0 0
Files : 0 0 0 0 0 0
Bytes : 0 0 0 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00
Ended : Thu Dec 29 18:00:22 2017
This setup has worked when transferring from a Windows 7 Pro w/s to the same server where source folder is from NTFS volume (Robocopy kept adding backslash in Windows 7 batch script).
Below are differences between Windows 7 Pro setup to this one:
Workstation on Windows XP SP3 is the source folder is a FAT32 volume (H:). I have removed the S flag (from /COPY:DATS to /COPY:DAT) which eliminates the need to copy NTFS security attributes but still no backup file been transferred.
Use an alternative source folder from a NTFS volume (D:) also not able to transfer the same backup file either.
No need for compression done by vendor application backup.
Use an old C:\Robocopy\ROBOCOPY.exe as opposed to Windows 7 Pro native C:\Windows\Systems32\ROBOCOPY.EXE.
I ran out of ideas and would appreciate your expert advice.
Thanks again,
George
Robocopy displays the output correctly.
Your robocopy output says that it has not found a file with this name and that's why no file is copied.
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 1 0 0 0
Files : 0 0 0 0 0 0
Make sure this file exists before you commit Robocopy to copy anything. Otherwise give a message in your log file that this file does not exist.
if exist "%LOCAL_BACKUP_PATH%\%BACKUP_FILE%" (
robocopy ...
) else >> "H:\Backup\blog.txt echo "%LOCAL_BACKUP_PATH%\%BACKUP_FILE%" not found.

SoundRecorder.exe Executed from Ruby on Windows 7

I am trying to run c:\windows\system32\soundrecorder.exe on a Windows 7 Device from Ruby. When I run that application, I get the following error: "No such file or Directory".
I can successfully run CALC.exe without any trouble.
I verified that my computer has the following file:
Directory of c:\windows\system32
07/13/2009 08:39 PM 142,336 SoundRecorder.exe
1 File(s) 142,336 bytes
0 Dir(s) 156,940,525,568 bytes free
I'm using:
#run_command = 'c:\windows\system32\SoundRecorder.exe'
stdin, stdout,stderr =Open3.popen3(#run_command) do |stdin,stdout,stderr,wait_thr|
process_pid = wait_thr[:pid]
p "Process Started for Execute Command: #{process_pid}"
exit_status = wait_thr.value
end
Here are the things I tried:
Ran using Calc.exe (for #run_command), and it worked.
Tried to execute this with Root privileges which failed.
Tried to pass in more environment variables which failed.
Tried to execute this via IRB and that failed.
Tried to execute this via ``` (back ticks) which failed.
** Additional Debugging Results ***
irb(main):006:0> Dir.exist? 'c:/windows/system32'
=> true
irb(main):011:0> File.exist? 'c:/windows/system32/calc.exe'
=> true
irb(main):012:0> File.exist? 'c:/windows/system32/SoundRecorder.exe'
=> false
HOWEVER before anyone says, "XXX, the file doesn't exist look here"
C:\>dir c:\windows\system32\SoundRecorder.exe
Volume in drive C is OS
Volume Serial Number is F099-27F4
Directory of c:\windows\system32
07/13/2009 08:39 PM 142,336 SoundRecorder.exe
1 File(s) 142,336 bytes
0 Dir(s) 156,942,340,096 bytes free
This is 100 % a Windows issue.
Copy the file anywhere else, and run that.
It works. I don't know why.

Uncompress recursively using 7-Zip from command line

I'm attempting to uncompress several .gz files using 7-Zip from the command line. My files are in directories like so:
Desktop/copyto/1/
file1.gz
file2.gz
Desktop/copyto/2/
file1.gz
file2.gz
file3.gz
I would like to recursively uncompress all the .gz files into each's orginal location and as well as deleting the remaining .gz files when they are done uncompressing.
I have tried the following command with no luck:
7z.exe x C:\Users\MYUSERNAME\Desktop\copyto\*\*.gz -r
I assumed that this would extract recursively. I get the error:
Processing archive: C:\Users\MYUSERNAME\Desktop\copyto\1\file1.gz
Can not open output file file1
Sub items Errors: 1
Any idea what's going on?
Given your command line, my guess is that your current working directory isn't any subdirectory of your home directory (C:\Users\MYUSERNAME) or the public user directory (C:\Users\Public), which means you probably don't have access rights. For example, if I run the following from C:\Program Files\7-Zip, I get the same error with a 7-Zip file:
C:\Program Files\7-Zip>7z x C:\Users\MYUSERNAME\Desktop\migrated\annex_k.7z -r
7-Zip [64] 9.38 beta Copyright (c) 1999-2014 Igor Pavlov 2015-01-03
Processing archive: C:\Users\MYUSERNAME\Desktop\migrated\annex_k.7z
ERROR: Can not open output file : .\annex_k\include\annex_k\errno.h
Skipping annex_k\include\annex_k\errno.h
ERROR: Can not open output file : .\annex_k\include\annex_k\handler.h
Skipping annex_k\include\annex_k\handler.h
...
Extracting annex_k\include\annex_k
Extracting annex_k\include
Extracting annex_k
Sub items Errors: 10
Archives with Errors: 1
Sub items Errors: 10
Kernel Time = 0.031 = 39%
User Time = 0.031 = 39%
Process Time = 0.062 = 78% Virtual Memory = 3 MB
Global Time = 0.080 = 100% Physical Memory = 4 MB
Notice that not even an annex_k directory was created:
C:\Program Files\7-Zip>dir /b
7-zip.chm
7-zip.dll
7-zip32.dll
7z.dll
7z.exe
7z.sfx
7zCon.sfx
7zFM.exe
7zG.exe
descript.ion
History.txt
Lang
License.txt
readme.txt
The solution is to extract to a directory in which you have access rights. You can specify an output directory using something like -oC:\Users\MYUSERNAME\Desktop\copyto\1. If you absolutely need to do this in a directory in which you don't have write access ordinarily, you'd need to run the command prompt as an administrator and extract the file as usual.

Resources