Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Libcurl lesson 2 compiling static Library

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1 compile libcurl static library

Make sure that the code generation / runtime under the Cpicrates + page is consistent with the solution, and that the output path and target file name are normally (d).

2 preprocessor property page settings definition in the C _ blank + property page

_ DEBUG

BUILDING_LIBCURL

DEBUGBUILD

CURL_STATICLIB

USE_WINDOWS_SSPI

USE_SCHANNEL

The two precompiled processing definitions, USE_WINDOWS_SSPI and USE_SCHANNEL, are used to define HTTPS, which need to be specified in order to use the https protocol.

3 call the preprocessor property page setting definition in the property page of the project CumberCraft +.

BUILDING_LIBCURL

CURL_STATICLIB

Because the macro definition is mainly used in the curl/curl.h header file, for the conditional compilation of the macro definition of the header file, these two macro definitions must be defined, otherwise the compilation error will be found and the error analysis will be found.

2 Link error analysis

1) error LNK2019: unparsed external symbol _ _ imp__curl_easy_init, which is referenced in the function _ main

Analysis: the CURL_STATICLIB compilation result is not defined because CURL_EXTERN CURL * curl_easy_init (void); function is preceded by a CURL_EXTERN definition, which is defined in the

# ifdef CURL_STATICLIB

# define CURL_EXTERN

# elif defined (WIN32) | | defined (_ WIN32) | | defined (_ _ SYMBIAN32__)

# if defined (BUILDING_LIBCURL)

# define CURL_EXTERN _ _ declspec (dllexport)

# else

# define CURL_EXTERN _ _ declspec (dllimport)

# endif

# elif defined (BUILDING_LIBCURL) & & defined (CURL_HIDDEN_SYMBOLS)

# define CURL_EXTERN CURL_EXTERN_SYMBOL

# else

# define CURL_EXTERN

# endif

It is defined here that if CURL_STATICLIB is not defined, it will cause CURL_EXTERN to be replaced with _ _ declspec (dllexport) or _ _ declspec (dllimport). These two declarations apply only to dynamic links, not to static links.

2) error LNK2019: unparsed external symbol _ _ imp__ldap_init, which is referenced in the function _ _ ldap_free_urldesc

Add an additional static library Crypt32.lib,Wldap32.lib to the properties of the referenced project, otherwise the following error occurs because https is used

3) C2371 "curl_share_init": redefined; different base types libcurl

Looking at the source code, if the BUILDING_LIBCURL is not defined, it will lead to the problem of inconsistent return types in the declaration and definition of curl_share_init.

# if defined (BUILDING_LIBCURL) | | defined (CURL_STRICTER)

Typedef struct Curl_easy CURL

Typedef struct Curl_share CURLSH

# else

Typedef void CURL

Typedef void CURLSH

# endif

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report