tôi muốn bao gồm libgpgerror và libgcrypt trong nhanh chóng-dự án của tôi và tạo ra module.modulemaps sau:Xcode "ld: không tìm thấy thư viện [...] cho kiến trúc x86_64"
libgpgerror:
libgcrypt:
module libgcrypt {
header "/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgcrypt/gcrypt.h"
link "'/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgcrypt/libgcrypt-1.6.5.dylib'"
export *
}
tôi cũng đã thêm các "Swift Compiler - Search Path/Import Path": /Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/**
cho cả hai dự án và mục tiêu. Các mô-đun được tìm thấy, các đường dẫn là chính xác.
Tuy nhiên nếu tôi muốn biên dịch dự án tôi nhận được lỗi sau:
ld: library not found for -l'/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgpgerror/libgpgerror-1.21.dylib' for architecture x86_64
Nhưng nếu tôi làm
file /Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgpgerror/libgpgerror-1.21.dylib
tôi nhận được đầu ra
/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgpgerror/libgpgerror-1.21.dylib: Mach-O 64-bit dynamically linked shared library x86_64
Vì vậy, có vẻ như thư viện ở đúng vị trí và cũng có kiến trúc chính xác.
Sửa
Tôi tìm thấy một workaround: tôi loại bỏ các liên kết chỉ thị từ modulemaps và liên kết các thư viện bằng tay; điều này dường như hoạt động. Nhưng tại sao?
module libgpgerror {
header "/Volumes/Xcode/Programme/Swifts/KCAnon/KCAnon_Client/Libs/libgpgerror/gpg-error.h"
export *
}
Bạn có đang sử dụng Trình quản lý gói Swift không? Làm thế nào bạn có thể liên kết các thư viện theo cách thủ công? –
Tôi đã có thể làm cho nó xây dựng bằng cách xác định rõ ràng đường dẫn dylib trong lệnh xây dựng nhanh chóng. 'swift build -Xlinker -L/usr/local/lib/-Xcc -I/usr/local/include /' –
Nếu bạn không thêm chỉ thị liên kết, bạn có thể chỉ định cờ '-luv' và tạo xcodeproj sẽ có các cờ cần thiết được thiết lập: 'swift build -Xlinker -L/usr/local/lib/-Xcc -I/usr/local/include/-Xlinker -luv --generate-xcodeproj' –