Linking error while trying to include an external library to a CMAKE project

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Linking error while trying to include an external library to a CMAKE project

maaschn
I currently try to add an external dynamiced linked library (dll) to my cmake project. I have got the .dll and the .lib file. I spent a lot of time to find an answer by myself but I didn't manage to find the solution. The include works but I always get a linking error when I try to compile a minimum solution. CMAKE throws no errors while configuring and generating and finds the library. I hope someone had the problem before and recognizes my error

I also build my own find module which looks like this

find_path(LLT_INCLUDE_DIR InterfaceLLT_2.h HINTS ${LLT_DIR})

find_library(LLT_LIBRARY NAMES LLT HINTS ${LLT_DIR} )

set(LLT_LIBRARIES ${LLT_LIBRARY} )

set(LLT_INCLUDE_DIRS ${LLT_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)

# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE

# if all listed variables are TRUE

find_package_handle_standard_args(LLT  DEFAULT_MSG LLT_LIBRARY LLT_INCLUDE_DIR)

mark_as_advanced(LLT_INCLUDE_DIR LLT_LIBRARY )
The corresponding CMakeLists.txt looks like this

PROJECT(TestProg)

cmake_minimum_required(VERSION 2.8)

FIND_PACKAGE(LLT REQUIRED)

INCLUDE_DIRECTORIES(${LLT_INCLUDE_DIR})

SET(TestProg_SOURCES

main.cpp

)

SET(TestProg_HEADERS

)

add_executable(TestProg ${TestProg_SOURCES} ${TestProg_HEADERS})

target_link_libraries(TestProg ${LLT_LIBRARIES} )
Here is the CMAKE output

The C compiler identification is MSVC 16.0.40219.1

The CXX compiler identification is MSVC 16.0.40219.1

Check for working C compiler using: Visual Studio 10

Check for working C compiler using: Visual Studio 10 -- works

Detecting C compiler ABI info

Detecting C compiler ABI info - done

Check for working CXX compiler using: Visual Studio 10

Check for working CXX compiler using: Visual Studio 10 -- works

Detecting CXX compiler ABI info

Detecting CXX compiler ABI info - done

Found LLT: C:/XXX/LLT.lib

Configuring done

Generating done
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while trying to include an external library to a CMAKE project

Andreas Pakulat-2
Hi,

On Sun, Apr 28, 2013 at 4:36 PM, maaschn <[hidden email]> wrote:
I currently try to add an external dynamiced linked library (dll) to my cmake
project. I have got the .dll and the .lib file. I spent a lot of time to
find an answer by myself but I didn't manage to find the solution. The
include works but I always get a linking error when I try to compile a
minimum solution. CMAKE throws no errors while configuring and generating
and finds the library. I hope someone had the problem before and recognizes
my error

Without the actual error you get, there's probably not many people that could help you. The files themselves look innocent enough to me.

Andreas

--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Linking error while trying to include an external library to a CMAKE project

maaschn
Thank you for your reply. I didnt add the code because it is just that common linking error which pops up. But I will show it nevertheless.

error LNK2019: unresolved external Symbol ""public: __thiscall CInterfaceLLT::CInterfaceLLT(char const *,bool *)" (??0CInterfaceLLT@@QAE@PBDPA_N@Z)" in Function "_main". C:\Users\Maaschn\Desktop\TestProg\TestProg_VS10\main.obj TestProg


this is the correspondant minimla codesnippet

#include <iostream>
#include "InterfaceLLT_2.h"
using namespace std;

int main()
{
   
        bool bLoadError;

        CInterfaceLLT* m_pLLT;

         m_pLLT = new CInterfaceLLT("LLT.dll", &bLoadError);

         cout << "Hello World!" << endl;



    return 0;
}