2017-07-19 61 views
0

因此,我一直在努力嘗試使GDAL庫與我的iOS應用程序一起工作兩天。每當我嘗試建立我的計劃,我得到像下面這樣的錯誤:將從自制軟件下載的C庫鏈接到Xcode項目時出錯

Ld /Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Products/Debug-iphoneos/Mapper.app/Mapper normal arm64 
cd /Users/scottdriggers/Documents/XcodeProjects/Mapper 
export IPHONEOS_DEPLOYMENT_TARGET=9.0 
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -L/Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Products/Debug-iphoneos -L-L/usr/local/Cellar/gdal/1.11.5_2/lib -L-lgdal -L/usr/local/Cellar/gdal/1.11.5_2/lib -F/Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Products/Debug-iphoneos -F/Users/scottdriggers/Documents/XcodeProjects/Mapper/Pods/DJI-SDK-iOS/iOS_Mobile_SDK -F/Users/scottdriggers/Documents/XcodeProjects/Mapper/Pods/DJI-UILibrary-iOS/iOS_UILibrary -filelist /Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Intermediates/Mapper.build/Debug-iphoneos/Mapper.build/Objects-normal/arm64/Mapper.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -miphoneos-version-min=9.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Intermediates/Mapper.build/Debug-iphoneos/Mapper.build/Objects-normal/arm64/Mapper_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -ObjC -framework DJISDK -framework DJIUILibrary -ObjC -framework DJISDK -framework DJIUILibrary -I/usr/local/Cellar/gdal/1.11.5_2/include -lgdal.1 -framework CoreGraphics -framework MapKit -framework CoreLocation -framework UIKit -framework Foundation /Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Products/Debug-iphoneos/VideoPreviewer.framework/VideoPreviewer -lPods-Mapper -Xlinker -dependency_info -Xlinker /Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Intermediates/Mapper.build/Debug-iphoneos/Mapper.build/Objects-normal/arm64/Mapper_dependency_info.dat -o /Users/scottdriggers/Library/Developer/Xcode/DerivedData/Mapper-goynotoybcqaezfpmrcmfwumcokh/Build/Products/Debug-iphoneos/Mapper.app/Mapper 

ld: warning: directory not found for option '-L-L/usr/local/Cellar/gdal/1.11.5_2/lib' 
ld: warning: directory not found for option '-L-lgdal' 
ld: warning: ignoring file /usr/local/Cellar/gdal/1.11.5_2/lib/libgdal.1.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /usr/local/Cellar/gdal/1.11.5_2/lib/libgdal.1.dylib 
Undefined symbols for architecture arm64: 
"_GDALGetRasterXSize", referenced from: 
    -[GEOTIFFManager averageFile:] in GEOTIFFManager.o 
"_GDALGetRasterYSize", referenced from: 
    -[GEOTIFFManager averageFile:] in GEOTIFFManager.o 

...許多類似的問題...

ld: symbol(s) not found for architecture arm64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

專家級程序員我,我立即去谷歌搜索有類似問題的其他人,並發現有不少。繼他們的建議,我做了所有的下列事項多次在幾個不同的順序:

我清理,並試圖重新建造
我刪除了導出數據文件夾中的內容的Xcode
我更新了頭項目搜索路徑,其他鏈接標誌,框架搜索路徑和庫搜索路徑到我推薦的所有東西,沒有任何幫助。這些設置的當前狀態爲:
框架搜索路徑:
$(繼承)
頭搜索路徑:
$(繼承)
「$ {PODS_ROOT} /頭/公/ DJI-SDK-IOS」
「$ {} PODS_ROOT /頭/公/ DJI-UILibrary-IOS」
/usr/local/Cellar/gdal/1.11.5_2/include
在/ usr /本地/包括
圖書館搜索路徑:
-L在/ usr /本地/庫/ @中/ 1.11.5_2/lib目錄
-lgdal
/usr/local/Cellar/gdal/1.11.5_2/lib
RUNPATH搜索路徑:
$ (繼承)
@ executable_path /框架

我收到了多個錯誤,我能在我的目標的構建階段加入一些庫到標籤「鏈接二進制與圖書館」來解決其中的一些,但即使我從/ usr/local/lib文件鏈接庫,這些GDAL錯誤也不會消失。

Link Binaries With Libraries

背景:我需要從我的程序的GeoTIFF文件查看像素。我正在使用OBJC編寫我的應用程序,但GDAL庫是用於C++或C的。我使用Homebrew安裝了這些庫,並且這很順利,所有文件都鏈接到/ usr/local,但它們不能正常工作Xcode中。我最初開始用C++編寫這個文件,但是在這樣的錯誤發生一天後切換到了C語言。切換到C後(所以我不必在OBJC++編譯),我仍然經歷了相同的錯誤。

