I am trying glog. I have downloaded last version (0.3.5)
I try to compile with cmake.
What I have done is:
I have compiled as static library with options
BUILD_TESTING = OFF
andWITH_GFLAGS = OFF
and used libglog.a perfectly on linuxNow I try on windows. I have compiled glog with same options as static library:
[ 11%] Building CXX object CMakeFiles/glog.dir/src/demangle.cc.obj [ 22%] Building CXX object CMakeFiles/glog.dir/src/logging.cc.obj [ 33%] Building CXX object CMakeFiles/glog.dir/src/raw_logging.cc.obj [ 44%] Building CXX object CMakeFiles/glog.dir/src/symbolize.cc.obj [ 55%] Building CXX object CMakeFiles/glog.dir/src/utilities.cc.obj [ 66%] Building CXX object CMakeFiles/glog.dir/src/vlog_is_on.cc.obj [ 77%] Building CXX object CMakeFiles/glog.dir/src/signalhandler.cc.obj [ 88%] Building CXX object CMakeFiles/glog.dir/src/windows/port.cc.obj [100%] Linking CXX static library libglogd.a [100%] Built target glog
Then, when i try to use it in a project (executable) including libglogd.a just like in linux, I got these exceptions of linking when compiling executable:
undefined reference to `_imp___ZN6google17InitGoogleLoggingEPKc' undefined reference to `_imp___ZN6google10LogMessageC1EPKci' undefined reference to `_imp___ZN6google10LogMessage6streamEv' undefined reference to `_imp___ZN6google10LogMessageD1Ev' undefined reference to `_imp___ZN6google10LogMessageC1EPKcii' undefined reference to `_imp___ZN6google10LogMessage6streamEv' undefined reference to `_imp___ZN6google10LogMessageD1Ev' undefined reference to `_imp___ZN6google10LogMessageD1Ev' undefined reference to `_imp___ZN6google10LogMessageD1Ev'
I could not find any further info about this.
Here is CMakeLists.txt of executable:
project(exe)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
#Ignore QT specified variables
set(ignoreMe "${QT_QMAKE_EXECUTABLE}")
#set(HEADERS foo.h)
add_executable(${PROJECT_NAME} ${SRC_LIST})
if (!WIN32)
target_include_directories(${PROJECT_NAME} PUBLIC
/home/glog-master/trunk/build/linux/Debug
/home/glog-master/trunk/src
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
target_link_libraries(${PROJECT_NAME} /home/glog-master/trunk/build/linux/Debug/libglogd.a)
else()
target_include_directories(${PROJECT_NAME} PUBLIC
D:/glog-master/trunk/build/windows/Debug
D:/glog-master/trunk/src
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>)
target_link_libraries(${PROJECT_NAME} D:/glog-master/trunk/build/windows/Debug/libglogd.a)
endif()
And here is the only file of executable, main.cpp:
#include <iostream>
#include "glog/logging.h"
using namespace std;
int main() {
google::InitGoogleLogging("MYEXE");
LOG(INFO) << "This is an info message MAIN";
LOG(WARNING) << "This is a warning message MAIN";
return 0;
}
What do I miss in windows?
EDIT: The library has those symbols without _imp. How do I get rid of it? I do not have dllimport.
EDIT 2: Well, I do have dllimport. I should not have. To get rid of it I see that I should define GOOGLE_GLOG_DLL_DECL. When I define it, then undefined references are:
undefined reference to google::InitGoogleLogging(char const*)
undefined reference to google::LogMessage::LogMessage(char const*, int)
...