X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Lewis Hyatt Subject: Re: Help with strange compiler error linking to GSL Date: Thu, 05 Jul 2007 14:22:16 -0400 Lines: 86 Message-ID: References: <002701c7bf2d$beddf800$0701a8c0 AT lee8075b> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) In-Reply-To: <002701c7bf2d$beddf800$0701a8c0@lee8075b> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Lee Rhodes wrote: > Hello, > I have installed the GSL libs via setup and am trying to get the following > example program to work: > > #include > #include > > int main (void) > { > double x = 5.0; > double y = gsl_sf_bessel_J0 (x); > printf ("J0(%g) = %.18e\n", x, y); > return 0; > } > > The compiler/linker is able to locate the header ok, but the error message I > get on the line that calls the function is: > > undefined reference to `_gsl_sf_bessel_J0' > > Somehow the function name got mangled with an added underscore, and of > course, it doesn't exist. > It compiles and links fine for me using "gcc t.cpp -lgsl". Are you sure you are putting -lgsl in the right place on the command line (ie, at the end)? If you are, try compiling with "gcc -v -v t.cpp -lgsl", here is that output for me: $ gcc t.cpp -v -v -lgsl Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --verbose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug Thread model: posix gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) /usr/lib/gcc/i686-pc-cygwin/3.4.4/cc1plus.exe -quiet -v -v -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api -idirafter /usr/local/lib/../../include/w32api t.cpp -quiet -dumpbase t.cpp -mtune=pentiumpro -auxbase t -version -o /cygdrive/c/DOCUME~1/Lewis/LOCALS~1/Temp/cc1w4jdk.s ignoring nonexistent directory "/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/include" ignoring duplicate directory "/usr/local/lib/../../include/w32api" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++ /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/i686-pc-cygwin /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward /usr/local/include /usr/lib/gcc/i686-pc-cygwin/3.4.4/include /usr/include /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../include/w32api End of search list. GNU C++ version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) (i686-pc-cygwin) compiled by GNU C version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125). GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 t.cpp:10:7: warning: no newline at end of file /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/as.exe -o /cygdrive/c/DOCUME~1/Lewis/LOCALS~1/Temp/ccGPvaYJ.o /cygdrive/c/DOCUME~1/Lewis/LOCALS~1/Temp/cc1w4jdk.s /usr/lib/gcc/i686-pc-cygwin/3.4.4/collect2.exe -Bdynamic --dll-search-prefix=cyg /usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../crt0.o -L/usr/local/lib -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4 -L/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../.. /cygdrive/c/DOCUME~1/Lewis/LOCALS~1/Temp/ccGPvaYJ.o -lgsl -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc It also works fine with g++ for me. -Lewis -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/