Return-Path: Delivered-To: apmail-logging-log4cxx-user-archive@www.apache.org Received: (qmail 40827 invoked from network); 7 May 2010 13:27:03 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 May 2010 13:27:03 -0000 Received: (qmail 42059 invoked by uid 500); 7 May 2010 13:27:03 -0000 Delivered-To: apmail-logging-log4cxx-user-archive@logging.apache.org Received: (qmail 42020 invoked by uid 500); 7 May 2010 13:27:03 -0000 Mailing-List: contact log4cxx-user-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4CXX User" List-Id: Delivered-To: mailing list log4cxx-user@logging.apache.org Received: (qmail 42012 invoked by uid 99); 7 May 2010 13:27:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 May 2010 13:27:02 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fabian.jacquet@gmail.com designates 209.85.161.47 as permitted sender) Received: from [209.85.161.47] (HELO mail-fx0-f47.google.com) (209.85.161.47) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 May 2010 13:26:56 +0000 Received: by fxm11 with SMTP id 11so690990fxm.34 for ; Fri, 07 May 2010 06:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=N0PwBag/p+EptbRPHiHDu3anyEiSgMIe+vPG73KNfeg=; b=fNOfgIFA/YvdLsvBT5MLE8Ml6hfYFfb8RsavYNRyMif1+ZhH8kB+c2gZs8z+l6Fj2q /Jqzasi94mz/Lh/1X7YmE8MzG46HzWzj8YvmaaYUkcOan09LGZoXEJlNh51UNDfpRuqK +I6mqBj3Rc6nihOUAPjHEftPitJHKdPUUP3S0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=xvLMfU9eWq+WEE1UB8fA7UGpwtHzTNhojSwHPmPyUSNnYIHPv1r/Rul3BNqISFtdiI IZH3V4BzDxS9SY56ECllks0wxTEXveAxFCJH9oSTaj3WVWgtWwzJBCoVZWWZ5QLB4RPz jHXOarLhLOXx5dPnQmgSVhaMT0YN3CJhZ81j4= MIME-Version: 1.0 Received: by 10.239.147.196 with SMTP id c4mr5136hbb.82.1273238794627; Fri, 07 May 2010 06:26:34 -0700 (PDT) Received: by 10.239.146.12 with HTTP; Fri, 7 May 2010 06:26:34 -0700 (PDT) In-Reply-To: References: <783EAA15-5A6B-4693-AFC3-42C3CE256658@mac.com> Date: Fri, 7 May 2010 15:26:34 +0200 Message-ID: Subject: Re: link error in release mode with Visual Studio 2008 From: Fabian Jacquet To: Log4CXX User Content-Type: multipart/alternative; boundary=001485f6d4ac116a140486010265 --001485f6d4ac116a140486010265 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Why my boss don't want I develop for MacOS X ? :-) The class d=E9claration must be __declspec(export) when you compile the dll and must be __declspec(import) when you include .h from this dll. So it's correct in your error message. It's possible that the missing symbols declarations didn't have __declspec(export) when you compiled log4cxx.dll Did you take sources from SVN? I compiled the source downloaded from the we= b site with VisualStudio 2008 without any problem. On Fri, May 7, 2010 at 14:12, Jean-Denis Muys wrote: > When setting the linker verbose, it indeed reports that it is searching > log4cxx.lib. > When setting fully verbose, it even reports *finding* symbols in > log4cxx.lib with the file that references them. > So indeed, the linker finds log4cxx.lib AND manages to find some of the > symbols I use. > Also, it seems that all the found symbols have a __thiscall declaration, > while all the ones that are *not* found have a __stdcall declaration. > > I have no idea whether this has any significance. > > regarding the __declspec thing, I noticed that the linker says the symbol= s > it cannot find are __declspec(import), not __declspec(export). What are t= he > differences between these two? Could it be that the "export" variations a= re > in the log4cxx.lib file but cannot be matched to the "import" variation i= t's > looking for? > > > Why is the Windows platform so poorly designed? None of those charades ar= e > necessary on the BSD architecture that MacOS X is built upon! > > > I am not sure what I can do next. I'll try to look for those symbols in t= he > log4cxx source to check their declarations. > > Jean-Denis > > > > On May 7, 2010, at 12:02 , Fabian Jacquet wrote: > > Mh, maybe those symbols are in the DLL but not in the lib. To be in the > lib, it must have __declspec(dllexport) when compiling. > log4cxx use this define to do this: > #if defined(LOG4CXX_STATIC) > #define LOG4CXX_EXPORT > // definitions used when building DLL > #elif defined(LOG4CXX) > #define LOG4CXX_EXPORT __declspec(dllexport) > #else > // definitions used when using DLL > #define LOG4CXX_EXPORT __declspec(dllimport) > #endif > > So, "LOG4CXX_EXPORT __declspec(dllexport)" when compiling log4cxx.dll > and > "LOG4CXX_EXPORT __declspec(dllimport)" when including log4cxx.h from your > project. > > If for some reason, LOG4CXX_STATIC is defined, it's possible that some > symbols are not exported. But I don't know how it's possible. > > If you don't use more than those 13 symbols maybe nothing is exported or > maybe the link don't use log4cxx.lib. > You can check the list of lib used by the linker like this: > Project properties>Linker>General>Show Progress =3D /VERBOSE:LIB > The linker will dump the lib list in the output window of visual studio > when compiling. Check that you have something like that: > 1> Searching [your directories]\log4cxx.lib: > > I don't know any tools to check symbols. I think you could check with > notepad, you can search about "getLogger" by example but if you find it, = I > don't know if you can conclude that the symbol is right exported. If you > don't find it, I think the problem comes from the lib :-) > > On Fri, May 7, 2010 at 11:08, Jean-Denis Muys wrote: > >> Thanks for answering. I wish the solution was that simple. I apologize f= or >> not explicitly mentioning it, but my project is - I think - set up >> correctly. >> >> That is: >> >> - both the Debug and Release configurations mention log4cxx.lib in its >> Linker>Input>Additional Dependencies >> - both the Debug and Release configurations mention a *different* >> directory in Linker>General>Additional Library Directories. They are >> different because they point to the Debug version and the Relase version= of >> loc4cxx respectively (apache-log4cxx-0.10.0\projects\Debug >> and apache-log4cxx-0.10.0\projects\Release) >> >> >> Of course both configurations of log4cxx were previously built with no >> failure (from its Visual Studio project). They were built in "DLL" mode = as >> explained on the log4cxx web site. While doing a static library version = is >> on my todo list, I'd rather solve the present issue first. >> >> At this point in time, I suppose the 13 missing symbols are present in t= he >> Debug version of the log4cxx.lib stub library, but not in the Release >> version. How can I verify this hypothesis? What could explain that? How = can >> I fix it? >> >> Another hypothesis might be that there is yet another dependency that >> needs to be set in Release mode only. This seems less plausible though. = And >> what would it be? >> >> Again, thanks for you answer. Any other idea on how I could make progres= s >> on this issue? >> >> Regards, >> >> Jean-Denis >> >> >> On May 7, 2010, at 10:29 , Fabian Jacquet wrote: >> >> Hi, >> >> The project configuration is different between debug and release. In deb= ug >> you certainly added log4cxx.lib in the field "Linker/Input/Additional >> dependencies" but you have a drop-down which select the configuration, i= f >> you switch to release, I think you don't have log4cxx.lib in "Additional >> dependencies" . >> >> Don't forget to add the directory of this lib in the field >> "Linker/General/Additional Library Directories" >> >> log4cxx.lib is not really a static lib. It's only the interface to the d= ll >> class and functions. >> >> I hope it help you. >> >> On Fri, May 7, 2010 at 04:00, Jean-Denis Muys wrote: >> >>> Hi, >>> >>> I have a Visual Studio 2008 project using log4cxx that links (and runs) >>> fine in Debug mode using the Debug version of log4cxx, but fails to lin= k in >>> Release mode using the release version of log4cxx. Here are the 13 unde= fined >>> symbols: >>> >>> >>> 1>------ Build started: Project: RepliKator04, Configuration: Release >>> Win32 ------ >>> 1>Linking... >>> 1> Creating library >>> z:\PCdev\RepliKator2004\RK_Demo_2004\plugins\RepliKator04.bundle\conten= ts\windows\RepliKator04.lib >>> and object >>> z:\PCdev\RepliKator2004\RK_Demo_2004\plugins\RepliKator04.bundle\conten= ts\windows\RepliKator04.exp >>> 1>RKConnector.obj : error LNK2001: unresolved external symbol >>> "__declspec(dllimport) public: static class >>> log4cxx::helpers::ObjectPtrT __stdcall >>> log4cxx::Level::getTrace(void)" (__imp_?getTrace@Level@log4cxx@ >>> @SG?AV?$ObjectPtrT@VLevel@log4cxx@@@helpers@2@XZ) >>> [...] >>> 1>RepliKator04 - 13 error(s), 0 warning(s) >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Build: 0 succeeded, 1 failed, 0 up-to-da= te, 0 skipped >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> >>> >>> As I am a Mac developer, not a Windows developer, I feel lost here. Wha= t >>> can I do to fix that issue? I really don't get why those symbols would = not >>> be defined in Release mode. >>> >>> Note that my project is not an application, but a Plugin for a third >>> party app. >>> I link against the DLL version of log4cxx. I'd rather use a static >>> library version, but I failed to build it so, and I could not find deta= iled >>> instructions on the net to do it. >>> >>> So for the time being, I am mainly interested in understanding why thes= e >>> link-time errors occur, and in how to fix them. >>> >>> Thanks and regards. >>> >>> Jean-Denis >>> >>> >> >> > > --001485f6d4ac116a140486010265 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
<venting frustration>
Why my boss don't want I dev= elop for MacOS X ? :-)
</venting=20 frustration>

