With the FindGSL.cmake copy to the CMake module dir, Here is my CMakeLists.txt (with TARGET_LINK_LIBRARIES) <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">

<pre><b>PROJECT</b>(test1)
<b>FIND_PACKAGE</b>(GSL)<span style="color: rgb(128, 128, 128);"></span>
<b>ADD_DEFINITIONS</b>(-Wall -O2)
<span style="color: rgb(128, 128, 128);"><i>#list all source files here</i></span>
<b>ADD_EXECUTABLE</b>(test1 main.cpp)<span style="color: rgb(128, 128, 128);"></span>
<b>TARGET_LINK_LIBRARIES</b>(test1 gsl_sf_bessel_j0)
</pre>but still got the error<br>
<br>
Linking CXX executable test1<br>
/usr/local/bin/cmake -E remove -f test1<br>
c++&nbsp;&nbsp;&nbsp; -fPIC &quot;CMakeFiles/test1.dir/main.o&quot;&nbsp;&nbsp; -o test1 -rdynamic -lgsl_sf_bessel_j0<br>
/usr/bin/ld: cannot find -lgsl_sf_bessel_j0<br>
collect2: ld returned 1 exit status<br>
<br>
for the gsl sample program<br>
<pre class="example">#include &lt;stdio.h&gt;<br>#include &lt;gsl/gsl_sf_bessel.h&gt;<br><br>int<br>main (void)<br>{<br>  double x = 5.0;<br>  double y = gsl_sf_bessel_J0 (x);<br>  printf (&quot;J0(%g) = %.18e\n&quot;, x, y);
<br>  return 0;<br>}<br><br>What should I do to make it work? I am using linux so it should work somehow. Many thanks.<br><br>zl2k<br></pre>
<br>
<br><br><div><span class="gmail_quote">On 3/13/06, <b class="gmail_sendername">Jan Woetzel</b> &lt;<a href="mailto:jw@woetzelweb.de">jw@woetzelweb.de</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<a href="mailto:kdsfinger@gmail.com">kdsfinger@gmail.com</a> wrote:<br><br>&gt; I am trying to use the gnu gsl package in vtk. The gsl is make<br>&gt; installed by gnu, not cmake. How can I use the library in my vtk<br>&gt; project? I put something like
<br>&gt; FIND_PACKAGE(GSL)<br><br>Does a &quot;FindGSL.cmake&quot; script exist and does cmake find it?<br>See the cmake&nbsp;&nbsp;FIND_PACKAGE help.<br><br>As far as I know CMake does not come with a &quot;standard&quot; find script for
<br>GSL, thus you have to write one yourself .<br>The CMake &quot;Modules&quot; directory contains examples.<br><br>We already created our own simple GSL find, see teh attached file.<br>It is simply based on &quot;gsl-config&quot;, actually and works only on Linux.
<br><br>Jan.<br><br>--<br><br>&nbsp;&nbsp;Dipl.-Ing. Jan Woetzel<br>--------------------------------------------------<br>&nbsp;&nbsp;Uni Kiel<br>&nbsp;&nbsp;Institut f. Informatik und Praktische Mathematik<br>&nbsp;&nbsp;Hermann-Rodewaldstr. 3&nbsp;&nbsp;[Raum 310]<br>&nbsp;&nbsp;24098 Kiel/Germany
<br>--------------------------------------------------<br>&nbsp;&nbsp;Tel&nbsp;&nbsp;&nbsp;&nbsp;+49-431-880-4477<br>&nbsp;&nbsp;Fax&nbsp;&nbsp;&nbsp;&nbsp;+49-431-880-4054<br>&nbsp;&nbsp;Privat +49-431-802872<br>&nbsp;&nbsp;Mob.&nbsp;&nbsp; +49-179-2937346<br>--------------------------------------------------
<br>&nbsp;&nbsp;Url&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.mip.informatik.uni-kiel.de/~jw">www.mip.informatik.uni-kiel.de/~jw</a><br>&nbsp;&nbsp;Email&nbsp;&nbsp;<a href="mailto:jw@mip.informatik.uni-kiel.de">jw@mip.informatik.uni-kiel.de</a><br>&nbsp;&nbsp;Privat <a href="mailto:jw@WoetzelWeb.de">
jw@WoetzelWeb.de</a><br><br><br><br>##<br>## Try to find gnu scientific library GSL<br>## (see <a href="http://www.gnu.org/software/gsl/">http://www.gnu.org/software/gsl/</a>)<br>## Once run this will define:<br>##<br>## GSL_FOUND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = system has GSL lib
<br>##<br>## GSL_LIBRARIES&nbsp;&nbsp; = full path to the libraries<br>##&nbsp;&nbsp;&nbsp;&nbsp;on Unix/Linux with additional linker flags from &quot;gsl-config --libs&quot;<br>##<br>## CMAKE_GSL_CXX_FLAGS&nbsp;&nbsp;= Unix compiler flags for GSL, essentially &quot;`gsl-config --cxxflags`&quot;
<br>##<br>## GSL_INCLUDE_DIR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= where to find headers<br>##<br>## GSL_LINK_DIRECTORIES = link directories, useful for rpath on Unix<br>## GSL_EXE_LINKER_FLAGS = rpath on Unix<br>##<br>## Felix Woelk 07/2004<br>## minor corrections Jan Woetzel
<br>##<br>## <a href="http://www.mip.informatik.uni-kiel.de">www.mip.informatik.uni-kiel.de</a><br>## --------------------------------<br><br>IF(WIN32)<br>&nbsp;&nbsp;MESSAGE(SEND_ERROR &quot;FindGSL.cmake: gnu scientific library GSL not (yet) supported on WIN32&quot;)
<br><br>ELSE(WIN32)<br>&nbsp;&nbsp;IF(UNIX)<br>&nbsp;&nbsp;&nbsp;&nbsp;SET(GSL_CONFIG_PREFER_PATH &quot;$ENV{GSL_HOME}/bin&quot; CACHE STRING &quot;preferred path to OpenSG (osg-config)&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;FIND_PROGRAM(GSL_CONFIG gsl-config<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${GSL_CONFIG_PREFER_PATH}
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/usr/bin/<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;# MESSAGE(&quot;DBG GSL_CONFIG ${GSL_CONFIG}&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;IF (GSL_CONFIG)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# set CXXFLAGS to be fed into CXX_FLAGS by the user:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET(GSL_CXX_FLAGS &quot;`${GSL_CONFIG} --cflags`&quot;)
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# set INCLUDE_DIRS to prefix+include<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXEC_PROGRAM(${GSL_CONFIG}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARGS --prefix<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OUTPUT_VARIABLE GSL_PREFIX)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET(GSL_INCLUDE_DIR ${GSL_PREFIX}/include CACHE STRING INTERNAL)
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# set link libraries and link flags<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET(GSL_LIBRARIES &quot;`${GSL_CONFIG} --libs`&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;## extract link dirs for rpath<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EXEC_PROGRAM(${GSL_CONFIG}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARGS --libs<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OUTPUT_VARIABLE GSL_CONFIG_LIBS )
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;## split off the link dirs (for rpath)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;## use regular expression to match wildcard equivalent &quot;-L*&lt;endchar&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;## with &lt;endchar&gt; is a space or a semicolon<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STRING(REGEX MATCHALL &quot;[-][L]([^ ;])+&quot;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GSL_LINK_DIRECTORIES_WITH_PREFIX<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;${GSL_CONFIG_LIBS}&quot; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MESSAGE(&quot;DBG&nbsp;&nbsp;GSL_LINK_DIRECTORIES_WITH_PREFIX=${GSL_LINK_DIRECTORIES_WITH_PREFIX}&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;## remove prefix -L because we need the pure directory for LINK_DIRECTORIES
<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IF (GSL_LINK_DIRECTORIES_WITH_PREFIX)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STRING(REGEX
REPLACE &quot;[-][L]&quot; &quot;&quot; GSL_LINK_DIRECTORIES ${GSL_LINK_DIRECTORIES_WITH_PREFIX} )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ENDIF (GSL_LINK_DIRECTORIES_WITH_PREFIX)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET(GSL_EXE_LINKER_FLAGS &quot;-Wl,-rpath,${GSL_LINK_DIRECTORIES}&quot; CACHE STRING INTERNAL)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MESSAGE(&quot;DBG&nbsp;&nbsp;GSL_LINK_DIRECTORIES=${GSL_LINK_DIRECTORIES}&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MESSAGE(&quot;DBG&nbsp;&nbsp;GSL_EXE_LINKER_FLAGS=${GSL_EXE_LINKER_FLAGS}&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADD_DEFINITIONS(&quot;-DHAVE_GSL&quot;)
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SET(GSL_DEFINITIONS &quot;-DHAVE_GSL&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MARK_AS_ADVANCED(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GSL_CXX_FLAGS<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GSL_INCLUDE_DIR<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GSL_LIBRARIES<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GSL_LINK_DIRECTORIES<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GSL_DEFINITIONS
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MESSAGE(STATUS &quot;Using GSL from ${GSL_PREFIX}&quot;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;ELSE(GSL_CONFIG)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MESSAGE(&quot;FindGSL.cmake:
gsl-config not found. Please set it manually. GSL_CONFIG=${GSL_CONFIG}&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;ENDIF(GSL_CONFIG)<br><br>&nbsp;&nbsp;ENDIF(UNIX)<br>ENDIF(WIN32)<br><br><br>IF(GSL_LIBRARIES)<br>&nbsp;&nbsp;IF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;SET(GSL_FOUND 1)
<br><br>&nbsp;&nbsp;ENDIF(GSL_INCLUDE_DIR OR GSL_CXX_FLAGS)<br>ENDIF(GSL_LIBRARIES)<br><br><br><br></blockquote></div><br>