本文来自投稿,不代表长河网立场,转载请注明出处: http://www.changhe99.com/a/gjrX1gDwnN.html
Compile C++ on iOS 7 and iPhone 5S
ProgramminggeeksmayhavediscoveredthatprevioustutorialsabouthowtocompileC++oniOSneverfunctiononjailbrokeniOS7oriPhone5S.YouriDevicemustbejailbroken.GCC/G++problems fatalerror:\'iostream\'filenotfound std::coutisnotdefined Illegealinstruction:4 (someproblemswon\'tgoevenafterpatchedby\"sed-i\") ld:unknown/unsupportedarchitecturenamefor:-archarmClang++problems librarynotfoundfor-lstdc++ filenotfound:/usr/lib/system/libcache.dylibforarchitecturearmv7OneimportantreasonwhytheerrorsoccuristhatthelibraryfilesoniOS7havechangedtoomuch.TheotheristhatiPhone5Stakestheleadtousea64bitsCPU.HerearethestepsofsolutionTherearefourstepsintotal.1.DownloadCorrectcompilersHereIrecommendeveryonetodownloadanimprovedpackageofthewholecompilingenvironmentfromanotherblog.Thismodifiedpackagemakessurethatcompilersworkcorrectly,whereasitcannotprovideiOS7\'sheadersorlibraryfilesaccordingtolaws.Hereisthewebpage:http://bbs.weiphone.com/forum.php?mod=viewthread&tid=5259660&extra=page%3D&page=1&mobile=nNotethatyoualsohavetoexecutethefollowingcommands:mvtheos/var/cd/var/theos/makefiles/targetsln-sDarwin-armDarwin-arm64cd/var/theos/makefiles/platformln-sDarwin-armDarwin-arm64killallSpringBoard2.ImportiOS7 HeadersandLibrariesNow,ifwefollowoldtutorialsandimportHeadersandLibrariesfromthem,weactuallyhavenoproblemcompilingCcodes,butitjustcannotworkwithC++.Therefore,wehavetoupgradethemtoiOS7versions.BecauseofsomelawsprotectingtheHeadersandLibrariesofAppleSystems,nooneshallprovideadownloadlink.SoeveryonehastoinstallMacOSandXcodebythemselves,sothattheycanextractnecessaryfiles. ThereareonlytwopointsIintendtomentionaboutinstallingMacOS.First,itisnotrequiredtoinstallanydriversaslongasyoucanentertheOS.Second,thedirctorytobeextractedis /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/.However,actuallyitismorepromisingifthewhole/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/iscopiedtoyouriDevice.3.Noweverythinggetseasy.FirstwetellGCC/G++wheretheheadersandlibrariesarebuttheGNUCompilerisstillstuckinerrors:ld:unknown/unsupportedarchitecturenamefor:-archarmEvenifwetrytocarryoutamanuallinking,therearestillanumberofproblems.Therefore,weshouldgiveupGnuCompilersandtryClang++,whichIthinkisthemorepowerfulcompileronAppleSystems.Wefindthedirectoryofnecessaryfilesthrough\'find\'andpasstheseparameterstoClang++.Theneverythingwillworkoutprettysmoothly.HereistheSnapshotofmySSH:yuzhongzhide-iPhone:/var/mobile/MkIPA/test-cpproot#clang++a.cpp-I/var/sdk/v7-include/c++/4.2.1/-L/var/sdk/v7-lib/-L/var/sdk/v7-lib/system/yuzhongzhide-iPhone:/var/mobile/MkIPA/test-cpproot#./a.outHello!yuzhongzhide-iPhone:/var/mobile/MkIPA/test-cpproot#cata.cpp#includeusingnamespacestd;intmain(){ cout
赞
(0)