Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CMake support for glog #4

Closed
prudhomm opened this issue Mar 16, 2015 · 39 comments
Closed

Add CMake support for glog #4

prudhomm opened this issue Mar 16, 2015 · 39 comments

Comments

@prudhomm
Copy link

Hi

would it be possible to add cmake support for Glog ? Gflags already support cmake, it would be consistent to have glog supporting it also.
It seems that there have been attempts to do that in the past.

Thanks you very much in advance

@sergiud
Copy link
Collaborator

sergiud commented Mar 23, 2015

I've added CMake support to glog: https://github.com/sergiud/glog. Tested on Windows using VC 8.0-14.0 CTP 6 and cygwin gcc 4.9.2, and on Arch Linux using gcc 4.9.2 and clang 3.6.

Usage in a CMake project:

cmake_minimum_required (VERSION 2.8.11)
project (myproject)

find_package (glog 0.3.4)

add_executable (myproject myproject.cpp)
target_link_libraries (myproject glog)

@prudhomm
Copy link
Author

Hi thanks for your work ! I will test it asap.
how about a pull request on the google/glog to see what the maintainer says ?

@sergiud
Copy link
Collaborator

sergiud commented Mar 23, 2015

There are minor things left to be done. Once I'm done, I'll create a pull request.

@exxus
Copy link

exxus commented Mar 27, 2015

When adding cmake support it would be nice to have also mingw support on windows.
The release 0.3.4 states "attempt to improve mingw-w64 support", but I think that's maybe only for cross compiles.
Building with mingw-w64 seems not to be supported.

@sergiud
Copy link
Collaborator

sergiud commented Mar 27, 2015

MinGW and CMake support are pretty much unrelated issues. MinGW is simply missing functions that are required to compile glog.

@exxus
Copy link

exxus commented Mar 27, 2015

Thank you for your help.

I was able to compile glog with mingw, but I had to use msys to run the configure script, and there were some linker problems with the test. Also there are some problems with pthreads, because glog defines its own pthreads. I had to use mingw without pthread support. But I was able to use the library in my project that I compiled with MinGW and the logging could be used correctly. MinGW does not support symbolic links, but glog can be used without this functionality. I just thought that during the cmake process one could check for mingw compiler and set the correct macros.

Currently I am testing your cmake fork and it also seems that somehow the MSVC Project can not include the gflags headers correctly.

@sergiud
Copy link
Collaborator

sergiud commented Mar 27, 2015

What MinGW version are you using? Maybe I can take a look.

Would you also post the CMake/compiler output regarding the gflags problem? Thanks.

@exxus
Copy link

exxus commented Mar 27, 2015

I am using mingw-w64: i686-4.9.2-win32-sjlj-rt_v3-rev1 from the mingw-w64 project.
Note that in logging.h I had to import stdlib and disable the dllimport stuff also for mingw

#include <stdlib.h>
...
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
#   define GOOGLE_GLOG_DLL_DECL  __declspec(dllimport)
# else
#   define GOOGLE_GLOG_DLL_DECL
# endif

The problem with gflags is, that the headers are not found.

Fehler  1   error C1083: Datei (Include) kann nicht geöffnet werden: "gflags/gflags.h": No such file or directory  d:\buildlibs\glogcmake\glog\src\base\commandlineflags.h 58  1   glog

From the CmakeCache.txt

//The directory containing a CMake configuration file for Gflags.
Gflags_DIR:PATH=D:/libs/local/cmake

Additionally you could add Cache variable in cmake to disable gflags.

Thank you

@sergiud
Copy link
Collaborator

sergiud commented Mar 30, 2015

My MinGW installation is missing the strerror_s and localtime_s functions, which are required for the implementation of strerror_r and localtime_r. I pushed a fix for the gflags issue, though.

@sergiud
Copy link
Collaborator

sergiud commented Mar 30, 2015

As a side note, you have to use the gflags_DIR CMake variable instead of Gflags_DIR now.

@exxus
Copy link

exxus commented Mar 30, 2015

Thank you. Compiling without gflags with MSVS works now.
When building with gflags, the gflags headers are still not included automatically.
This is a typo, the gflags include directory is called gflags_INCLUDE_DIR and not gflags_INCLUDE_DIRS.
After fixing this, MSVS complains about:

