theQuantumMechanic
theQuantumMechanic

Reputation: 82

__iob_func referenced in function _gsl_error when using GSL library

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;

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).

Upvotes: 1

Views: 839

Answers (1)

theQuantumMechanic
theQuantumMechanic

Reputation: 82

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!!

Upvotes: 0

Related Questions