注:我也使用Cocoapods來運行一些其他庫,但Cocoapods沒有GDAL庫,或者我會嘗試該路線。

情節複雜:當我運行程序的iPhone模擬器,而不是試圖在我的iPhone 7上運行它,程序編譯就好了,並說:「構建成功」,但我得到另一個錯誤嘗試時將其連接到模擬器:

dyld: Library not loaded: /usr/local/opt/gdal/lib/libgdal.1.dylib 
Referenced from: /Users/scottdriggers/Library/Developer/CoreSimulator/Devices/1618C362-7271-4E1D-93C7-DE7CE2F15F59/data/Containers/Bundle/Application/905B2454-C731-42DC-8963-5B5C3F4A62A6/Mapper.app/Mapper 
Reason: no suitable image found. 
Did find: /usr/local/opt/gdal/lib/libgdal.1.dylib: mach-o, but not built for iOS simulator 

我不認爲它必須包括引起錯誤,但在這裏,如果有人想看看一個採樣文件:

#include "GEOTIFFManager.h" 
#include "gdal.h" 
#include "cpl_conv.h" 
@interface GEOTIFFManager() 
@end 
@implementation GEOTIFFManager 
- (id) init{ 
    self = [super init]; 
    GDALAllRegister(); 
    return self; 
} 
- (float) getPixelValueOfCoordinate:(double *)coordinate FromFile:(char *)name{ 
    GDALDatasetH* inFile = (GDALDatasetH*)GDALOpen(name, GA_ReadOnly); 
    double* transformation = NULL; 
    GDALGetGeoTransform(inFile, transformation); 
    double* transformedCoord; 
    transformedCoord = reverseTransform(coordinate, transformation); 
    int pixelX = floor(transformedCoord[0]); 
    int pixelY = floor(transformedCoord[1]); 
    float tempArray[1] = {-1.0}; 
    float* output = tempArray; 
    GDALRasterBandH Band = GDALGetRasterBand(inFile, 1); 
    GDALRasterIO(Band, GF_Read, pixelX, pixelY, 1, 1, output, 1, 1, GDT_CFloat32, 0, 0); 
    return output[0]; 
} 

無論如何,謝謝你我爲你的幫助,我很感激。希望你能提供一些有用的提示。

回答

0

我找到了答案。我試圖將Mac OSX應用程序安裝到我的iOS應用程序中。是的,我知道,非常愚蠢。我通過使用谷歌搜索來解決這個問題,直到我發現有人爲此解決方案提供了tutorial。希望這有助於某人。

0

我沒有做任何的Xcode或iOS開發,但我建議固定鏈接錯誤,你做任何事情之前:

ld: warning: directory not found for option '-L-L/usr/local/Cellar/gdal/1.11.5_2/lib'

鏈接器找不到目錄-L/usr/local/Cellar/gdal/1.11.5_2/lib。它看起來像一個接一個地有兩個-L選項,所以我會刪除第一個,然後仔細檢查目錄/usr/local/Cellar/gdal/1.11.5_2/lib是否存在幷包含所需的庫。這可能是Xcode配置問題。看看你在哪裏配置鏈接器包括。這裏

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

同一問題上,-L選項指定一個額外的目錄去尋找庫和-l選項提供特定庫,包括(在這種情況下,gdal)。字符串-L-lgdal沒有任何意義,但-lgdal的確有意義。

ld: warning: ignoring file /usr/local/Cellar/gdal/1.11.5_2/lib/libgdal.1.dylib, file was built for x86_64 which is not the architecture being linked (arm64): /usr/local/Cellar/gdal/1.11.5_2/lib/libgdal.1.dylib

被發現的庫是x86_64體系,但你試圖建立一個arm64應用。如果您將庫作爲預構建的二進制文件,那麼請去找一個arm64二進制文件。如果你建立了這些庫,那麼你想爲arm64體系結構重新構建它們。

+0

當我將這些路徑添加到Xcode中的「庫搜索路徑」中時,我將它們添加爲「-L」而它提供了「-L」我應該添加路徑「/usr/local/Cellar/gdal/1.11 .5_2/lib-lgdal「是這樣嗎? –

+0

@ScottDriggers我從來沒有使用過Xcode,對不起。我只能說'ld'沒有得到你想要的參數。 – David

+0

@ScottDriggers但是,圖書館搜索路徑聽起來是指定該路徑的正確位置,而其他地方則需要指定庫「gdal」 – David

相關問題