How do I add my libraries to the project?

Since CLion relies on CMake build system, you can do this with CMake commands. To add libraries to your project, use find_package (if you use separate libraries, for example, installed in the system) and target_link_libraries CMake commands. In target_link_libraries, specify either the variable generated by find_packages or library target name (if your library is also built by CMake and has the same parent project, so library target is accessible).

Find more details and samples in our Quick CMake Tutorial.

 

5 comments
Comment actions Permalink

Hi,

Whould be great if you could provide Clion + SDL solution, for beginners,

I checked JetBrains Quick Tutorial but i still can't handle it

Cheers,

Pavlo

4
Comment actions Permalink

P.S. to my previous message, your edit button ain't working.

i'm using linux

0
Comment actions Permalink

Pavlo, since CLion just works with CMake projects, all you need is to have a correct CMake project with SDL included. If it compiles correctly thought CMale, CLion will be able to run CMake on it and get all the necessary information.

This thread on SO has some useful information and links.

1
Comment actions Permalink

Hi!

Adding external shared libraries to my C++-Projects in Clion under Linux works well. But there are two things I can't figure out. If I have a release and a debug version of an external shared library, for example:

/usr/local/lib/libPocoFoundationd.so.60
/usr/local/lib/libPocoFoundation.so.60

Now I want to link against the debug version in a debug build, and against the regular version otherwise. I cannot find any hints how to do this. Is there a blog post, a form entry, a faq entry how this can be done?

 

The second question regards an external shared library sources. The library is not part of my project. Let say itcomes precompiled as an rpm from the distro. As it is open source there is also the source rpm. So we have

/usr/lib/libPocoFoundation.so.60

/usr/include/Poco/*

and now there is

/home/<username>/sources/Poco-1.9.0/

I know how I get CLion to recognize the first two. But how do I tell Clion about the external shared library sources? Note that I don't want to debug into the external shared library. But sometimes I just want to inspect the library sources to check for example what exception I might have to deal with.

Cheers

Uli

3
Comment actions Permalink

Здравствуйте подскажите как решить данный вопрос у меня есть вот такие библиотеки как на скриншоте

Вот путь до них C:\Users\WORK-PC\CLionProjects\untitled\lib

Что и куда мне нужно добавить чтобы они начали работать в проекте только можно подробно пожалуйста и рабочий пример.

Так же есть вот такие файлы как на скриншоте

Путь к ним вот такой C:\Users\WORK-PC\CLionProjects\untitled\bin

 

Тоже объясните различие между ними и какой вариант более предпочтителен для меня (так как я уже всё перепробовал и ноль не могу сделать так чтобы они работали хотя я точно знаю что они работают), спасибо!

0

Please sign in to leave a comment.

Have more questions?

Submit a request