The class d=E9claration must be __declspec(export)= when you compile the dll and must be __declspec(import) when you include .= h from this dll. So it's correct in your error message.
It's pos= sible that the missing symbols declarations didn't have __declspec(expo= rt) when you compiled log4cxx.dll

Did you take sources from SVN? I compiled the source downloaded from th= e web site with VisualStudio 2008 without any problem.


On Fri, May 7, 2010 at 14:12, Jean-Denis Muys <jdmuys@mac.com> wrote:
When setting the linker verbose, it indeed reports tha= t it is searching log4cxx.lib.
When setting fully verbose, it even reports *finding* symbols in log4cxx.li= b with the file that references them.
So indeed, the linker finds= log4cxx.lib AND manages to find some of the symbols I use.
Also,= it seems that all the found symbols have a __thiscall declaration, while a= ll the ones that are *not* found have a __stdcall declaration.

I have no idea whether this has any significance.
=

regarding the=A0__declspec thing, I noticed that the li= nker says the symbols it cannot find are=A0__declspec(import), not=A0__decl= spec(export). What are the differences between these two? Could it be that = the "export" variations are in the=A0log4cxx.lib file but cannot = be matched to the "import" variation it's looking for?

<venting frustration>
Why is the Window= s platform so poorly designed? None of those charades are necessary on the = BSD architecture that MacOS X is built upon!
</venting fr= ustration>

