I am on Windows 10 using msys.
Whenever I try to run protoc.exe for protobufs I get the following error.
error while loading shared libraries: ?: cannot open shared object file: No such file or directory
I have checked with ldd
ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ffe998b0000)
KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ffe97c10000)
KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ffe972a0000)
msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ffe98900000)
All of these files exist and PATH is set to /c/Windows/SYSTEM32.
I am not sure what is going on here.
You can trigger this in bazel by trying to build any protobuf
bazel build --compiler=mingw-gcc some_proto
only in msys though.
Okay there are two ways to fix this.
build through command prompt and change PATH
to include
C:\Windows\SYSTEM32
C:\msys64\usr\bin
Through msys move the following files to C:\msys64\mingw64\bin
ntdll.dll
KERNEL32.DLL
KERNELBASE.dll
msvcrt.dll
Related
I know there are sevareal answers about this topic, but certainly, I do not understand them.
[Linux | ubuntu 20.04 | cmake 3.23]
The problem is that while building a shared library with cmake, when I link this library to an executable, the library is founded [tested with ldd command]. But when i install the project my executable in /bin folder, cant find my library in lib directory.
The error is:
./my_executable.exe: error while loading shared libraries: libCOOK.so: cannot open shared object file: No such file or directory
Program directory
src/
exes/
my_exe.f90
libraries/
COOK.c
Install directory
-lib/
libCOOK.so
-bin/
my_executable.exe
-include/
My own answer:
Just add the install_directory/lib to the LD_LIBRARY_PATH
I'am trying build boost 1.69 on Solaris 11.3 with gcc 4.8.2.
Then build is complete i'am see (with ldd libname.so) that linker using relative path in dynamic section tag NEEDED
bin.v2/libs/atomic/build/gcc-4.8.2/release/threading-multi/visibility-hidden/libboost_atomic.so.1.69.0
It is not good. I want to linker use only libname without any path (absolute or relative).
How i can set short name link?
So: outut ldd from solaris and ldd from RHEL 6
Solaris
ldd libboost_thread.so.1.69.0
**bin.v2/libs/system/build/gcc-4.8.2/release/threading-multi/visibility-hidden/libboost_system.so.1.69.0** => bin.v2/libs/system/build/gcc-4.8.2/release/threading-multi/visibility-hidden/libboost_system.so.1.69.0
.........
linux
ldd libboost_thread.so.1.69.0
linux-gate.so.1 => (0x00ba6000)
**libboost_system.so.1.69.0** => /usr/lib/libboost_system.so.1.69.0 (0x00a53000)
........
Why on Solaris boost building with using crasy path in dependency name, but on Linux - it normal - only libname without any path. How i can say to b2 or other tool to use only short dependency name?
The Solaris linker is simply recording what it was told - it appears the command to link the software passed bin.v2/libs/system/build/gcc-4.8.2/release/threading-multi/visibility-hidden/libboost_system.so.1.69.0 to the linker, instead of the normal -Lbin.v2/libs/system/build/gcc-4.8.2/release/threading-multi/visibility-hidden/ -lboost_system. You'll have to look into the build scripts/Makefiles to determine why it's doing that.
With the following C code:
int main() {}
I compile under MSYS2 using gcc -o m2 m2.c . This gcc is the one installed by pacman -S gcc; version 4.9.2 target x86_64-pc-msys.
I copy m2.exe and msys-2.0.dll to a directory on another PC with a Cygwin installation. If I run m2.exe from a command prompt it executes correctly, however executing from a Cygwin Bash shell I get the error:
3 [main] m2 (4552) C:\Temp\m2.exe: *** fatal error - cygheap base mismatch detected - 0x180305408/0x180320400.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version. The most recent version *should*
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution. Rebooting is also suggested if you
are unable to find another cygwin DLL.
The error message is puzzling as MSYS2 does not have any cygwin1.dll at all.
How do I fix this? Obviously I don't want to delete the Cygwin installation's cygwin1.dll .
The m2 executable does not have any dependencies other than msys-2.0.dll and built-in Windows DLLs. (I checked with Dependency Walker). It must be something about the binary built with MSYS2 GCC that is meant to search for msys-2.0.dll but instead finds the installed cygwin1.dll. Is there a workaround?
The output of ldd m2.exe is:
ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7ffd12740000)
KERNEL32.DLL => /cygdrive/c/Windows/system32/KERNEL32.DLL (0x7ffd115f0000)
KERNELBASE.dll => /cygdrive/c/Windows/system32/KERNELBASE.dll (0x7ffd0f2b0000)
msys-2.0.dll => /c/Temp/msys-2.0.dll (0x180040000)
I am compiling with GCC 4.8.2 (MinGW) on Windows. I am using openMP in my program. When I compile without -static flag I get this output from dumpbin /dependents myapp.exe:
Dump of file myapp.exe
File Type: EXECUTABLE IMAGE
Image has the following dependencies:
KERNEL32.dll
msvcrt.dll
USER32.dll
libgomp-1.dll
Now including libgomp-1.dll in the same folder as myapp.exe won't be enough as that depends on some more .dlls (libwinpthread-1.dll and libgcc_s_seh-1.dll) and dumpbin only goes one level deep.
Now I compile including -static in compilation flags and I get this output from dumpbin:
File Type: EXECUTABLE IMAGE
Image has the following dependencies:
KERNEL32.dll
msvcrt.dll
USER32.dll
Is it now going to work without .dlls on which libgomp-1.dll depends? Did GCC include static version of those libraries as well? Would dumpbin be able to detect those new dependencies ?
(I am probably getting a bit paranoid here but those things are very difficult to test on local machine where I have those dlls in many places on my PATH)
You can't link MSVCRT (the Windows C Library) static with MinGW, but that shouldn't be much of a problem. MSVCRT.dll, KERNEL32.dll, USER32.dll should be present on all Windows versions. You don't need to redistribute them.
I've created very minimal chroot environment on sdb and mounted it on /mnt/sdb. I've also created a symbolic link /mnt/sdb/bin/cc that points to /usr/bin/gcc.
ldd /mnt/sdb/bin/cc returned
linux-gate.so.1 => (0xb7829000)
libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb76dd000)
/lib/ld-linux.so.2 (0xb782a000)
So I copied the necessary libraries by running:
cp /lib/i686/cmov/libc.so.6 /mnt/sdb/lib/i686/cmov/libc.so.6
cp /lib/ld-linux.so.2 /mnt/sdb/lib/ld-linux.so.2
Glancing through this article, I figured that since linux-gate.so.1 is a part of the kernel, I don't need to copy it over.
However, after I run chroot /mnt/sdb /bin/sh then try cc I get
cc: error while loading shared libraries: libm.so.6: cannot open shared object file: No such file or directory
How come ldd couldn't tell cc needed libm.so.6? Is there an easy way to get cc to work in the chrooted environment without simply copying over all the libraries? I'd just like to use cc temporarily so that I can build tcc with it, then build everything else with tcc (I've also tried simply building tcc outside then using it in chroot, but I'm afraid that that might deserve its own post).
Note:
I'm using Debian in Virtualbox, and the only program that currently runs in the chroot environment is a single (static) busybox binary.