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 Javier <xa...@yahoo.com.ar> on 2005/09/07 23:41:45 UTC

Linking problem



Hi All

I'm trying to compile my first C++ app using log4cxx and I got the
following errors (using VC++ 6)

inking...
MyPrueba.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall log4cxx::Logger::forcedLog(class log4cxx::helpers::ObjectPtrT<class log4cxx::Level> const &,class std::basic_string<char,struct std::char_traits<
char>,class std::allocator<char> > const &,char const *,int)" (__imp_?forcedLog@Logger@log4cxx@@QAEXABV?$ObjectPtrT@VLevel@log4cxx@@@helpers@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBDH@Z)
MyPrueba.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl log4cxx::PropertyConfigurator::configure(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (_
_imp_?configure@PropertyConfigurator@log4cxx@@SAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
Debug/prueba.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

prueba.exe - 3 error(s), 0 warning(s)


How could I fix it ?


Also, how could I know wich libs/files should I deploy with my exe
app ?

Thanks in advance

J




-- 
Javier


Re[2]: Linking problem

Posted by Javier <xa...@yahoo.com.ar>.
On 08/09/2005 at 7:53 Andreas Fester wrote:

>
>This looks like the log4cxx.lib link library is not linked with your
>project. Are you sure that you added it to the libraries of your project?
>Otherwise, please post a minimal source code example, like
>


Hi 

Thanks for your reply.

I'm trying to compile the following code:

-------------
// include log4cxx header files.
#include <log4cxx/logger.h>
#include <log4cxx/basicconfigurator.h>
#include <log4cxx/propertyconfigurator.h>
#include <log4cxx/helpers/exception.h>

using namespace log4cxx;
using namespace log4cxx::helpers;

// Define a static logger variable so that it references the
// Logger instance named "MyApp".
LoggerPtr logger(Logger::getLogger("MyApp"));

int main(int argc, char **argv)
{
       int result = EXIT_SUCCESS;
        try
        {
                if (argc > 1)
                {
                        // BasicConfigurator replaced with
PropertyConfigurator.
                        PropertyConfigurator::configure(argv[1]);
                }
                else
                {
                        BasicConfigurator::configure();
                }

                LOG4CXX_INFO(logger, "Entering application.");
                LOG4CXX_INFO(logger, "Exiting application.");
        }
        catch(Exception&)
        {
                result = EXIT_FAILURE;
        }

        return result;
}

----------------

I've copied log4cxx "include" folder to my project folder and passed this
path as parameter to compiler with /I. Then I copied log4cxx.lib to my
project folder and added to linker options.

Nevertheless I get the message:

Linking...
MyPrueba.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __thiscall
log4cxx::Logger::forcedLog(class log4cxx::helpers::ObjectPtrT<class
log4cxx::Level> const &,class std::basic_string<char,struct
std::char_traits<
char>,class std::allocator<char> > const &,char const *,int)"
(__imp_?forcedLog@Logger@log4cxx@@QAEXABV?$ObjectPtrT@VLevel@log4cxx@@@helpe
rs@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBDH@Z)

MyPrueba.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: static void __cdecl
log4cxx::PropertyConfigurator::configure(class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> > const &)" (_
_imp_?configure@PropertyConfigurator@log4cxx@@SAXABV?$basic_string@DU?$char_
traits@D@std@@V?$allocator@D@2@@std@@@Z)
Debug/plog.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

plog.exe - 3 error(s), 0 warning(s)



Thanks in advance for any clue to solve this.


J

PD: I'm using VC++ 6 in WinXP.




Re: Linking problem

Posted by Andreas Fester <An...@gmx.de>.
Hi Javier,

> inking...
> MyPrueba.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall log4cxx::Logger::forcedLog(class log4cxx::helpers::ObjectPtrT<class log4cxx::Level> const &,class std::basic_string<char,struct std::char_traits<
> char>,class std::allocator<char> > const &,char const *,int)" (__imp_?forcedLog@Logger@log4cxx@@QAEXABV?$ObjectPtrT@VLevel@log4cxx@@@helpers@2@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PBDH@Z)
> MyPrueba.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static void __cdecl log4cxx::PropertyConfigurator::configure(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (_
> _imp_?configure@PropertyConfigurator@log4cxx@@SAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
> Debug/prueba.exe : fatal error LNK1120: 2 unresolved externals

This looks like the log4cxx.lib link library is not linked with your
project. Are you sure that you added it to the libraries of your project?
Otherwise, please post a minimal source code example, like

#include <log4cxx/logger.h>
[...]

int main() {
     PropertyConfigurator::configure(...);
     LoggerPtr logger = Logger::getLogger(...);
     LOG4CXX_FATAL(logger, ...);
}

> Also, how could I know wich libs/files should I deploy with my exe
> app ?

Regarding log4cxx, you need log4cxx.dll. Of course you need
any other third party library you are using. Its always a good
idea to test the deployment on a fresh installation of your
operating system before deploying them, virtual machines like
vmware or qemu can be of great help there.

Best Regards,

	Andreas