Dll lookup fails on application load time - dll

I'm trying to follow bevy's tutorial and setup everything on Windows 10 (21H1) x64. The setup kinda works. I did the following build optimizations (from bevy's tutorial):
bevy's dynamic link feature
switch to the LLD linker
switch to latest rust nightly
disable shared generics (because of this issue)
My cargo.toml
[package]
name = "foo"
version = "0.1.0"
authors = ["foo <foo#bar.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = "0.5"
My main.rs (the only code file so far):
use bevy::prelude::*;
fn main() {
println!("hello");
App::build().run();
}
My .cargo/config.toml:
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=off"]
After building my application, target/debug/ looks something like this (I removed some entries):
deps/
bevy_dylib.dll
bevy_dylib.dll.lib
bevy_dylib.pdb
foo.d
foo.exe
foo.pdb
I can build and run the application just fine using cargo with the command cargo run --features bevy/dynamic. The program prints "hello" and exists normally. However, if I run the program from the terminal (powershell in my case) nothing is print and the program exists with no error code. Seeing that lldb also crashes with "unknown error" I went ahead and took a closer look with procmon.
cargo run vs .\foo.exe
Using cargo run --features bevy/dynamic works fine, but .\foo.exe (run directly from powershell) fails without errors. Procmon reveals that .\foo.exe tries to load a different dll, it searches for bevy_dylib-d54840081e5b3869.dll instead of bevy_dylib.dll. This obviously fails because this file doesn't exist and so the program terminates before it even reaches main().
But why does cargo run --features bevy/dynamic work then? Well it turns out that the program still tries to load bevy_dylib-d54840081e5b3869.dll, however this time the loader looks up different paths. There is an additional search path: {my_project}/target/debug/deps/. And that directory actually has a dll with that exact name which is then loaded and the program can execute normally. So it turns out we never even try to use the dll target/debug/bevy_dylib.dll which makes me wonder why it's there in the first place.
My questions are:
Why does cargo run use additional lookup directories at load time linking?
Why does the program search for bevy_dylib-d54840081e5b3869.dll instead of bevy_dylib.dll?
Is this fixable without some nasty post build tasks that copy dlls manually around?

Related

XOpenDisplay(NULL) fails to connect to X

I was given a fairly large program to compile and run with extremely vague instructions on how to properly configure my system and install the program. I was told to use a Windows, install Cygwin, navigate to the program's base directory, and type "make". I installed Cygwin on a 64-bit Windows 7 in C:\cygwin64 as the main user (I also installed all of the default packages, plus a few extras) and then ran the makefile included with the program (this worked with no problems). When trying to run the executable with a required file argument, I was simply given the error message "cannot connect to X server." Upon examination of the code, it appears that this error was caused by a line setting display=XOpenDisplay(NULL) and then exiting when this resulted in display == NULL. Earlier, "display" had been declared as a variable of type Display. Is there any way I can get the program to connect to the X server? I have been assured that the installation of the program is extremely easy, but I'm not so sure... Thanks in advance.

Exported RCP application does not run

Current situation:
One of our products exported via the Eclipse Product export wizard does no longer run, if the produced .exe is run directly. Unfortunately no error message is shown, the program just stops. I assume that no plug-in is loaded at all.
Interestingly the product runs in the following cases:
the created .exe is executed in the developer mode:
in cmd with MyApplication.exe -dev
in Eclipse with Launch an Eclipse application
my colleague, who uses the same code, can export the product and run it directly
the .exe, created by me, can be run on my colleague's PC and another PC
Furthermore I can build and run the other product as usual. Win 7 and Java 7 are installed on the three PCs.
Log:
There is a Log file in \configuration:
!SESSION 2015-02-05 18:03:17.765 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_65
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Command-line arguments: -os win32 -ws win32 -arch x86
!ENTRY org.eclipse.equinox.ds 1 0 2015-02-05 18:03:19.481
!MESSAGE Could not bind a reference of component com.company.common.utils.Zipper.
The reference is: Reference[name = LogModelProvider, interface = com.company.common.service.ILogModelProvider,
policy = dynamic, cardinality = 0..1, target = null, bind = setLogModelProvider, unbind = unsetLogModelProvider]
I am not sure what the message means, but it also appears when the application is running in Eclipse. Therefore I ignored it.
There is no log file in \workspace. The folder .metadata does not exists.
What might have gone wrong:
The PDE build and export used to work, till I wanted to use Tycho as build system. Therefore I made the needed changes and finally I could build the two projects. Although the projects showed the same symptoms as described above (one worked, the other not). Therefore I created a SVN branch, committed every change and switched back to the trunk, to be back in the starting position. But the symptoms were not gone. Therefore I assume that I must have changed some setting, which causes the problem.
What I tried:
Basically I checked if the code and settings were back in the original state. I also switched the Eclipse workspace and imported the necessary plug-ins again. I also rebooted the PC once or twice.
Question:
Did anybody already have a similar behavior? Any hint is welcome.
(I know that my problem description is vague, sorry for that.)

clojure newbie, nothing is printed to console in intellij

I created test.clj
I have this code in it:
(ns clojure.examples.hello
(:gen-class))
(defn -main
[greetee]
(println (str "Hello " greetee "!")))
result:
/home/bin/java /tmp/testclj/src/test.clj
(where are my printings? shouldn't they appear here? nothing is printed here)
Process finished with exit code 0
but i get nothing printed out when i run it shouldn't it be printed?
How do you run your code?
First, you need to compile it:
(compile 'clojure.examples.hello)
And then:
java -cp ./classes:clojure.jar clojure.examples.hello Jas
Of course, path depends on your project structure.
I would say, it is much more easier if you installed IntelliJ Leiningen plugin and trying to run your code with Leiningen.
With Leiningen, you can do:
; run the -main function of a namespace
lein run -m my.namespace
And it is always a good idea, not to rely on IDEs to run and build your projects.
Old question I know, but in case someone else runs into this: the default configuration that IntelliJ creates did not print anything on my computer either. Instead, do the following:
go to Edit Configuration
change Run Clojure script to Run -main from Clojure namespace and fill in your namespace (for example, hello.world)
Run with Leiningen should have been activated automatically
If you run this config instead of the default (and have Leiningen installed, naturally), you should get logs printed to console.

File.execute() is not executing my script. How to debug this issue?

I'm writing a script for Illustrator CS6 in ExtendScript. At the end of my script, I want to spawn a task (a second script, in Ruby) using File.execute(). However, it's not working. And I'm at a loss as how to debug the problem -- how can I figure out why this isn't working?
Here's the end of my ExtendScript file:
// Do a bunch of other work, then:
var rubyFile = new File(scriptFolder + 'BuildHtmlWalkthrough.rb');
alert(rubyFile.exists);
var result = rubyFile.execute();
alert(result);
Both rubyFile.exists and result are always true, indicating that the script launched OK. But the script does not appear to run, at all. I've tried the following diagnostics:
The Ruby script does successfully run from the command line. The script's permissions are -rwxr-xr-x
I added a call to system("touch /blah/blah/blah") as the very first line of the Ruby script. The file does not get touched.
I thought maybe the ExtendScript process was terminating before the Ruby script could run, so I added a long for loop after rubyFile.execute(). Spinning for > 30 seconds did not help.
What can I do to debug, or solve, this problem?
I'm on MacOS X v10.9.1. And for reference, this is the documentation for File.execute():
File.execute (): Boolean
Core JavaScript Classes
Executes or opens
this file using the appropriate application, as if it had been
double-clicked in a file browser. You can use this method to run
scripts, launch applications, and so on. Returns true immediately if
the application launch was successful.
It's probably doing the "opens this file using the appropriate application" instead of executing, and returns true because the file successfully opens (or is already open in its associated app). If I have a python script and do
f= new File("~/Documents/misc_scripts/getpixelrgb.py");
f.execute();
, it opens it in my script editor, even if the file's execute flags are set.
I'm on OSX, btw
In After Effects, there is system.callSystem() to execute command line commands, but I'm afraid that is absent in Illustrator (I'm assuming you're doing this for Illustrator because of the tag). Are you on OSX or Windows? There are ways around this, by making an executable .app (OSX) or .exe (Win) and calling that with execute(). If I were doing this, I'm on OSX and I'd make an AppleScript app that does 'do shell script' to make the ruby system call. On Windows, it's different. One solution you might like if you're on windows: ocra, which is ruby-specific (http://ocra.rubyforge.org/). It may be possible to run a .bat file on Windows that calls the ruby script, but I'm not sure.
[edit!]
Terribly sorry for the extraneous Windows info (for someone else, I guess). Just saw your note about being on OSX. So you might want to use the AppleScript solution.
[edit again]
So, if my ruby script ("test.rb") is:
#!/usr/bin/env ruby
print "Hello"
and my AppleScript is:
do shell script "cd /testing_folder/; ruby test.rb"
Then I get "Hello" returned in AppleScript, but ExtendScript will just return true.

Why would a native program run fine when executed directly, but fail with a seg fault when submitted through condor

I have a third party library that I'm attempting to incorporate into a simulation. We have the static library (.a), along with all of it's runtime dependencies (shared objects). I've created a very simple application (in C) that is linked against the library. All it does is call an initialization function that is part of the third party library's API, and exits. When I run this directly from the command line, it works fine. If I submit the executable to our Condor grid, it fails with a seg fault on strncpy (libc.so.6). I've forced condor to only run the executable on a particular machine, and if I run it directly on that machine, it works fine.
I'm mostly a Java programmer... limited amount of native coding experience. I'm familiar with tools such as nm, ldd, catchsegv, etc... to the point where I can run them. I don't really know where to start looking for an issue though.
I've run ldd directly on the executing machine, and via a script submitted through condor, along with my executable. ldd reports the same files in both cases.
I don't understand how running it directly would work, but it would fail being run by condor. The process that ultimately executes the program, condor_startd, is a process that starts as root, and changes its effective uid to the submitter. Perhaps this has something to do with it?
Don't know why this would cause an issue, but the culprit was the LANG environment variable. It was not set when running under Condor, but was set to US_EN.UTF-8 when running locally. Adding this value to the condor execution environment fixed the problem.