Compiler Error C2370
'identifier' : redefinition; different storage class

in logging.cc line 105, 107, 134, 1034, 175, 140, 142, 172, 138, 128, 166, 168
e.g.: 'fLB::FLAGS_alsologtostderr'
in vlog_is_on line 53
'fLI::FLAGS_v'

and

Compiler Error C2872
'symbol' : ambiguous symbol

'int64' and 'uint32' in several lines in logging_unittest.cc

mingw with posix threads is not compiling, I will try mingw with win32 threads later.

@sergiud
Copy link
Collaborator

sergiud commented Mar 30, 2015

Thanks for letting me know. The gflags issues should be fixed now.

@exxus
Copy link

exxus commented Mar 30, 2015

using mingw with win32 threads:

PS D:\buildlibs\glogcmake\glog\build> mingw32-make
Scanning dependencies of target glog
[  8%] Building CXX object CMakeFiles/glog.dir/src/demangle.cc.obj
[ 16%] Building CXX object CMakeFiles/glog.dir/src/logging.cc.obj
[ 25%] Building CXX object CMakeFiles/glog.dir/src/raw_logging.cc.obj
[ 33%] Building CXX object CMakeFiles/glog.dir/src/symbolize.cc.obj
[ 41%] Building CXX object CMakeFiles/glog.dir/src/utilities.cc.obj
[ 50%] Building CXX object CMakeFiles/glog.dir/src/vlog_is_on.cc.obj
[ 58%] Building CXX object CMakeFiles/glog.dir/src/signalhandler.cc.obj
[ 66%] Building CXX object CMakeFiles/glog.dir/src/windows/port.cc.obj
D:\buildlibs\glogcmake\glog\src\windows\port.cc: In function 'int snprintf(char*, size_t, const char*, ...)':
D:\buildlibs\glogcmake\glog\src\windows\port.cc:59:5: error: redefinition of 'int snprintf(char*, size_t, const char*, .
..)'
 int snprintf(char *str, size_t size, const char *format, ...) {
     ^
In file included from D:/Software/mingw-w64/i686-4.9.2-win32-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/locale.h:1
2:0,
                 from D:/Software/mingw-w64/i686-4.9.2-win32-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/clocal
e:42,
                 from D:/Software/mingw-w64/i686-4.9.2-win32-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/i686-w
64-mingw32/bits/c++locale.h:41,
                 from D:/Software/mingw-w64/i686-4.9.2-win32-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/bits/l
ocalefwd.h:40,
                 from D:/Software/mingw-w64/i686-4.9.2-win32-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/string
:43,
                 from D:\buildlibs\glogcmake\glog\src\windows\port.cc:43:
D:/Software/mingw-w64/i686-4.9.2-win32-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/stdio.h:339:5: note: 'int snprin
tf(char*, size_t, const char*, ...)' previously defined here
 int snprintf (char *__stream, size_t __n, const char *__format, ...)
     ^
At global scope:
cc1plus.exe: warning: unrecognized command line option "-Wno-unnamed-type-template-args"
CMakeFiles\glog.dir\build.make:222: recipe for target 'CMakeFiles/glog.dir/src/windows/port.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/windows/port.cc.obj] Error 1
CMakeFiles\Makefile2:94: recipe for target 'CMakeFiles/glog.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/glog.dir/all] Error 2
makefile:146: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
PS D:\buildlibs\glogcmake\glog\build>

using mingw with posix threads:

PS D:\buildlibs\glogcmake\glog\build> mingw32-make
Scanning dependencies of target glog
[  8%] Building CXX object CMakeFiles/glog.dir/src/demangle.cc.obj
[ 16%] Building CXX object CMakeFiles/glog.dir/src/logging.cc.obj
In file included from D:\buildlibs\glogcmake\glog\src\utilities.h:78:0,
                 from D:\buildlibs\glogcmake\glog\src\logging.cc:32:
D:/buildlibs/glogcmake/glog/src/windows/port.h:139:15: error: conflicting declaration 'typedef DWORD pthread_t'
 typedef DWORD pthread_t;
               ^
In file included from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/i686-w
64-mingw32/bits/gthr-default.h:35:0,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/i686-w
64-mingw32/bits/gthr.h:148,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/ext/at
omicity.h:35,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/bits/b
asic_string.h:39,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/string
:52,
                 from D:\buildlibs\glogcmake\glog\src\utilities.h:75,
                 from D:\buildlibs\glogcmake\glog\src\logging.cc:32:
D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/pthread.h:196:19: note: previous
 declaration as 'typedef uintptr_t pthread_t'
 typedef uintptr_t pthread_t;
                   ^
In file included from D:\buildlibs\glogcmake\glog\src\utilities.h:78:0,
                 from D:\buildlibs\glogcmake\glog\src\logging.cc:32:
D:/buildlibs/glogcmake/glog/src/windows/port.h:140:15: error: conflicting declaration 'typedef DWORD pthread_key_t'
 typedef DWORD pthread_key_t;
               ^
In file included from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/i686-w
64-mingw32/bits/gthr-default.h:35:0,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/i686-w
64-mingw32/bits/gthr.h:148,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/ext/at
omicity.h:35,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/bits/b
asic_string.h:39,
                 from D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/c++/string
:52,
                 from D:\buildlibs\glogcmake\glog\src\utilities.h:75,
                 from D:\buildlibs\glogcmake\glog\src\logging.cc:32:
D:/Software/mingw-w64/i686-4.9.2-posix-sjlj-rt_v3-rev1/mingw32/i686-w64-mingw32/include/pthread.h:182:18: note: previous
 declaration as 'typedef unsigned int pthread_key_t'
 typedef unsigned pthread_key_t;
                  ^
D:/buildlibs/glogcmake/glog/src/windows/port.h:142:8: error: expected identifier before numeric constant
 enum { PTHREAD_ONCE_INIT = 0 };   // important that this be 0! for SpinLock
        ^
D:/buildlibs/glogcmake/glog/src/windows/port.h:142:8: error: expected '}' before numeric constant
D:/buildlibs/glogcmake/glog/src/windows/port.h:142:8: error: expected unqualified-id before numeric constant
In file included from D:\buildlibs\glogcmake\glog\src\utilities.h:78:0,
                 from D:\buildlibs\glogcmake\glog\src\logging.cc:32:
D:/buildlibs/glogcmake/glog/src/windows/port.h:142:30: error: expected declaration before '}' token
 enum { PTHREAD_ONCE_INIT = 0 };   // important that this be 0! for SpinLock
                              ^
cc1plus.exe: warning: unrecognized command line option "-Wno-unnamed-type-template-args"
CMakeFiles\glog.dir\build.make:78: recipe for target 'CMakeFiles/glog.dir/src/logging.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/logging.cc.obj] Error 1
CMakeFiles\Makefile2:94: recipe for target 'CMakeFiles/glog.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/glog.dir/all] Error 2
makefile:146: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

@sergiud
Copy link
Collaborator

sergiud commented Mar 31, 2015

I see. Adding MinGW support basically requires some code refactoring, which I can't really help with.

@exxus
Copy link

exxus commented Mar 31, 2015

Thank you very much for your help. In the release 0.3.4, the developers added the feature

  • attempt to improve mingw-w64 support

I hope they will continue adding mingw-w64 on windows with cmake.

@bvanevery
Copy link

sergiud, there's a bug in your CMake build somewhere, on Windows 7 with Visual Studio 2013 Community Edition at least. It doesn't copy the glog\log_severity.h file. I haven't found the cause yet. I'm building in build\serguid_glog. My build\sergiud_glog\glog directory doesn't have the file, although all the other *.h files are present. build\sergiud_glog\install_manifest.txt does not list the file, but the other *.h files are listed. As I have not found an explicit list of these files for installation, I am guessing you used some kind of automated routine to grab all the needed files, and had an endpoint error iterating through them. I would have filed this as an issue in your github repository, but you don't seem to have Issues enabled.

Anyways count me as someone who'd like to see an official CMake build for glog. I've found 3 different ones including sergiud's. I'm currently dealing with 2 projects that consume gflags and glog, that aren't working well with gflags detection or glog building in Visual Studio 2013. The .sln files that glog proper provides, are only 32-bit when imported to Visual Studio 2013. 7 project upgrade errors are given, which might be worrisome.

@sergiud
Copy link
Collaborator

sergiud commented Jul 7, 2015

@bvanevery, good catch. I failed to include log_severity.h for install.

@bvanevery
Copy link

sergiud, are you going to fix that in your repo? Or at least enable Issues reporting in your repo, so that it's not forgotten?

@sergiud
Copy link
Collaborator

sergiud commented Jul 14, 2015

@bvanevery I've enabled issues in my repository.

@acgtyrant
Copy link

@sergiud Hi, I am glad that you make google-glog support CMake, however, I write a find_package(glog REQUIRED) in my CMakeList.txt, and cmake it, it complains:

CMake Error at CMakeLists.txt:26 (find_package):
  By not providing "Findglog.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "glog", but
  CMake did not find one.

  Could not find a package configuration file provided by "glog" with any of
  the following names:

    glogConfig.cmake
    glog-config.cmake

My OS is Arch Linux, and I execute pacman -Ql google-glog, I do not know why does it not contains the glog-config.cmake:

google-glog /usr/
google-glog /usr/include/
google-glog /usr/include/glog/
google-glog /usr/include/glog/log_severity.h
google-glog /usr/include/glog/logging.h
google-glog /usr/include/glog/raw_logging.h
google-glog /usr/include/glog/stl_logging.h
google-glog /usr/include/glog/vlog_is_on.h
google-glog /usr/lib/
google-glog /usr/lib/libglog.so
google-glog /usr/lib/libglog.so.0
google-glog /usr/lib/libglog.so.0.0.0
google-glog /usr/lib/pkgconfig/
google-glog /usr/lib/pkgconfig/libglog.pc
google-glog /usr/share/
google-glog /usr/share/licenses/
google-glog /usr/share/licenses/google-glog/
google-glog /usr/share/licenses/google-glog/COPYING

Any ides? Thank you!

@sergiud
Copy link
Collaborator

sergiud commented Dec 29, 2015

Glog 0.3.5 which includes CMake support has not been released yet. You'll have to compile Glog from source.

@acgtyrant
Copy link

@sergiud So it is! Thank you!

@acgtyrant
Copy link

@sergiud Hi, I write the PKBGUILD to comiple Glog from source, however, I find it does not compile libglog.so, I do not know why, any idea? Thank you!

See my compile output and PKGBUILD: https://gist.github.com/acgtyrant/ae5794c37cef79c8464c

kennyyu added a commit to kennyyu/glog that referenced this issue Nov 4, 2017
Summary:
Issue google#80 points out several places in glog where TSAN discovers
false positives. One of these places is in the `LOG_EVERY_N` macros.
These macros are implemented by maintaining a static unprotected
integer counter, and TSAN will report data races on these counters.

Here is a minimum example to reproduce the data race:

```

void logging() {
  for (int i = 0; i < 300; ++i) {
    LOG_EVERY_N(INFO, 2) << "foo";
  }
}

int main() {
  auto t1 = std::thread(logging);
  auto t2 = std::thread(logging);
  t1.join();
  t2.join();
  return 0;
}
```

And here is the TSAN report:

```
WARNING: ThreadSanitizer: data race (pid=776850)
  Write of size 4 at 0x558de483f684 by thread T2:
    #0 logging()
    google#1 void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>)
    google#2 std::_Bind_simple<void (*())()>::operator()()
    google#3 std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run()
    google#4 execute_native_thread_routine

  Previous write of size 4 at 0x558de483f684 by thread T1:
    #0 logging()
    google#1 void std::_Bind_simple<void (*())()>::_M_invoke<>(std::_Index_tuple<>)
    google#2 std::_Bind_simple<void (*())()>::operator()()
    google#3 std::thread::_Impl<std::_Bind_simple<void (*())()> >::_M_run()
    google#4 execute_native_thread_routine

  Location is global '<null>' at 0x000000000000 (main+0x00000011c684)

  Thread T2 (tid=776857, running) created by main thread at:
    #0 pthread_create
    google#1 __gthread_create
    google#2 std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)())
    google#3 main

  Thread T1 (tid=776856, running) created by main thread at:
    #0 pthread_create
    google#1 __gthread_create
    google#2 std::thread::_M_start_thread(std::shared_ptr<std::thread::_Impl_base>, void (*)())
    google#3 main

SUMMARY: ThreadSanitizer: data race in logging()
```

To avoid noisy TSAN reports and also avoid adding a performance hit, this
change will mark these counters as benign races so that TSAN will not report
them. This change will only have an effect if we are compiling with TSAN;
there are no changes if we are not building with TSAN.

With this change, the above example no longer reports a data race when built
and run with TSAN.
@graugans
Copy link

Just for the sake of completeness. I recently had some issues with how the glog CMake implementation works. It is not glog related I guess it is how CMake's find_package config mode works. Together with object-libraries CMake did not passed the Include files folder to the object file compilation step.

This example form ifm3d will fail compilation at least under Windows with Visual Studio 2017

file(GLOB IFM3D_CAMERA_SOURCES *.cpp)
add_library(ifm3d_camera OBJECT ${IFM3D_CAMERA_SOURCES})
set_property(TARGET ifm3d_camera PROPERTY POSITION_INDEPENDENT_CODE 1)

add_library(ifm3d_camera_shared SHARED $<TARGET_OBJECTS:ifm3d_camera>)
target_link_libraries(
  ifm3d_camera_shared
  glog::glog
  ${LIB_xmlrpcxx}
  ${LIB_xmlrpc_clientxx}
)

The fix is pretty easy but maybe this save someone some time

find_package(Boost REQUIRED COMPONENTS system date_time regex)
find_package(glog REQUIRED CONFIG NAMES google-glog glog)
if (NOT TARGET glog::glog)
	find_library(LIB_glog NAMES glog)
else()
	set(LIB_glog glog::glog)
endif (NOT TARGET glog::glog)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

file(GLOB IFM3D_FG_SOURCES *.cpp)

add_library(
  ifm3d_framegrabber_shared SHARED ${IFM3D_FG_SOURCES}
  )
set_property(TARGET ifm3d_framegrabber_shared PROPERTY POSITION_INDEPENDENT_CODE 1)

  
target_link_libraries(
  ifm3d_framegrabber_shared
  ifm3d_camera_shared
  ${LIB_glog}
  ${Boost_LIBRARIES}
  ${CMAKE_THREAD_LIBS_INIT}
  )

@sergiud
Copy link
Collaborator

sergiud commented Dec 13, 2017

You have two code paths there. The first one (which calls find_library) uses only the raw glog library. This code path may fail if you did not set the include directories, compile definitions etc. correctly, which is user's responsibility. The second one where the glog::glog target is defined, should not fail if the package was found.

I don't see how the problem is related to CMake's config mode or object-libraries. Why do you need to locate glog using find_library in the first place?

@graugans
Copy link

@sergiud the find_library(LIB_glog NAMES glog) is for glog < 0.3.5 where no CMake support was provided. If using the glog::glog which uses the magic inside the CMake-config file for setting the right compiler and linker flags this will not work when compiling an OBJECT library. Because at least the include path is not provided correctly and the CFLAGS also missing.

add_library(ifm3d_camera OBJECT ${IFM3D_CAMERA_SOURCES})

@sergiud
Copy link
Collaborator

sergiud commented Dec 14, 2017

As per CMake documentation object libraries only compile the sources. You need to add another library which uses the objects and then you can link to the imported glog::glog target as usual.

@graugans
Copy link

Thanks for the hint with the extra library and I highly appreciate your CMake support for glog which saved me a lot of time.

I tried to explain in the comments above I do not consider this a bug in Glogs CMake implementation nor in the CMake itself. It was just something which took me quite some time to figure out. And I tried to document it somehow so maybe I can save someone some time.

@majiqiang
Copy link

My OS is Arch Linux, and I execute pacman -Ql google-glog, I do not know why does it not contains the glog-config.cmake:

i want to know how you solve this problem. i also met this case!

@graugans
Copy link

@majiqiang It looks like Arch uses configure to build the package thus the cmake stuff is not generated. So you can add a comment or vote on their issue tracker to the already opened issue about this.
FS#55185 - [google-glog] use cmake to build to generate cmake import configs maybe adding a link to this issue might shed some lights.

@majiqiang
Copy link

@majiqiang It looks like Arch uses configure to build the package thus the cmake stuff is not generated. So you can add a comment or vote on their issue tracker to the already opened issue about this.
FS#55185 - [google-glog] use cmake to build to generate cmake import configs maybe adding a link to this issue might shed some lights.

@graugans What should I do specifically? I first installed various dependencies, such as glog, egien3, and so on. Then I git clone handeye-calib-camodocal to my workspace ~/catkin_ws/src, and catkin_make. but I got the errors:
Could not find a package configuration file provided by "Glog" with any of
the following names:

              GlogConfig.cmake
              glog-config.cmake

@graugans
Copy link

@majiqiang you can try to get in touch with the Arch guys so they fix it. or you can build glog from source.

@majiqiang
Copy link

@majiqiang you can try to get in touch with the Arch guys so they fix it. or you can build glog from source.

@graugans you mean this?
git clone https://github.com/google/glog
sudo apt-get install autoconf automake libtool
./autogen.sh
./configure
make -j 24
sudo make install

@graugans
Copy link

This will not help. This is exactly how the Arch Maintainer builds. You have to use CMake. https://github.com/google/glog/blob/master/cmake/INSTALL.md

@samhartlebury
Copy link

Whenever I build on windows I get a warning fLB::FLAGS_logtostderr': inconsistent dll linkage
And after running tests, symbolize always fails.

Anyone point me in the right direction?

@zyzn
Copy link

zyzn commented Feb 1, 2024

When I execute the cmake, it says the add_library cannot create imported target "glog::glog" because another
target with the same name already exists. Could anyone help me about it? Thanks.

-- Found Glog
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
-- Found SQLite3: /usr/include (found version "3.31.1")
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found Git: /usr/bin/git (found version "2.25.1")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found required Ceres dependency: Eigen version 3.3.7 in /usr/lib/cmake/eigen3
CMake Error at /usr/local/lib/cmake/Ceres/FindGlog.cmake:349 (add_library):
add_library cannot create imported target "glog::glog" because another
target with the same name already exists.
Call Stack (most recent call first):
/usr/local/lib/cmake/Ceres/CeresConfig.cmake:247 (find_package)
cmake/FindDependencies.cmake:33 (find_package)
CMakeLists.txt:85 (include)

-- Found required Ceres dependency: glog
-- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, SchurSpecializations]

