You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by "Eberhard, Markus (external)" <Ma...@eads.com> on 2008/07/15 08:25:55 UTC

Build log4cxx as static library using MS Visual Studio 2003

Hello *,

I ma trying to build log4cxx as static library using MS Visual Studio
2003, but it doesn't work. I have opened the project log4cxx.dsw of the
log4cxx package, converted it to a MS Visual Studio 2003 project, set
the project "log4cxx" as start-up project and changed two properties:

- build "static library" not "dynamic library"

-  and the pre-processor definition "LOG4CXX" to "LOG4CXX_STATIC"

 

When linking during the build process I get 544 warnings like the
followings:

apr-1.lib(dir.obj) : warning LNK4006: _apr_os_dir_put@12 already defined
in aprutil-1.lib(dir.obj); second definition ignored

apr-1.lib(fileacc.obj) : warning LNK4006: _apr_file_name_get@8 already
defined in aprutil-1.lib(fileacc.obj); second definition ignored

 

Linking my own test project with the build static library results in the
following errors:

log4cxx.lib(start.obj) : error LNK2019: unresolved external symbol
__imp__WSACleanup@0 referenced in function _apr_initialize@0

log4cxx.lib(start.obj) : error LNK2019: unresolved external symbol
__imp__WSAStartup@8 referenced in function _apr_initialize@0

log4cxx.lib(apr_snprintf.obj) : error LNK2019: unresolved external
symbol __imp__ntohl@4 referenced in function _conv_in_addr

log4cxx.lib(sockaddr.obj) : error LNK2001: unresolved external symbol
__imp__ntohl@4

log4cxx.lib(sockaddr.obj) : error LNK2019: unresolved external symbol
__imp__htons@4 referenced in function _apr_sockaddr_vars_set

...

 

What have I to do to get the static library running? Please help.

 

Thanks 

Markus 

 


Re: Build log4cxx as static library using MS Visual Studio 2003

Posted by Curt Arnold <ca...@apache.org>.
On Jul 15, 2008, at 1:25 AM, Eberhard, Markus (external) wrote:

> Hello *,
> I ma trying to build log4cxx as static library using MS Visual  
> Studio 2003, but it doesn’t work. I have opened the project  
> log4cxx.dsw of the log4cxx package, converted it to a MS Visual  
> Studio 2003 project, set the project “log4cxx” as start-up project  
> and changed two properties:
> - build “static library” not “dynamic library”
> -  and the pre-processor definition “LOG4CXX” to “LOG4CXX_STATIC”
>
> When linking during the build process I get 544 warnings like the  
> followings:
> apr-1.lib(dir.obj) : warning LNK4006: _apr_os_dir_put@12 already  
> defined in aprutil-1.lib(dir.obj); second definition ignored
> apr-1.lib(fileacc.obj) : warning LNK4006: _apr_file_name_get@8  
> already defined in aprutil-1.lib(fileacc.obj); second definition  
> ignored
>
> Linking my own test project with the build static library results in  
> the following errors:
> log4cxx.lib(start.obj) : error LNK2019: unresolved external symbol  
> __imp__WSACleanup@0 referenced in function _apr_initialize@0
> log4cxx.lib(start.obj) : error LNK2019: unresolved external symbol  
> __imp__WSAStartup@8 referenced in function _apr_initialize@0
> log4cxx.lib(apr_snprintf.obj) : error LNK2019: unresolved external  
> symbol __imp__ntohl@4 referenced in function _conv_in_addr
> log4cxx.lib(sockaddr.obj) : error LNK2001: unresolved external  
> symbol __imp__ntohl@4
> log4cxx.lib(sockaddr.obj) : error LNK2019: unresolved external  
> symbol __imp__htons@4 referenced in function _apr_sockaddr_vars_set
> …
>
> What have I to do to get the static library running? Please help.
>
> Thanks
> Markus
>

Add advapi32.lib, mswsock.lib, ws2_32.lib and shell32.lib to the  
libraries used in the link step.  log4cxx.dll is dependent on those  
system libraries.  When you link with the static library, you also  
have to include the libraries dependencies.