我需要使用libcurl的静态库,我找到了生成库的this github rep。
现在,我尝试使用静态库libcurl_a.lib编译一段使用curl的简单代码,但没有成功。
首先,我错过了-DCURL_STATICLIB标志,并且我得到了一些未定义的引用错误:
#import "LoginViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface LoginViewController ()
- (void)toggleHiddenState:(BOOL)shouldHide;
@end
@implementation LoginViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self toggleHiddenState:YES];
self.lblLoginStatus.text = @"";
self.loginButton.readPermissions = @[@"public_profile", @"email"];
self.loginButton.layer.cornerRadius = 0;
[self.loginButton.layer setBorderWidth:0.0f];
self.loginButton.delegate = self;
// UIImageView *image = nil;
//
// for (NSObject *pic in [self.profilePicture subviews]) {
// if ([pic isMemberOfClass:[UIImageView class]]) {
// UIImageView *objImg = (UIImageView *)pic;
// image = objImg.image;
// break;
// }
// }
//
// self.view.backgroundColor = [UIColor colorWithPatternImage:image];
//
// Do any additional setup after loading the view.
}
-(void)toggleHiddenState:(BOOL)shouldHide{
self.lblUsername.hidden = shouldHide;
self.lblEmail.hidden = shouldHide;
self.profilePicture.hidden = shouldHide;
self.loggedinwallpaper.hidden = shouldHide;
self.FBlogout.hidden = shouldHide;
}
-(void)toggleUnhiddenState:(BOOL)shouldShow{
self.loggedinwallpaper.hidden = NO;
}
-(void)loginViewShowingLoggedInUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = @"";
[self toggleHiddenState:NO];
[self toggleUnhiddenState:YES];
}
-(void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView{
self.lblLoginStatus.text = @"";
[self toggleHiddenState:YES];
}
-(void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user{
NSLog(@"%@", user);
self.profilePicture.profileID = user.objectID;
self.lblUsername.text = user.name;
self.lblEmail.text = [user objectForKey:@"email"];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *homeViewController = (UIViewController *)[storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
[self presentViewController:homeViewController animated:YES completion:nil];
//
// for (NSObject *obj in [self.profilePicture subviews]) {
// if ([obj isMemberOfClass:[UIImageView class]]) {
// UIImageView *objImg = (UIImageView *)obj;
// image = objImg.image;
// break;
// }
// }
}
-(void)loginView:(FBLoginView *)loginView handleError:(NSError *)error{
NSLog(@"%@", [error localizedDescription]);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
//- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// UIImage *image = _profilePicture;
// HomeViewController *homeviewController = (HomeViewController *)segue.destinationViewController;
// homeviewController.homepic = image;
//
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
//}
@end
旗帜解决了它,但现在我得到了这些:
undefined reference to `curl_easy_init'
undefined reference to `curl_easy_setopt'
undefined reference to `curl_easy_setopt'
undefined reference to `curl_easy_perform'
undefined reference to `curl_easy_strerror'
undefined reference to `curl_easy_cleanup'
我被困在这里,我不知道如何解决这个未解决的外部符号。
任何人都可以帮助我吗?谢谢
答案 0 :(得分:0)
可能是您正在链接错误版本的kernel32.lib。你做x64构建吗? 如果是这样,您需要更正库路径。
答案 1 :(得分:0)
解决方案:
github存储库.bat文件存在问题,似乎只适用于最新的VS版本。我使用了较旧版本的build.bat并且工作正常。
供参考:使用VS 2005编译。