Menu

Linking error: unresolved externals GSL

Help
2005-11-24
2012-07-26
  • Nobody/Anonymous

    when running the example code in the gsl documentation

    include <stdio.h>

    include <gsl/gsl_sf_bessel.h>

    int
    main (void)
    {
    double x = 5.0;
    double y = gsl_sf_bessel_J0 (x);
    printf ("J0(%g) = %.18e\n", x, y);
    return 0;
    }

    i am able to compile it, but when building, it produces the following errors

    Cpp1.obj : error LNK2001: unresolved external symbol _gsl_sf_bessel_J0
    Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    i am compiling with ms visual c++ and i have included the library and header files respectively in the lib and include path of my compiler.

    many thanks in advance for help.

     
    • Simon Martin

      Simon Martin - 2009-01-27

      Hi,

      here it works with VC2005, when I use GSL_DLL.

      But I tried to compile my project using cpptasks for Ant and then I got the LNK2019 error again. The compiler properties should be the same.

      Any hints?

       
      • Simon Martin

        Simon Martin - 2009-01-29

        Workaround for this issue:

        Use libgslcblas.lib, libgsl.lib for Ant compiling and libgslcblas_dll.lib, libgsl_dll.lib for VisualC++ compiling.

         
      • Simon Martin

        Simon Martin - 2009-01-27

        Even more strange:

        Compiling with cpptasks the linker finds only the following methods:
        _gsl_interp_accel_free gefunden.
        _gsl_spline_free gefunden.
        _gsl_spline_eval gefunden.
        _gsl_spline_init gefunden.
        _gsl_spline_alloc gefunden.
        _gsl_interp_accel_alloc gefunden.
        _IMPORT_DESCRIPTOR_libgsl gefunden.
        libgsl_NULL_THUNK_DATA gefunden.

        But the also needed method __imp__gsl_interp_linear is missing. So the GSL library files are recognized, but just one method cannot be found.

         
    • Nobody/Anonymous

      I have the same problem under the Borland C++ IDE:
      "Info :Making... Info :Linking... Error: Unresolved external '_gsl_sf_bessel_J0' referenced from..."

      I checked off "Generate underscores (Options|Project|Compiler|Compiler Output)" but get the same message.

      Could somebody help us?

       
      • Nobody/Anonymous

        did you solve it, I have the sme problem?
        beguin@et.esiea.fr

         
    • Nobody/Anonymous

      Even I am having the same issues. I did the exact steps as posted in a previous message:

      1. Within VisualStudio, go to File->New->Project, then "Visual C++ Projects," then "Win32," then "Win32 Console Application." Enter a name and click "OK." On the next screen click "Finish."

      2. In the "Solution Explorer," right click on the name of your project and go to "Properties."

      3. Under Configuration Properties->Linker->General->Additional Library Directories, type in "C:\Program Files\GnuWin32\lib"

      4. Under Configuration Properties->Linker->Input->Additional Dependencies, type in "libgslcblas.a libgsl.a"

      5. Under Configuration Properties->C/C++->General->Additional Include Directories, type in "C:\Program Files\GnuWin32\include"

      6. Under Configuration Properties->C/C++->Code Generation->Runtime Library,select "Multi-threaded DLL"

      But I still get the linking error. Can someone please help?

       
      • GnuWin

        GnuWin - 2006-12-27

        Probably you'll have to define the macro GSL_DLL; see the gsl package page (http://gnuwin32.sourceforge.net/packages/gsl.htm) or several other help postings, e.g.
        http://sourceforge.net/forum/message.php?msg_id=3675704

         
        • Steve Gardner

          Steve Gardner - 2008-02-11

          My apologies, I'm very new at this. I'm having the same problem, but I don't know how to follow the suggestion, i.e. I don't know how to define the macro GSL_DLL.

          Specifically, I get these errors from the linker:

          libgsl.a(roots_brent.o) : error LNK2019: unresolved external symbol _finite referenced in function _brent_init
          Debug/preproc.exe : fatal error LNK1120: 1 unresolved externals

          I've already followed these instructions:

          1. Download and install
            http://umn.dl.sourceforge.net/sourceforge/gnuwin32/gsl-1.0-1.exe
            (For more info, see http://gnuwin32.sourceforge.net/packages/gsl.htm)

          2. Within VisualStudio, go to File->New->Project, then "Visual C++ Projects," then "Win32," then "Win32 Console Application." Enter a name and click "OK." On the next screen click "Finish."

          3. In the "Solution Explorer," right click on the name of your project and go to "Properties."

          4. Under Configuration Properties->Linker->General->Additional Library Directories, type in "C:\Program Files\GnuWin32\lib"

          5. Under Configuration Properties->Linker->Input->Additional Dependencies, type in "libgslcblas.a libgsl.a"

          6. Under Configuration Properties->C/C++->General->Additional Include Directories, type in "C:\Program Files\GnuWin32\include"

          7. Under Configuration Properties->C/C++->Code Generation->Runtime Library, select "Multi-threaded DLL"

          Can someone help me?

           
          • gegol gegol

            gegol gegol - 2008-02-12

            you can copy the file C:\Program Files\GnuWin32\src\gsl\1.8\gsl-1.8\VC8\libgsl\Debug-DLL\libgsl_d.dll to your project's folder (my documents\Visual Studio 2008\Projects\yourProject)
            if you dont find this .dll you ca see http://www.quantcode.com/modules/smartfaq/faq.php?faqid=33

             
            • Steve Gardner

              Steve Gardner - 2008-02-19

              Sadly, even after downloading Visual Studio C++ 2005 and following the instructions at the link you gave, I'm styill getting exactly same errors as before at link time, plus a new one:

              1>preproc.obj : error LNK2019: unresolved external symbol __impCrtDbgReportW referenced in function "public: void thiscall std::Vector_const_iterator<int,class std::allocator<int> >::_Compat(class std::_Vector_const_iterator<int,class std::allocator<int> > const &)const " (?_Compat@?$_Vector_const_iterator@HV?$allocator@H@std@@@std@@QBEXABV12@@Z)
              1>libgsl.a(roots_brent.o) : error LNK2019: unresolved external symbol _finite referenced in function _brent_init
              1>Debug/preproc.exe : fatal error LNK1120: 2 unresolved externals

              I'm stumped.

               
            • Steve Gardner

              Steve Gardner - 2008-02-12

              NB: I'm using Visual Studio .NET 2003 (don't ask).

              There's no \src directory under C:\Program Files\GnuWin32. There is a \contrib directory with a similar subdirectory structure, but under C:\Program Files\GnuWin32contribgsl\1.8\gsl-1.8\ there's no VC8 subdirectory.

              In C:\Program Files\GnuWin32\lib I can see libgsl.dll.a and libgslcblas.dll.a. I tried adding them to the Additional Dependencies in my project's configuration, but it made no difference.

              In C:\Program Files\GnuWin32\bin I can see libgsl.dll and libgslcblas.dll. I tried adding them to the Additional Dependences and got a different linker error, LNK1104: Cannot open

              Despite the claim in the file C:\Program Files\GnuWin32\contrib\gsl\1.8\gsl-1.8\ReadMe_GnuWin32.txt that the files libgsl_d.dll and libgslcblas_d.dll are in the \bin directory, they aren't.

              Thanks for the link, but since I'm using VS .Net 2003, are the instructions still valid? E.g. the instructions for setting the paths don't describe what I see under options->Tools.

              Thanks for your help,

              Steve

               
    • franckie566

      franckie566 - 2007-01-27

      I have the same problem (GSL v1.8 - complete package whitout sources)
      =>
      error LNK2001: unresolved external symbol _log1p

      Do everything recommended in the above posts

      =====================
      Under Configuration Properties->Linker->General->Additional Library Directories, type in "C:\Program Files\GnuWin32\lib"

      Under Configuration Properties->Linker->Input->Additional Dependencies, type in "libgslcblas.a libgsl.a"

      Under Configuration Properties->C/C++->General->Additional Include Directories, type in "C:\Program Files\GnuWin32\include"

      Under Configuration Properties->C/C++->Code Generation->Runtime Library,select "Multi-threaded DLL"

      It seems that the libs are not well compiled

      A solution ???

       
      • cpt761

        cpt761 - 2007-07-26

        >> GSL v1.8 - complete package whitout sources
        >> error LNK2001: unresolved external symbol _log1p

        If you open the gsl/config.h you will find the line: #define HAVE_DECL_LOG1P 1
        This means that this GSL libs have been build for an environment where log1p is available (from an external library).
        If you don't have it, you have to buil GSL yourself.
        Don't worry it's really easy.


        Building GSL 1.8 under Windows StepByStep:
        Assuming you use Visual C++ 2005 - Studio Vers. 8.

        // 1) Get the sourcecode

        // 2) Configure

        • Open the config.h.msvc in the VC8 directory
        • change "#define HAVE_DECL_LOG1P 1" entry to "#define HAVE_DECL_LOG1P 0"
          (just to be on the safe side: change all #define HAVE_... 1 to 0)

        // 3) Make

        • open the visual studio solution libgsl.sln in the VC8 directory.
        • Build->Batch Build
        • Check the configurations you need (DLL/Static/Debug/Release) and build them
          (if you don't know what you need, check everything EXCEPT the 4 install_libgsl entries)

        // 4) Install

        • Open the Property Page of the install_libgsl project (SolutionExplorer->right click->Properties)
        • Select "All Configurations"
        • Go to Configuration Properties -> Build Events -> Pre-Build Event
        • Edit the command line (click [...])
        • Change the install location in the second line (to your GnuWin32 directory)
          (If you installed the gsl win32 binaries with standard paramteres that's C:\GnuWin32)
        • Build the "install_libgsl" project (SolutionExplorer -> right click -> build)

        // 4.1) Fix the directory error
        If there are no .lib or .dll files in the /lib and /bin directory the copy source directories are wrong:

        • Go to the Pre-Buil Event command line again (see Step 4)
          In my version there where whitespaces in all Debug-StaticLib, Release-StaticLib, Debug-DLL, Release-DLL entries
          If you are finished with step 3) those should be the same as your build output directories
        • Just change everything that looks like this: ../Debug - Static Lib/.. to ../Debug-StaticLib/..
          ( The same with: Release - Static Lib, Debug - DLL, Release DLL)
        • Build the "install_libgsl" project

        This should do it!
        If this solved your GSL&Windows problem, please let me know!

         
    • franckie566

      franckie566 - 2007-01-27

      Probably you'll have to define the macro GSL_DLL; see the gsl package page (http://gnuwin32.sourceforge.net/packages/gsl.htm) or several other help postings, e.g.


      Right- THis is the solution ! now linking is OK

      But my program don't launch ( under VC7.1 ) - I indicates the right path directories for dll : libgslcblas.dll libgsl.dll

      Thanks for help

       
    • franckie566

      franckie566 - 2007-01-27

      Ok It works => Mode DEBUG multi-thread shoul be also set in VC (if you are in debug)

      Yes I know, I make questions & answers :) but if
      it can help others .....

       
      • Siddharth Kant

        Siddharth Kant - 2007-02-10

        Hi,

        I am a University Student from Singapore, currently working on a simulation package for networks. I needed to use the GSL libraries, along with Microsoft Visual Studio 2005. I downloaded the GSL package for windows and was able to install the package, as well as link to my program. The program compiles and links perfectly. However, when I try to run the package, an error is displayed saying that

        *** "This application failed to start because libgsl_d.dll was not found. Re-installing the application may fix this problem" ***

        I tried to re-build the package as well as try to use the main program without calling any function listed under the GSl library, and it worked well. So i'm guessing that I need to specify the path for this DLL file somewhere.

        I am a novice at all this, and I would be highly grateful if someone could help me solve this problem.

        My Configuration Settings are :

        Additional Include Directories : C:\Program Files\GnuWin32\include

        Runtime Library : Multi-threaded Debug DLL (/MDd)

        Additional Include Library: "C:\Program Files\GnuWin32\bin";"C:\Program Files\GnuWin32\lib"

        Additional Dependencies : libgsl_dll_d.lib libgslcblas_dll_d.lib

        Thanks in advance!!

        Siddharth

         
MongoDB Logo MongoDB