is there a way to set the external dll searching path when a Fortran project is deployed(Leave the PATH strategy aside)?
Assume that we have a Main.exe here, and it depend on an external dll called Depend.dll. Generally, we can put Main.exe and Depend.dll together under the same folder to make it work, but in another situation, if Depend.dll is under a folder called External, and External and Main.exe are put together, is there a solution that Main.exe can find the dll?
As discussed, for Windows:
add the place of the dll to the PATH variable.
In case one wants to only set the path to the dll temporarily:
create a .bat file with:
save current path: set SAVED_PATH=%PATH%
set path including dll directory: set PATH=<path to dll>;%PATH%
<run executable>
reset path: set PATH=%SAVED_PATH%
Related
I have an excutable and a shared library in same directory, the executable running well, however, after moving the shared library to other pos, I can not run the executable showing can not find libxxx.so
I want to know why it happens?
You can move the library to some standard library path. It is defined in /etc/ld.so.conf. The loader will only find libraries defined in there. In the other hand, you can also use LD_LIBRARY_PATH env variable to put your shared library path. It makes sure the path is searched first
I have a shared library and application in same folder and when I try to open terminal from that folder and run the application it gives library not found issue. If i set environment variable $LD_LIBRARY_PATH then it works well
My question is:
Wouldnt opening the terminal from that folder sets environment variable $LD_LIBRARY_PATH?
Wouldnt opening the terminal from that folder sets environment variable $LD_LIBRARY_PATH?
No, you will have to add it to your $LD_LIBRARY_PATH
Basically the shared library's location is not in the linker's search path. You will have to either
modify the LD_LIBRARY_PATH environment variable and then run ldd again or
move the shared library file to one of the $LD_LIBRARY_PATHalready present
I am trying to make a Qt5 part of my source tree, so I haven't installed it on my machine, just copied it from source control. I am having a problem when I try to run uic.exe:
stiopa#stiopa-VirtualBox:~/ct/LinuxLibs/Qt/bin > ./uic
./uic: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
I am still getting the same error even when I copy the libQt5Core library to bin directory. How is uic looking for shared libraries? Is there any environment variable I need to set to fix it?
This is yet another case of not putting the dependent shared libraries in a defined location that is supported by the program.
If you're planning on doing the 'copy the files to the same directory as the executable', the fast solution is to reference the directory in the library load path; e.g. if the binary is in $HOME/foo, you do:
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}$HOME/foo
This adds or makes $HOME/foo the run-time-linker's load path. As a result, any programs you run will look in this directory for libraries, as well as the default set for the OS (defined by the ld.so configuration), as well as the paths that are defined within the application itself (the rpath).
If you're going to follow this route, what you can do is to move the binary to target.bin, create a target bash script, which invokes the bin file automatically; e.g.
#!/bin/bash -p
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}$(dirname $0)
exec $0.bin "$*"
A secondary mechanism which will permit you to change the search location for a binary; without requiring an environment variable insert is to modify the binary so that it searches in different locations than it usually does; this takes advantage of some features in the run-time linker (which looks for libraries).
There is a program called chrpath, which can be added by various package managers, which allows you to edit the rpath directly. In this case; you can change the additional search path of the binary using:
chrpath -r '$ORIGIN' foo
This means that the program will look in the same directory as the binary for .so files, thus allowing it to run.
I have a Visual C++ 2012 Express project on Git that uses an external libcurl (not included in the repository).
I added the library by adding the corresponding paths on my machine (D:\libcurl\XXX) to Include Directories and Library Directories in VC++ Directories of Project Properties. So these settings are saved in the .vcxproj file.
If someone whose libcurl path is different from mine wants to build the project, he would have to:
Change VC++ Directories settings in Project Properties.
(then the project file will become modified, which is not what I want.)
Move his libcurl files to match mine (D:\libcurl).
(library path is forced to be D:\libcurl, not so flexible)
My question is: Is there a way to avoid this?
(In old versions of Visual C++, I can set the paths in the global VC++ Directories of the Tools->Options dialog instead. But the feature is deprecated in recent versions.)
I believe u can achieve this by using environment variables.
For example, you can add an environment variable called: LIBCURL
You can then set the LIBCURL to any path u want: D:\libcurl or X:\lib2.3b ...
no matter what ur library path is, u can always use the same VC++ Directories: $(LIBCURL)\XXX
I have a DLL that I am calling from Inno setup script, dll is looking to load some file from the path where executable is located.
In my case when I execute the setup, temporary executable is exported in temp folder is-xxxxx
BTW, {tmp} is not the right one. It is another tmp folder but not the one that temporary setup.
I need to know that in inno setup is there a constant to represent that folder.
Thanks.
Your DLL can determine which path it's been extracted to and it can also determine the path of the temporary executable. The way you do it depends on the language your DLL is written in.
But the Key Windows API call is GetModuleFileName
If your DLL was written in Delphi you could use the following to get the path of Setup.exe
ExtractFilePath(ParamStr(0))
How about this
path := ExpandConstant('{src}');