avast / retdec

RetDec is a retargetable machine-code decompiler based on LLVM.
https://retdec.com/
MIT License
8k stars 946 forks source link

Error during "Linking CXX executable retdec-ar-extractor.exe" on cygwin64 #558

Closed TheElementalOfDestruction closed 4 years ago

TheElementalOfDestruction commented 5 years ago
$ make
[  0%] Built target capstone-project
[  1%] Built target jsoncpp-project
[  2%] Built target llvm-project
[  3%] Built target rapidjson-project
[  3%] Built target tinyxml2-project
[  4%] Built target elfio-project
[  5%] Built target libdwarf-project
[  6%] Built target pelib-project
[  7%] Built target yaracpp-project
[  8%] Built target yaramod-project
[  9%] Built target whereami
[ 11%] Built target retdec-utils
[ 11%] Built target retdec-ar-extractor
[ 11%] Linking CXX executable retdec-ar-extractor.exe
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text+0xa0): undefined reference to `__imp_PathFileExistsA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_PathFileExistsA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text+0x180): undefined reference to `__imp_PathIsRelativeA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text+0x180): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_PathIsRelativeA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text+0x1c0): undefined reference to `__imp_PathIsRelativeA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text+0x1c0): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_PathIsRelativeA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text$_ZN6retdec5utils25FilesystemPathImplWindows10isAbsoluteEv[_ZN6retdec5utils25FilesystemPathImplWindows10isAbsoluteEv]+0xa): undefined reference to `__imp_PathIsRelativeA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text$_ZN6retdec5utils25FilesystemPathImplWindows10isAbsoluteEv[_ZN6retdec5utils25FilesystemPathImplWindows10isAbsoluteEv]+0xa): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_PathIsRelativeA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text$_ZN6retdec5utils25FilesystemPathImplWindows6existsEv[_ZN6retdec5utils25FilesystemPathImplWindows6existsEv]+0xa): undefined reference to `__imp_PathFileExistsA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text$_ZN6retdec5utils25FilesystemPathImplWindows6existsEv[_ZN6retdec5utils25FilesystemPathImplWindows6existsEv]+0xa): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_PathFileExistsA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text$_ZN6retdec5utils25FilesystemPathImplWindows13getParentPathEv[_ZN6retdec5utils25FilesystemPathImplWindows13getParentPathEv]+0x3d): undefined reference to `__imp_PathRemoveFileSpecA'
../utils/libretdec-utils.a(filesystem_path.cpp.o):filesystem_path.cpp:(.text$_ZN6retdec5utils25FilesystemPathImplWindows13getParentPathEv[_ZN6retdec5utils25FilesystemPathImplWindows13getParentPathEv]+0x3d): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `__imp_PathRemoveFileSpecA'
collect2: error: ld returned 1 exit status
make[2]: *** [src/ar-extractortool/CMakeFiles/retdec-ar-extractortool.dir/build.make:120: src/ar-extractortool/retdec-ar-extractor.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:983: src/ar-extractortool/CMakeFiles/retdec-ar-extractortool.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
s3rvac commented 5 years ago

Thank you for the report. We will try to reproduce it and fix it. We have never really tried building RetDec inside Cygwin (on Windows, we recommend building RetDec without any Unix-like environment with Visual Studio).

twitzelbos commented 5 years ago

This and other tools in the retdec build are missing the link to the two libraries -lshlwapi -lz. I manually winged it for the few affected bins and got it to compile. Unfortunately, I'm not versed enough in cmake to fix this properly, so if someone could point me in the right direction, I'll gladly fix it and push it.

There is also some difficulty with the deps, relating to retdec-libdwarf.dll and retdec-libelf.dll (compiling to bin, but sometimes looking in lib) and the deps for yarac (looking for file yarac, but its called yarac.exe from the start), all of which I was to wing, but need to be addressed properly in the cmake system.

twitzelbos commented 5 years ago

Update: I made some tweaks to the cmake files that make the whole package compile smoothly now and also put in a pull request. Let's see how this fares. I think the crux here is that msys/mingw has behavior that's a mix between Windows typical and Linux behaviors.

s3rvac commented 5 years ago

Just for future reference, the PR where this is being worked on is #606.

s3rvac commented 4 years ago

@TheElementalOfCreation Does the issue still persist for you, even after #606 has been merged into master?

TheElementalOfDestruction commented 4 years ago

Err, I gave up compiling with Cygwin a while ago, I don't know. Getting a proper build environment back up to test this in would take quite some time as well.

s3rvac commented 4 years ago

Alright, no problem. Let's close the issue. If anyone else stumbles upon it, please create a new issue.