[CMake] using cmake to link header files: file could be found, is included, but build error when using nmake.
Petr Kmoch
petr.kmoch at gmail.com
Thu Mar 31 03:20:32 EDT 2016
Hi Karel,
I've noticed a few points where you could start looking for a solution:
* You're mentioning that CMake warns about some linking stuff, but the
compiler error is one about including a header file. Libraries and headers
are fundamentally different objects: header files are used by the compiler,
libraries are used by the linker.
* Regarding the linking thing:
AVRO_LIBRARY - The Avro C++ libraries
Yet you seem to be setting this to a directory:
set(AVRO_LIBRARY
D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win)
when you're supposed to set it to a library (.lib file).
* As for the header issue, you're setting:
set(AVRO_INCLUDE_DIR
D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/avro)
but then using:
include_directories (
${AVRO_INCLUDE_DIRS}
)
Note the difference in the trailing 'S'.
* Additionally, variables like AVRO_INCLUDE_DIR and AVRO_LIBRARY look like
something the find package should be setting *for* you. It doesn't seem
like a package shipped with CMake, so consult its docs to check you're
using it as intended.
Petr
On Wed, Mar 30, 2016 at 5:15 PM, Karel Geiregat <karelgeiregat at gmail.com>
wrote:
> Dear users at Cmake
>
>
> It could be that I don't have understood the linking process when building
> the project by cmake. The project has three dependencies: (1) Boost, (2)
> (Apache) Avro and (3) Botan.
> After issuing the following command to be able to use the nmake command
> from Visual Studio:
>
> D:\...\build>cmake -G "NMake Makefiles" -DKAA_INSTALL_PATH="D:\kaa\kaaSDK"
>> -DKAA_DEBUG_ENABLED=1 ..
>>
>
> It ran without problems, except minor warnings like
>
> WARNING: Target "kaacpp" requests linking to directory
>> "D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win". Targets may link only to
>> libraries. CMake is dropping the item.
>>
> => note: full log is at the bottom of this mail (appendix 1).
>
> but when i call nmake after, it immediately throws up error:
>
> D:\...\build>nmake
>>
>> Microsoft (R) Program Maintenance Utility Version 14.00.23506.0
>> Copyright (C) Microsoft Corporation. All rights reserved.
>>
>> Scanning dependencies of target kaacpp_o
>> [ 1%] Building CXX object
>> CMakeFiles/kaacpp_o.dir/impl/event/registration/EndpointRegistrationManager.cpp.obj
>> EndpointRegistrationManager.cpp
>> D:\kaa\kaa-cpp-ep-sdk-aXrMkhHEE2BrPBehV_Vbxym2MfU\kaa/gen/EndpointGen.hpp(26):
>> fatal error C1083: Cannot open include file: 'avro/Specific.hh': No such
>> file or directory
>> NMAKE : fatal error U1077: 'C:\PROGRA~2\VISUAL~1.0\VC\bin\cl.exe' :
>> return code '0x2'
>> Stop.
>> NMAKE : fatal error U1077: '"C:\Program Files (x86)\Visual Studio
>> 14.0\VC\BIN\nmake.exe"' : return code '0x2'
>> Stop.
>>
>
> I have checked the file, and there is the following includes
>
> #include <sstream>
>> #include "boost/any.hpp"
>> #include "avro/Specific.hh" <-------- error line
>> #include "avro/Encoder.hh"
>> #include "avro/Decoder.hh"
>>
>
> My idea is that the linking of the avro library is not set up correctly
> since the error got thrown after including a Boost file.
> Here is a fragment of my cmakelists.txt file where Avro got added and how
> the packages got found/added
>
> # AVRO_ROOT_DIR - Set this variable to the root installation
>> of Avro C++ if the module has problems finding the proper installation
>> path.
>> # AVRO_LIBRARY - The Avro C++ libraries
>> # AVRO_INCLUDE_DIR - The location of Avro C++ headers
>> set(AVRO_ROOT_DIR D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++)
>> set(AVRO_LIBRARY
>> D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win)
>> set(AVRO_INCLUDE_DIR
>> D:/kuleuven/thesis/kaa/kaaBuild/avro_1.8.0/lang/c++/avro)
>>
>
>>
> some contents omitte
>>
>
>>
> #
>> # Find third-party dependencies
>> #
>> find_package (Boost 1.54 REQUIRED COMPONENTS log system thread)
>> find_package (Avro REQUIRED)
>> find_package (Botan REQUIRED)
>>
> => note: full cmakelist.txt file is added as appendix2
>
>
> After that, i have issued the following messaging
>
> message("--- AVRO: Found? " ${AVRO_FOUND}) <----- displays "--- AVRO:
>> Found? TRUE"
>> message(${AVRO_LIBRARIES}) <----- displays "
>> D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win"
>
>
>
> So, the library can be found. However, it surprises me that the specific
> file, Specific.hh could not be found while it is in the include directory,
> AVRO_INCLUDE_DIR (according to the findavrocpp.cmake
> <https://github.com/Produban/log2kafka/blob/master/cmake/FindAvroCPP.cmake#L33>
> it's used for headers).
> I have issued the following PowerShell command to show that the file is in
> the given directory
>
> PS D:\kaa\kaaBuild\avro_1.8.0\lang\c++\avro> Get-childitem Specific.hh
>>
>> Directory: D:\kaa\kaaBuild\avro_1.8.0\lang\c++\avro
>>
>> Mode LastWriteTime Length Name
>> ---- ------------- ------ ----
>> -a---- 2/9/2012 7:11 PM 7428 Specific.hh
>>
>
>
> So it could be that it is not linking correctly. Is the cmakelist.txt
> incorrect or is cmake unable to link the right header file without throwing
> an error ?
> Is there a solution for this ? I don't have a clue where to find the cause
> of the linking problems so i can solve it.
>
> If you need more information, please check the appendix 1 & 2 here below.
> If these isn't sufficient enough, please inform me which information i can
> provide.
>
> Sincerely
> - kg
>
>
>
> *APPENDIX 1: output of cmake command*
>
> D:\kaa\kaa-cpp-ep-sdk-aXrMkhHEE2BrPBehV_Vbxym2MfU\build>cmake -G "NMake
>> Makefiles" -DKAA_INSTALL_PATH="D:\kaa\kaaSDK" -DKAA_DEBUG_ENABLED=1 ..
>> ==================================
>> CMake Warning (dev) at CMakeLists.txt:73 (if):
>> Policy CMP0054 is not set: Only interpret if() arguments as variables or
>> keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
>> details. Use the cmake_policy command to set the policy and suppress
>> this
>> warning.
>>
>> Quoted variables like "MSVC" will no longer be dereferenced when the
>> policy
>> is set to NEW. Since the policy is not set the OLD behavior will be
>> used.
>> This warning is for project developers. Use -Wno-dev to suppress it.
>>
>> ==================================
>> KAA_MAX_LOG_LEVEL=6
>> EVENTS ENABLED
>> NOTIFICATIONS ENABLED
>> CONFIGURATION ENABLED
>> LOGGING ENABLED
>> OPERATION_TCP_CHANNEL ENABLED
>> OPERATION_LONG_POLL_CHANNEL ENABLED
>> OPERATION_HTTP_CHANNEL ENABLED
>> BOOTSTRAP_HTTP_CHANNEL ENABLED
>> CONNECTIVITY_CHECKER ENABLED
>> KAA_THREADSAFE ENABLED
>> ==================================
>> -- Boost version: 1.60.0
>> -- Found the following Boost libraries:
>> -- log
>> -- system
>> -- thread
>> -- date_time
>> -- log_setup
>> -- filesystem
>> -- regex
>> -- chrono
>> -- atomic
>>
>> Looking for Avro C++ headers and libraries
>> -- Root dir: D:/kaa/kaaBuild/avro_1.8.0/lang/c++
>> -- Include directories: D:/kaa/kaaBuild/avro_1.8.0/lang/c++/avro
>> -- Libraries: D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win
>> -- FindBotan check
>> -- BOTAN_HOME is not empty: "D:/kaa/kaaBuild/botan-1.11.29"
>> -- Looking for botan in D:/kaa/kaaBuild/botan-1.11.29
>> -- Include directory: D:/kaa/kaaBuild/botan-1.11.29/build/include
>> -- Library: D:/kaa/kaaBuild/botan-1.11.29/botan.lib
>>
>> checking libraries
>> --- BOTAN: Found? YES
>> D:/kaa/kaaBuild/botan-1.11.29/botan.lib
>> --- AVRO: Found? TRUE
>> D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win
>> --- BOOST: Found?
>>
>> optimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_log-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_log-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_system-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_system-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_thread-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_thread-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_date_time-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_date_time-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_log_setup-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_log_setup-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_filesystem-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_filesystem-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_regex-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_regex-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_chrono-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_chrono-vc140-mt-gd-1_60.liboptimizedD:/software/boost_1_60_32/lib32-msvc-14.0/boost_atomic-vc140-mt-1_60.libdebugD:/software/boost_1_60_32/lib32-msvc-14.0/boost_atomic-vc140-mt-gd-1_60.lib
>> done checking libraries
>>
>> -- KAA WILL BE INSTALLED TO C:/Program Files (x86)/Kaa-cpp
>> -- Configuring done
>> WARNING: Target "kaacpp" requests linking to directory
>> "D:/kaa/kaaBuild/avro_1.8.0/lang/c++/build.win". Targets may link only to
>> libraries. CMake is dropping the item.
>> -- Generating done
>> -- Build files have been written to:
>> D:/kaa/kaa-cpp-ep-sdk-aXrMkhHEE2BrPBehV_Vbxym2MfU/build
>>
>
>
>
> *APPENDIX 2: cmakelists.txt file*
>
> File consists of 300+ lines, so uploaded it. See upload on my google
> drive: https://drive.google.com/open?id=0B-1WvUfrCC3MUHR5dGZmVUdhY0U
>
>
>
> // EOF
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160331/5b919dc3/attachment-0001.html>
More information about the CMake
mailing list