[log4cplus] Linking error
- Dominant language
- CMake
- Stars
- 27.5k
- Forks
- 7.7k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 321
Description
I have issues linking against the log4plus library on Windows, x64, running visual studio 2017.
When using the following main.cpp:
```
#include
#include
#include
#include
int main(int argc, char *argv[]){
log4cplus::BasicConfigurator config;
config.configure();
log4cplus::Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("test"));
logger.setLogLevel(log4cplus::DEBUG_LOG_LEVEL);
LOG4CPLUS_INFO(logger, "Hello world");
}
```
and the accompanying CMakeListst.txt:
```
cmake_minimum_required(VERSION 3.12.4)
IF(WIN32)
set(CMAKE_TOOLCHAIN_FILE c:/software/vcpkg/scripts/buildsystems/vcpkg.cmake)
ENDIF(WIN32)
project(log4cplustest VERSION 0.1 LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 11)
find_package(log4cplus REQUIRED)
add_executable(log4cplustest main.cpp)
target_link_libraries(log4cplustest log4cplus::log4cplusU)
```
Running CMake as follows:
`cmake -G "Visual Studio 15 2017 Win64" .. `
And building:
`cmake --build . --config Release`
Give the following linking error:
```
main.obj : error LNK2019: unresolved external symbol "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string,class std::allocator > const &)" (?getInstance@Logger@log4cplus@@SA?AV12@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function main [C:\software\log4plus_test_vcpkg\build\log4cplustest.vcxproj]
main.obj : error LNK2019: unresolved external symbol "class std::basic_ostringstream,class std::allocator > & __cdecl log4cplus::detail::get_macro_body_oss(void)" (?get_macro_body_oss@detail@log4cplus@@YAAEAV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function main [C:\software\log4plus_test_vcpkg\build\log4cplustest.vcxproj]
main.obj : error LNK2019: unresolved external symbol "void __cdecl log4cplus::detail::macro_forced_log(class log4cplus::Logger const &,int,class std::basic_string,class std::allocator > const &,char const *,int,char const *)" (?macro_forced_log@detail@log4cplus@@YAXAEBVLogger@2@HAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBDH2@Z) referenced in function main [C:\software\log4plus_test_vcpkg\build\log4cplustest.vcxproj]
C:\software\log4plus_test_vcpkg\build\Release\log4cplustest.exe : fatal error LNK1120: 3 unresolved externals [C:\software\log4plus_test_vcpkg\build\log4cplustest.vcxproj]
```
Any ideas? I also use the cpprestsdk vcpkg and that is not giving me any problems. When creating a new project in Visual Studio and using that instead of CMake, it also works.
Contributor guide
Assessment
This issue has not been assessed yet.