How to use or add a static library (.a) into a C++ project in CLion under Linux

已完成

I would like to know , how to specify the STATIC Library path in CMakeLists.txt to use a static library (.a file) in C++ Linux project in CLion. I have attached the print screen of my application and having error during the BUILD of the application. 

1. Library name = Engine (libEngine.a) . This library is present in /home/public/projects/lib

2. Main application - Main.cpp (project name untitled)

3. The main.cpp is using the method engine::PrintMessage()

I am getting the following error:

/opt/clion-2018.2.3/bin/cmake/linux/bin/cmake --build /home/public/Projects/CLionProjects/untitled/cmake-build-debug --target untitled -- -j 1
-- Configuring done
CMake Error at CMakeLists.txt:8 (add_library):
No SOURCES given to target: Engine

1

The issue got resolved. The following is a working CMakeLits.txt

 

cmake_minimum_required(VERSION 3.12)
project(untitled)

set(CMAKE_CXX_STANDARD 14)

link_directories(/home/public/projects/lib)

add_executable(untitled main.cpp)
target_link_libraries (untitled LINK_PUBLIC Engine)

 

 

1

请先登录再写评论。