@sergiud
Copy link
Collaborator

sergiud commented Feb 1, 2024

With the information you provided it is hard to tell what is going on. However, if had to guess I'd say that you are using broken/outdated distribution that does not provide a CMake glog package configuration or the project that you are trying to compile is mixing different glog versions.

I suggest opening a separate issue with detailed information on how to reproduce the error.

@dawnzyt
Copy link

dawnzyt commented Jul 30, 2024

When I execute the cmake, it says the add_library cannot create imported target "glog::glog" because another target with the same name already exists. Could anyone help me about it? Thanks.

-- Found Glog -- Includes : /usr/include -- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so -- Found SQLite3: /usr/include (found version "3.31.1") -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so -- Found Git: /usr/bin/git (found version "2.25.1") -- Looking for pthread.h -- Looking for pthread.h - found -- Looking for pthread_create -- Looking for pthread_create - not found -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE -- Found required Ceres dependency: Eigen version 3.3.7 in /usr/lib/cmake/eigen3 CMake Error at /usr/local/lib/cmake/Ceres/FindGlog.cmake:349 (add_library): add_library cannot create imported target "glog::glog" because another target with the same name already exists. Call Stack (most recent call first): /usr/local/lib/cmake/Ceres/CeresConfig.cmake:247 (find_package) cmake/FindDependencies.cmake:33 (find_package) CMakeLists.txt:85 (include)

-- Found required Ceres dependency: glog -- Found Ceres version: 2.2.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, SchurSpecializations]

I met the same problem. Modify line 349 of FindGlog.cmake to:

if(NOT TARGET glog::glog)
add_library(glog::glog INTERFACE IMPORTED)
# Additional configuration for glog::glog
endif()

It works for me.

@s1ddok
Copy link

s1ddok commented Jul 30, 2024

omg @dawnzyt thank you, glomap is about to be built ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests