Log4cpp: Linux cannot find lib files

I download log4cpp on my Linux and I use the following commands to install:

./configure
make
make check
make install

      

After that I can find the lib files below in the path "/ usr / local / lib":

liblog4cpp.a
liblog4cpp.la
liblog4cpp.so
liblog4cpp.so.4
liblog4cpp.so.4.0.0

      

Then I tried to use log4cpp in my cpp project which is run by gcc11.

But I got the error:

Undefined reference to "log4cpp::Category::shutdown()"

      

I think it cannot find the lib files. So I added liblog4cpp.so

manually.

Now I got this error:

undefined reference to "pthread_key_create"

      

What should I do?

+3


source to share


2 answers


The problem has been resolved.
I got this error because lib pthread is not lib by default. Therefore, we have to add it manually for our project (for the IDE) or add it as a compile-time parameter (gcc -pthread). If everything is ok, we can find it in / usr / lib.



0


source


log4cpp is a C ++ lib, I recommend setting up and building it using the same C ++ compiler



+1


source







All Articles