1

Using GSL library 2.4 on Visual Studio 2017 and getting these errors on compile and run,

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2019 unresolved external symbol ___iob_func referenced in function _gsl_error    
ImplementerGSL  C:\Users\MyUserName\source\repos\ImplementerGSL\ImplementerGSL\gsl.lib(error.obj)   1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol ___iob_func  ImplementerGSL  
C:\Users\MyUserName\source\repos\ImplementerGSL\ImplementerGSL\gsl.lib(stream.obj)  1   
Severity    Code    Description Project File    Line    Suppression State

Error   LNK2019 unresolved external symbol _fprintf referenced in function _gsl_error   ImplementerGSL  
C:\Users\MyUserName\source\repos\ImplementerGSL\ImplementerGSL\gsl.lib(error.obj)   1   

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol _fprintf ImplementerGSL          
C:\Users\iTzEinstein118Xx\source\repos\ImplementerGSL\ImplementerGSL\gsl.lib(stream.obj)    1

Further details about machine and project;

  • Visual Studios 2017 latest update on Fall Creators Update
  • Coding in C (not C++)
  • GSL is GNU Scientific Library, not to be confused with GSL.Microsoft
  • Latest version of GSL library installed at C:/gsl. Known to be compatible with VS2017
  • Solution properties has been edited to point to GSL libs, Additional* include directories: C:\gsl\include Additional library directories: C:\gsl\lib Additional dependancies : gsl.lib;cblas.lib Preprocessor definitions : _GSL_DLL

My goal eventually is to be using the library for another project. However, I can't get this simple test code to work. The code is written in C, VS2017 has the C++ libraries installed and so forth. Source files have been renamed to .c rather than .cpp.

My code:

#include "stdafx.h"
#include <stdlib.h>
#include <gsl/gsl_sf_bessel.h>


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

and then my stdafx header file,

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>

I have done a fair bit of research now and can't seem to find anything to fix this problem specifically. Sorry if this is a duplicate answer, but if there is another question out there that does solve this problem I would love to know about it! Thanks for any help in advance. Ps. New to C but familiar with C#.

EDIT UPDATE*: added legacy library, but this still leaves unresolved external symbol __iob_func(first two errors).

  • [Related](https://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2)? – user58697 Mar 17 '18 at 01:20
  • @user58697 Thanks for the pointer, added the reference to the legacy libraries and this fixes half the issue, but leaves me with __iob_func as an unresolved symbol still. – theQuantumMechanic Mar 17 '18 at 03:14
  • 1
    If your libraries were built with a previous version of Visual Studio you might need to rebuild them. – Dima Chubarov Mar 17 '18 at 03:42
  • You say your VS2017 GSL library binaries are installed under `C:\GSL` but your error message indicates that your build uses GSL binaries installed under `C:\Users\MyUserName\source\repos\ImplementerGSL`. Probably the latter were built with VS2015. – Dima Chubarov Mar 17 '18 at 03:46
  • @DmitriChubarov The GSL Libraries are actually installed at the top level of the C drive, the error directory points to my Source code implementing it. – theQuantumMechanic Mar 17 '18 at 06:32
  • @DmitriChubarov also, not being familiar with C maybe this is different. But to recompile for a new VS, I need the source code I thought. The library I have only includes header files and various libs. How do I go about doing this? – theQuantumMechanic Mar 17 '18 at 06:34
  • Sorry, I am probably misreading this `C:\Users\iTzEinstein118Xx\source\repos\ImplementerGSL\ImplementerGSL\gsl.lib` as the indication that `gsl.lib` is found in your local directory. (that's a sarcastic remark) – Dima Chubarov Mar 17 '18 at 06:34
  • @DmitriChubarov as far as I understand it, that's my source codes local reference to it. I may be wrong. However, I can quite clearly see that tee library is installed at the top level of my C drive. – theQuantumMechanic Mar 17 '18 at 07:35
  • @AlbertFerguson My hypothesis is that you have two versions of the library installed (one at the top level and another in the user directory) and they are compiled against different versions of system libraries. – Dima Chubarov Mar 17 '18 at 08:36

1 Answers1

0

So after a lot more digging and fiddling, I have found a workaround.

By installing the Nuget package locally as apposed to at C drive top level. This means just adjusting all the linker inputs and such. I am farily sure the reason this works is due to the NuGet packages being compile straight for VS2017 and thereby completely avoiding any build/compile issues between VS2017 and VS2015.

Thanks for the pointers and comments! Actually pointed me to dig a little deeper into some other ideas and find a solution!!