[ITK Community] [Insight-users] [Insight-developers] Problem linking libraries ITK-Cmake

Jon Haitz Legarreta jhlegarreta at vicomtech.org
Wed Jan 8 17:58:34 EST 2014


Hi Alessio,
are you building *OtherLibrary* as a library itself (be it dynamic or
static)?

If you want to use it as a library you shoud build it first (i.e., you
should write its own CMakeLists.txt, configure and generate the project,
and build it), and then you should be able to link against and use it from
other projects.

HTH,
JON HAITZ


On 8 January 2014 22:48, Alessio Mazzarini <alessiomazzarini89 at gmail.com>wrote:

> Hello everyone. I have a problem to link together some libraries with my
> ITK project.
> I made my own filter "MyOwnFilter.h" and its implementation
> "MyOwnFilter.hxx". In this filter i want to use some methods and members
> defined in another library called "OtherLibrary.h", which are implemented
> in "OtherLibrary.cpp".
> In the header of MyOwnFilter i write: #include "OtherLibrary.h"
> All of these files are in the same directory.
> When i run Cmake no errors appear, but when i try to "make" the file in
> the directory the terminal gives me this error:
>
> .....$ make
> [100%] Building CXX object CMakeFiles/MyProject.dir/main.cxx.o
> Linking CXX executable MyProject
> /usr/bin/ld: cannot find -lOtherLibrary
> collect2: ld returned 1 exit status
> make[2]: *** [MyProject] Error 1
> make[1]: *** [CMakeFiles/MyProject.dir/all] Error 2
> make: *** [all] Error 2
>
>
>
>
> My CmakeLists File is the following:
>
> PROJECT (MyProject)
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
>
> FIND_PACKAGE (ITK REQUIRED)
> INCLUDE (${ITK_USE_FILE})
>
> ADD_EXECUTABLE (MyProject main.cxx)
>
> TARGET_LINK_LIBRARIES(MyOwnFilter    OtherLibrary ${ITK_LIBRARIES})
>
>
>
> I am quite new in C++ and ITK and probably i'm missing something. can
> someone help me?
> Regards,
> Alessio
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140108/b00a9e8b/attachment.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

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

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list