I am not sure what I can do next. I'll try to look = for those symbols in the log4cxx source to check their declarations.
<= div>
Jean-Denis



On May 7, 2010, at 12:02 , Fabian Jacquet wrote:

Mh, maybe those symbols are in the DLL but not in the lib. T= o be in the lib, it must have __declspec(dllexport) when compiling.
log4cxx use this define to do this:
#if defined(LOG4CXX_STATIC)
#defi= ne LOG4CXX_EXPORT
//=A0=A0 definitions used when building DLL
#elif defined(LOG4CXX)
#d= efine LOG4CXX_EXPORT __declspec(dllexport)
#else
//=A0=A0=A0 definiti= ons used when using DLL
#define LOG4CXX_EXPORT __declspec(dllimport)
= #endif

So, "LOG4CXX_EXPORT __declspec(dllexport)" when compiling log= 4cxx.dll
and
"LOG4CXX_EXPORT __declspec(dllimport)" when in= cluding log4cxx.h from your project.

If for some reason, LOG4CXX_STA= TIC is defined, it's possible that some symbols are not exported. But I= don't know how it's possible.

If you don't use more than those 13 symbols maybe nothing is export= ed or maybe the link don't use log4cxx.lib.
You can check the list o= f lib used by the linker like this:
Project properties>Linker>Gene= ral>Show Progress =3D /VERBOSE:LIB
The linker will dump the lib list in the output window of visual studio whe= n compiling. Check that you have something like that:
1>=A0=A0=A0 Sea= rching [your directories]\log4cxx.lib:

I don't know any tools to= check symbols. I think you could check with notepad, you can search about = "getLogger" by example but if you find it, I don't know if yo= u can conclude that the symbol is right exported. If you don't find it,= I think the problem comes from the lib :-)

On Fri, May 7, 2010 at 11:08, Jean-Denis Muy= s <jdmuys@mac.com> wrote:
Thanks for answering. I wish the= solution was that simple. I apologize for not explicitly mentioning it, bu= t my project is - I think - set up correctly.

That= is:

- both the Debug and Release configurations mention=A0l= og4cxx.lib in its Linker>Input>Additional Dependencies
- bo= th the=A0Debug and Release configurations mention a *different* directory i= n Linker>General>Additional Library Directories. They are different b= ecause they point to the Debug version and the Relase version of loc4cxx re= spectively (apache-log4cxx-0.10.0\projects\Debug and=A0apache-log4cxx-0.10.= 0\projects\Release)


Of course both configurations of log4cxx were= previously built with no failure (from its Visual Studio project). They we= re built in "DLL" mode as explained on the log4cxx web site. Whil= e doing a static library version is on my todo list, I'd rather solve t= he present issue first.

At this point in time, I suppose the 13 missing symbols are = present in the Debug version of the log4cxx.lib stub library, but not in th= e Release version. How can I verify this hypothesis? What could explain tha= t? How can I fix it?

Another=A0hypothesis=A0might be that there is yet anoth= er dependency that needs to be set in Release mode only. This seems less pl= ausible though. And what would it be?

Again, thank= s for you answer. Any other idea on how I could make progress on this issue= ?

Regards,

Jean-Denis
=

On May 7, 2010, at 10:29 , Fabian Jacquet wrote= :

Hi,

The project configuration is different between debug and release. In de= bug you certainly added log4cxx.lib in the field "Linker/Input/Additio= nal dependencies" but you have a drop-down which select the configurat= ion, if you switch to release, I think you don't have log4cxx.lib in &q= uot;Additional dependencies" .

Don't forget to add the directory of this lib in the field "Li= nker/General/Additional Library Directories"

log4cxx.lib is no= t really a static lib. It's only the interface to the dll class and fun= ctions.

I hope it help you.

On Fri= , May 7, 2010 at 04:00, Jean-Denis Muys <jdmuys@mac.com> wrote:=
Hi,

I have a Visual Studio 2008 project using log4cxx that links (and runs) fin= e in Debug mode using the Debug version of log4cxx, but fails to link in Re= lease mode using the release version of log4cxx. Here are the 13 undefined = symbols:


1>------ Build started: Project: RepliKator04, Configuration: Release Wi= n32 ------
1>Linking...
1> =A0 Creating library z:\PCdev\RepliKator2004\RK_Demo_2004\plugins\Rep= liKator04.bundle\contents\windows\RepliKator04.lib and object z:\PCdev\Repl= iKator2004\RK_Demo_2004\plugins\RepliKator04.bundle\contents\windows\RepliK= ator04.exp
1>RKConnector.obj : error LNK2001: unresolved external symbol "__de= clspec(dllimport) public: static class log4cxx::helpers::ObjectPtrT<clas= s log4cxx::Level> __stdcall log4cxx::Level::getTrace(void)" (__imp_= ?getTrace@Level@log4cxx@@SG?AV?$ObjectPtrT@VLevel@log4cxx@@@helpers@2@XZ) [...]
1>RepliKator04 - 13 error(s), 0 warning(s)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Build: 0 succeeded, 1 failed, 0 up-to-date, = 0 skipped =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


As I am a Mac developer, not a Windows developer, I feel lost here. What ca= n I do to fix that issue? I really don't get why those symbols would no= t be defined in Release mode.

Note that my project is not an application, but a Plugin for a third party = app.
I link against the DLL version of log4cxx. I'd rather use a static libr= ary version, but I failed to build it so, and I could not find detailed ins= tructions on the net to do it.

So for the time being, I am mainly interested in understanding why these li= nk-time errors occur, and in how to fix them.

Thanks and regards.

Jean-Denis






--001485f6d4ac116a140486010265--