I want to add admob to my game. I added “GoogleAdMobAdsSdkiOS-6.5.1” to my project.
There is libcurl.a in framework, and the path is available.
But then it build failed, and here is the issue.
ld: warning: directory not found for option '-L"/Users/NPHD/GameDev/cocos2d-x-2.2.2/projects/FlappyBeetle/proj.ios/../../../cocos2dx/platform/third_party/ios/libraries"'
ld: warning: directory not found for option '-L"/Users/NPHD/GameDev/cocos2d-x-2.2.2/projects/FlappyBeetle/proj.ios/../../../external/libwebsockets/ios/lib"'
ld: library not found for -lcurl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does any body meet the same problem?
屏幕快照 2014-03-15 上午12.02.16.png (557.1 KB)
Hello!
Something similar happened to me when I added Flurry library, it changed the library paths (don’t know if this is a XCode bug or what).
Are you sure these paths are corret?
- “/Users/NPHD/GameDev/cocos2d-x-2.2.2/projects/FlappyBeetle/proj.ios/…/…/…/cocos2dx/platform/third_party/ios/libraries”
- “/Users/NPHD/GameDev/cocos2d-x-2.2.2/projects/FlappyBeetle/proj.ios/…/…/…/external/libwebsockets/ios/lib”
Look in Search Paths inside the Build Settings for the project. What’s there? Can you post a screenshot maybe :)?
Thank you for your reply.
I checked my Library Search Paths
There are some wrong with these 2 path
\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"
\"$(SRCROOT)/../../../external/libwebsockets/ios/lib\"
I changed these 2 path to the absolute path
/Users/NPHD/GameDev/cocos2d-x-2.2.2/cocos2dx/platform/third_party/ios/libraries
/Users/NPHD/GameDev/cocos2d-x-2.2.2/external/libwebsockets/ios/lib
Then it works.
1 Like
Summary of the problems I meet when adding admob to my project FlappyBeetle (cocos2dx-2.2.2)
$COCOS2D is the path of my cocos2d-2.2.2
-
my work is base on this blog [http://sukesan1984.com/wordpress/2013/12/11/807]
-
libcurl.a is missing
I create my project by $COCOS2D/tools/project-creator/create_project.py
When open the FlappyBeetle.xcodeproj, in the subproject(cocos2dx.xcodeproj),
the Location of libcurl.a is “…/…/cocos2dx/platform/third_party/ios/libraries/libcurl.a”
which means the absolute path of libcurl.a is “$COCOS2D/projects/cocos2dx/platform/third_party/ios/libraries/libcurl.a”
Solution: create a link of “$COCOS2D/cocos2dx” at “$COCOS2D/projects/cocos2dx”
$ ln -s $COCOS2D/cocos2dx $COCOS2D/projects/cocos2dx
- library not found for -lcurl
Build Settings > Library Search Paths
There are some wrong with these 2 path
\"$(SRCROOT)/../../../cocos2dx/platform/third_party/ios/libraries\"
\"$(SRCROOT)/../../../external/libwebsockets/ios/lib\"
Solution: change these 2 path to the absolute path
/Users/NPHD/GameDev/cocos2d-x-2.2.2/cocos2dx/platform/third_party/ios/libraries
/Users/NPHD/GameDev/cocos2d-x-2.2.2/external/libwebsockets/ios/lib
-
!! Don’t forget to add the tag before you build
Build Settings > Other Linker Flags -ObjC
-
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)
"_OBJC_CLASS_$_MFMailComposeViewController", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
"_OBJC_CLASS_$_MFMessageComposeViewController", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
"_OBJC_CLASS_$_SKStoreProductViewController", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
"_SCNetworkReachabilityCreateWithName", referenced from:
-[GADNetworkChecker startNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
"_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
-[GADNetworkChecker startNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
"_SCNetworkReachabilitySetCallback", referenced from:
-[GADNetworkChecker startNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
-[GADNetworkChecker stopNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
"_SKStoreProductParameterITunesItemIdentifier", referenced from:
-[GADOpener openInAppStore:fallbackURLString:] in libGoogleAdMobAds.a(GADOpener.o)
These kinds of problem are caused by missing framework library
Add the required.framework at Build Phases > Link Binary With Libraries
Here we need add 4 framework
+ AdSupport.framework “OBJC_CLASS$_ASIdentifierManager”
+ MessageUI.framework “OBJC_CLASS$_MFMailComposeViewController”
+ StoreKit.framework “OBJC_CLASS$_SKStoreProductViewController”
+ SystemConfiguration.framework “_SCNetworkReachabilityCreateWithName”
- admob SDK 6.5.1 -> 6.8.0
Console log:
2014-03-15 22:18:06.327 FlappyBeetle[11639:70b] <Google:HTML> Google Mobile Ads SDK: You are currently using 6.5.1 of the SDK. A new version, 6.8.0, is available at http://goo.gl/Zc0BYt . Please consider updating your SDK to get the latest features and bug fixes
Build Phases > Link Binary With Libraries
+ CoreTelephony.framework “_CTTelephonyNetworkInfo”
- place bannerView_ at the bottom of screen
Get the resolution of screen [http://stackoverflow.com/questions/4779221/in-iphone-app-how-to-detect-the-screen-resolution-of-the-device]
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGPoint origin = CGPointMake(0, screenBounds.size.height - GAD_SIZE_320x50.height);
bannerView_ = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin] autorelease];
So now it works? Glad to hear that
Good post about adding AdMob btw!
btw AdMob 6.x.x is about to be deprecated. Use Google Play Services ad framework instead…