Qt Creator error while linking: cannot specify link libraries for targets

I am new to Qt Creator and Cmake and I am trying to compile a simple program by linking to an existing library in Ubuntu libaspell-1.2.so.16

, which is in usr/lib

. So, I have a custom Cmake step in the build process that takes the following CMakeLists.txt

file:

cmake_minimum_required(VERSION 2.8)

project(Demo-Project)

target_link_libraries(demo libaspell-1.2.so.16)

add_executable(demo demo.cpp)

      

My demo.cpp

file is a simple function:

int main()
{
    return 0;
}

      

However, at compile time I get the following error:

CMake Error at CMakeLists.txt:5 (target_link_libraries):
  Cannot specify link libraries for target "demo" which is not built by this
  project.

      

This is such a simple program that I am trying to compile because it seems that I am doing something fundamentally wrong. I've tried linking with other library files that come with Ubuntu by default, but I'm getting the same error message.

So is the behavior higher than expected due to a simple error of mine, or is it something more complex that I need to investigate?

0


source to share


1 answer


I believe the order matters, so I would try:



cmake_minimum_required(VERSION 2.8)

project(Demo-Project)

add_executable(demo demo.cpp)

target_link_libraries(demo libaspell-1.2.so.16)

      

+1


source







All Articles