RJVB / afsctool

This is a version of "brkirch"'s afsctool utility that allows end-users to leverage HFS+ compression.
https://brkirch.wordpress.com/afsctool
GNU General Public License v3.0
187 stars 18 forks source link

Linking error with latest source #20

Closed gingerbeardman closed 5 years ago

gingerbeardman commented 5 years ago

Any thoughts appreciated.

[100%] Linking CXX executable afsctool
ld: warning: directory not found for option '-L-lz'
ld: warning: text-based stub file /System/Library/Frameworks//CoreServices.framework/CoreServices.tbd and library file /System/Library/Frameworks//CoreServices.framework/CoreServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork.tbd and library file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
  "_compress2", referenced from:
      _compressFile in afsctool.c.o
  "_compressBound", referenced from:
      _compressFile in afsctool.c.o
  "_uncompress", referenced from:
      _decompressFile in afsctool.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [afsctool] Error 1
make[1]: *** [CMakeFiles/afsctool.dir/all] Error 2
make: *** [all] Error 2
RJVB commented 5 years ago

ld: warning: directory not found for option '-L-lz' ... Undefined symbols for architecture x86_64: "_compress2", referenced from: _compressFile in afsctool.c.o "_compressBound", referenced from: _compressFile in afsctool.c.o "_uncompress", referenced from: _decompressFile in afsctool.c.o

I'll have to check where the -L-lz above comes from; evidently I'm not getting this or else I'd be having link errors too.

RJVB commented 5 years ago

ld: warning: directory not found for option '-L-lz'

Does this change anything for you?

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51cf7754d3efc426a54f068358b2b4eb8a6e1569..97914b75534f16c94a03cce13b2ac6b4977b8d9c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,7 +77,9 @@ endif()

 target_include_directories(afsctool PRIVATE ${CMAKE_SOURCE_DIR})
 # set_target_properties(afsctool PROPERTIES COMPILE_FLAGS -DSUPPORT_PARALLEL)
-target_link_libraries(afsctool ${ZLIBP_LIBRARY_LDFLAGS} ${ZLIBP_LIBRARIES} ${PKG_SPARSEHASH_LIBRARIES})
+set_target_properties(afsctool PROPERTIES
+    LINK_FLAGS "${ZLIBP_LIBRARY_LDFLAGS}")
+target_link_libraries(afsctool ${ZLIBP_LIBRARIES} ${PKG_SPARSEHASH_LIBRARIES})
 if(LZVN_LIBRARY)
     target_link_libraries(afsctool ${LZVN_LIBRARY})
 endif()
gingerbeardman commented 5 years ago

I now get this

[100%] Linking CXX executable afsctool
ld: warning: -L path 'CMakeFiles/afsctool.dir/afsctool.c.o' is not a directory
ld: warning: text-based stub file /System/Library/Frameworks//CoreServices.framework/CoreServices.tbd and library file /System/Library/Frameworks//CoreServices.framework/CoreServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork.tbd and library file /System/Library/Frameworks//CFNetwork.framework/Versions/A/CFNetwork are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/Versions/A/CoreFoundation are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices are out of sync. Falling back to library file for linking.
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
  "_afsctool", referenced from:
      _main in main.cpp.o
  "_compressFile", referenced from:
      FileEntry::compress(FileProcessor*, ParallelFileProcessor*) in ParallelProcess.cpp.o
  "_process_file", referenced from:
      FileEntry::compress(FileProcessor*, ParallelFileProcessor*) in ParallelProcess.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [afsctool] Error 1
make[1]: *** [CMakeFiles/afsctool.dir/all] Error 2
make: *** [all] Error 2
RJVB commented 5 years ago

Is there still a -lz argument on the linker commandline?

gingerbeardman commented 5 years ago

Have revised/expanded previous snippet, please check again. no -lz just -L

RJVB commented 5 years ago

Weird, you appear to have zlib installed. What do you get by adding the following 2 lines above the set_target_properties statement in the cmake file?

message(STATUS "ZLIB flags: ${ZLIBP_LIBRARY_LDFLAGS}")
message(STATUS "ZLIB lib(s): ${ZLIBP_LIBRARIES}")

It was already strange in fact that you got "-L" earlier, I should have realised that. Unless you installed zlib in the afsctool build directory?!

gingerbeardman commented 5 years ago

I get:

-- ZLIB flags: -L
-- ZLIB lib(s): z
RJVB commented 5 years ago

Hmmm, do you use the system zlib maybe? A bit surprising that cmake would set an empty -L option if the found library is on the standard search path!

gingerbeardman commented 5 years ago

I'll check later which zlib. Did be system but I can't be 100% sure

RJVB commented 5 years ago

I think I found the reason for the solitary -L: a zlib.pc file for an install that puts libz.dylib in a standard location. My FindZLIBP.cmake macro didn't consider the possibility that it could receive an empty PKG_ZLIBP_LIBRARIES variable. Fixed and pushed.

gingerbeardman commented 5 years ago

Merci beaucoup René