1

I tried to build log4cxx for visual 2012 and, after 4 hours of resolving errors, the build was succesful (i'm not sure :)).

As a second step I tried to create a vs project to test logging. I used this example but it keep tell me that

mainapp.cpp(2): fatal error C1083: Cannot open include file: 'log4cxx\logger.h': No such file or directory

I already specified in the linker the path of directory debug in additional library directories and I added "log4cxx.lib" additional dependencies .

I'm confused and I don't know how to make it work

thanks in advance for your help

Yossi Dahan
  • 5,389
  • 2
  • 28
  • 50
Amine
  • 347
  • 1
  • 5
  • 12
  • See also [fatal error C1083: Cannot open include file: 'xyz.h': No such file or directory?](http://stackoverflow.com/q/7789969/33499) – wimh Nov 21 '12 at 18:25

1 Answers1

2

You also need to add the directory, where headers for log4cxx are. This is not for linking phase, but for compiler phase.

This can be done with Project Properties -> Compiler -> Preprocessor (I think, I don't have VS opened now)

You don't include .lib. This file is for linking.

You need to add to includes the directory, which contains directory log4cxx, and that (log4cxx) directory must contain logger.h!

nothrow
  • 15,882
  • 9
  • 57
  • 104
  • thanks for your help ,i have already added the directories path in c/c++->general->additional include directories and additional #using directories – Amine Nov 21 '12 at 17:52
  • @user1842823 if logger.h is stored in `c:\libs\log4cxx\logger.h`, you need to add `c:\libs` to the include path. So not `c:\libs\log4cxx` in this example! But please specify where you have stored logger.h. – wimh Nov 21 '12 at 18:05
  • what i want to do is to use log4cxx.lib and in the my projet i include .i think if i add handreds of header files just for logging is meanless . – Amine Nov 21 '12 at 18:11
  • i searched tutorial how to use log4cxx in vs2012 but nothing – Amine Nov 21 '12 at 18:11
  • @user1842823 as Yossarian explained, this is a compiler error, not a linker error. So it is unrelated to the log4cxx.lib file. – wimh Nov 21 '12 at 18:17
  • yes i understand you but i still have the problem .any idea in the use of log4cxx will be useful – Amine Nov 21 '12 at 19:24
  • when i do this :

    #include #include #include #include #include #include "log4cxx\xml\domconfigurator.h" #include using namespace log4cxx; using namespace log4cxx::xml; using namespace log4cxx::helpers; the original error diasppair but instead i had this :
    c:\log_cxx\apache-log4cxx-0.10.0\projects\debug\log4cxx.lib(1): error C2059: syntax error : '<' 1>c:\log_cxx\apache-log4cxx-0.10.0\projects\debug\log4cxx.lib(2): error C2018: etc '
    – Amine Nov 22 '12 at 11:07
  • 1
    See the edit. And, learn something about C++ before trying to use any libraries. – nothrow Nov 22 '12 at 11:50