Qiniu the use of the VS import Lib Static library in a Windows system environment

Source: Internet
Author: User

I believe that a lot of people have some doubts about the introduction of Lib library, I give you a demonstration here, here I am based on the new project as the foundation to start building.

1, the C + + project steps in creating a VS integrated development environment are sequentially

2. Download the static library file for the seven KN C SDK

Http://developer.qiniu.com/code/v6/sdk/cpp.html

After downloading the file decompression, you will see two folders, a folder for the dynamic library, a folder for the static library
But I will report a mistake like this in the test.

error LNK1104: 无法打开文件“curllib.lib”

So you can be in the Lib folder of the static library, add a file, the file download link for

Http://liuhanlin-work.qiniudn.com/curllib.lib

So the full Lib library contains the following files

3. Import the static library to open the project properties, prepare the configuration

First need to configure VC + + directory (divided into--including directory, library directory)

The contents of the containing directory select Edit, import the directory, you need to import the directory contains the following items

The library directory contains a directory that is the Lib static library

You then need to configure the input options in the linker

Fill in the content including

4, the environment is configured successfully

Write code in the Mian function of your entrance

//Win-c-true.cpp: Defines the entry point of the console application. //#include "stdafx.h"#include "io.h"#include "resumable_io.h"#include "rs.h"#include "base.h"#include <stdio.h>/*debug function * /voidDebuginfo (qiniu_client* Client, Qiniu_error err) {printf("\nerror Code:%d, message:%s\n", Err.code, Err.message);printf("Response header:\n%s", Qiniu_buffer_cstr (&client->respheader));printf("Response body:\n%s", Qiniu_buffer_cstr (&client->b));printf("\n\n\n");}/ * Get token*/of uploaded filesChar* Uploadtoken (Const Char* Bucket, qiniu_mac* Mac) {Qiniu_rs_putpolicy putpolicy;    Qiniu_zero (Putpolicy); Putpolicy.scope = bucket;returnQiniu_rs_putpolicy_token (&putpolicy, Mac);}/ * Get the URL of the downloaded file token*/Char* DownloadURL (Const Char* Domain,Const Char* Key, qiniu_mac* Mac) {Char* URL =0;Char* BaseUrl =0;    Qiniu_rs_getpolicy GetPolicy;    Qiniu_zero (GetPolicy);    BASEURL = Qiniu_rs_makebaseurl (domain, key);    url = qiniu_rs_getpolicy_makerequest (&getpolicy, BaseUrl, Mac); Qiniu_free (BASEURL);returnURL;}voidDemogetfilestat (qiniu_client* pclient,Const Char* Bucketname,Const Char* KeyName) {/ * If the Qiniu account store has a bucket name referred to as bucketname string, this bucket has the name of the string KeyName refers to the file, * the following method, query KeyName file information */Qiniu_rs_statret Statret; Qiniu_error Error = Qiniu_rs_stat (pclient, &statret, Bucketname, keyName);/ * Determine the HTTP return value * /    if(Error.code! = $)    {/ * Not 200, incorrect return * /        printf("Get file%s:%s stat error.\n", Bucketname, KeyName);    Debuginfo (pclient, error); }Else{/*200, correctly returned, you can query some information about this file through the statret variable * /         printf("Get file%s:%s stat success.\n", Bucketname, KeyName); }}voidDemomovefile (qiniu_client* pclient,Const Char* Bucketname,Const Char* SRC,Const Char* dest) {/ * Assuming that the Qiniu account is stored under a bucket name called Bucketname, this bucket is known as the src file, * This is the following method, the renamed Sub-SRC is dest * /Qiniu_error Error = Qiniu_rs_move (pclient, Bucketname, SRC, bucketname, dest);if(Error.code! = $)    {printf("Rename file from%s:%s to%s:%s error.\n", Bucketname, SRC, bucketname, dest);    Debuginfo (pclient, error); }Else{printf("Rename file from%s:%s to%s:%s success.\n", Bucketname, SRC, bucketname, dest); }/ * Reverse operation renamed above * /Error = Qiniu_rs_move (pclient, Bucketname, dest, Bucketname, SRC);if(Error.code! = $)    {printf("Rename file from%s:%s to%s:%s error.\n", Bucketname,dest, Bucketname, SRC);    Debuginfo (pclient, error); }Else{printf("Rename file from%s:%s to%s:%s success.\n", Bucketname, dest, Bucketname, SRC); }}voidDemocopyfile (qiniu_client* pclient,Const Char* Bucketname,Const Char* SRC,Const Char* dest) {*/* Assuming that the Qiniu account store has a bucket name called Bucketname, this bucket has src file, * then this method, copy src to dest * /Qiniu_error Error = qiniu_rs_copy (pclient, Bucketname, SRC, bucketname, dest);if(Error.code! = $)    {printf("Copy file from%s:%s to%s:%s error.\n", Bucketname, SRC, bucketname, dest);    Debuginfo (pclient, error); }Else{printf("Copy file from%s:%s to%s:%s success.\n", Bucketname, SRC, bucketname, dest); }}voidDemodeletefile (qiniu_client* pclient,Const Char* Bucketname,Const Char* KeyName) {*/* Assuming that the Qiniu account store has a bucket name called Bucketname, this bucket has keyName file, * then this method, delete keyName * /Qiniu_error Error = Qiniu_rs_delete (pclient, Bucketname, keyName);if(Error.code! = $)    {printf("Delete file%s:%s error.\n", Bucketname, KeyName);    Debuginfo (pclient, error); }Else{printf("Delete file%s:%s success.\n", Bucketname, KeyName); }}voidDemobatchstatfiles (qiniu_client* pclient,Const Char* Bucketname) {/ * Assuming that the bucket name in the Qiniu account store is called Bucketname, there are batch files under this bucket * This demo function demonstrates how to get seven Qiniu stored file information in bulk * /Qiniu_rs_entrypath entrypath[] = {{Bucketname,"1.txt"}, {bucketname,"2.txt"}, {bucketname,"3.txt"}, {bucketname,"4.txt"}, {bucketname,"5.txt"},                                       };intLen =sizeof(Entrypath)/sizeof(Qiniu_rs_entrypath); qiniu_rs_batchstatret* rets = (qiniu_rs_batchstatret*)calloc(Len,sizeof(Qiniu_rs_batchstatret)); Qiniu_error Error = Qiniu_rs_batchstat (pclient, RETs, Entrypath, Len);if( $! = Error.code) {printf("Get files stat error.\n");    Debuginfo (pclient, error); }Else{printf("Get files stat success.\n"); } Free(RETs);}voidDemobatchcopyfiles (qiniu_client* pclient,Const Char* bucketname) {Qiniu_rs_entrypathpair entrypathpair1[] ={{{bucketname,"1.txt"}, {bucketname,"1_copy.txt"}}, {{bucketname,"2.txt"}, {bucketname,"2_copy.txt"}}, {{bucketname,"3.txt"}, {bucketname,"3_copy.txt"}}, {{bucketname,"4.txt"}, {bucketname,"4_copy.txt"}}, {{bucketname,"5.txt"}, {bucketname,"5_copy.txt"}},                                             };intLen =sizeof(ENTRYPATHPAIR1)/sizeof(Qiniu_rs_entrypathpair); qiniu_rs_batchitemret* itemrets = (qiniu_rs_batchitemret*)calloc(Len,sizeof(Qiniu_rs_batchitemret)); Qiniu_error Error = qiniu_rs_batchcopy (pclient, Itemrets, EntryPathpair1, Len);if( $! = Error.code) {printf("Copy files error.\n");    Debuginfo (pclient, error); }Else{printf("Copy files success.\n"); } qiniu_free (itemrets);}voidDemobatchdeletefiles (qiniu_client* pclient,Const Char* bucketname) {Qiniu_rs_entrypath entrypath1[] = {{Bucketname,"1_copy.txt"}, {bucketname,"2_copy.txt"}, {bucketname,"3_copy.txt"}, {bucketname,"4_copy.txt"}, {bucketname,"5_copy.txt"},                                      };intLen =sizeof(ENTRYPATH1)/sizeof(Qiniu_rs_entrypath); qiniu_rs_batchitemret* itemrets = (qiniu_rs_batchitemret*)calloc(Len,sizeof(Qiniu_rs_batchitemret)); Qiniu_error Error = Qiniu_rs_batchdelete (pclient, Itemrets, EntryPath1, Len);if( $! = Error.code) {printf("Delete Files error.\n");    Debuginfo (pclient, error); }Else{printf("Delete Files success.\n"); } qiniu_free (itemrets);}voidDemouploadfile (qiniu_client* pclient,Const Char* Bucketname, qiniu_mac* Mac) {Const Char* Uploadname ="TESTUPLOAD1.HPP";/ * Get uploadkey*/    Const Char* Uploadtoken = Uploadtoken (Bucketname, Mac);Const Char* Plocalfilepath ="C:\\3RDLIB\\OPERATORS.HPP";    Qiniu_io_putret Putret; Qiniu_error Error = Qiniu_io_putfile (pclient, &putret, Uploadtoken, Uploadname, Plocalfilepath, NULL);if(Error.code! = $)     {printf("Upload File%s to%s:%s error.\n", Plocalfilepath, Bucketname, uploadname);    Debuginfo (pclient, error); }Else{printf("Upload File%s to%s:%s success.\n", Plocalfilepath, Bucketname, uploadname); }//Qiniu_free (Uploadtoken);}voidDemogetdownloadurl (Const Char* Bucketname, qiniu_mac* Mac) {Char* domain = QINIU_STRING_CONCAT2 (bucketname,". u.qiniudn.com");Const Char* Downloadname ="TESTUPLOAD1.HPP";Char* PUrl = DownloadURL (domain, downloadname, MAC);if(0= = PUrl) {printf("Get URL%s:%s error.\n", Bucketname, Downloadname); }Else{printf("Get URL%s:%s is%s.\n", Bucketname, Downloadname, PURL);    } qiniu_free (PURL); Qiniu_free (domain);}int_tmain (intARGC, _tchar* argv[]) {qiniu_client Client; Qiniu_mac Mac;Char* Bucketname ="Qiniu-demo-test"; Mac.accesskey ="Og9utrj8i83ndeldqrzlpjxs8hwtiqvmv2s_v7d1"; Mac.secretkey ="OGUSG0NVSCCLTRLKCI08QY48DAM-UC7MQJSWRPE0";//InitializeQiniu_servend_init (-1); Qiniu_client_initmacauth (&client,1024x768, &mac);/ * This method shows how to get information about a file that is stored in seven Qiniu * /Demogetfilestat (&client, Bucketname,"A.txt");/ * This method shows how to change the name of a file stored in seven Qiniu * /Demomovefile (&client, Bucketname,"A.txt","B.txt");/ * This method shows how to copy a file of seven Qiniu storage * /Democopyfile (&client, Bucketname,"A.txt","A_back.txt");/ * This method shows how to delete a file of seven Qiniu storage * /Demodeletefile (&client, Bucketname,"A_back.txt");/ * This method shows how to get the information of seven Qiniu storage files in bulk * /Demobatchstatfiles (&client, bucketname);/ * This method shows how to bulk copy the seven Qiniu storage files * /Demobatchcopyfiles (&client, bucketname);/ * This method shows how to bulk delete the seven Qiniu storage files * /Demobatchdeletefiles (&client, bucketname);/ * This method shows how to upload a local file to the server * /Demouploadfile (&client, Bucketname, &mac);/ * This method shows how to get a file on a server, download url*/Demogetdownloadurl (Bucketname, &mac);//anti-initializationQiniu_client_cleanup (&client); Qiniu_servend_cleanup ();return 0;return 0;}

Caution: It is important to note that the compilation environment I configured is in debug mode. The cut to release mode requires reconfiguration.

Run results

Qiniu the use of the VS import Lib Static library in a Windows system environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.