VS2015 gsl compilation error - c

I am trying to compile a c program that uses the gsl library via the Visual Studio 2015. I have tried almost everything I have found online but nothing has worked so far.
The error I obtain is
Severity Code Description Project File Line Error LNK2019 unresolved
external symbol ___iob_func referenced in function
_gsl_error GSLExample C:....\gsl.lib(error.obj) 1
and more alike
In particular I tried answered Aug 8 at 19:43 in
unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2
More detail about how to implement this answer would be helpful
Thank you

You probably downloaded a library compiled with Visual Studio 2013 or earlier.
A change in Visual Studio 2015 broke backwards compatibility!
You just need to recompile the library with Visual Studio 2015, use that and it will work!

Related

Compiling udis86 with visual studio 2019 gives me an unresolved external symbol

I'm using Visual Studio 2019 and I'm trying to compile an UEFI driver, that uses udis86(https://github.com/vmt/udis86) with the __UD_STANDALONE__ preprocessor definition and the /NODEFAULTLIB linker option set.
This gives me this error
I have tried to set the _NO_CRT_STDIO_INLINE preprocessor definition, like replied to some similar questions to mine, but it just changes the error to
Does anyone have an idea on how to fix this error ?
Thanks in advance
Maybe you could take a standalone vsnprintf implementation from somewhere to satisfy the dependency.
e.g.
https://github.com/MrBad/vsnprintf
or the Linux kernel one?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/vsprintf.c
I resolved my issue by using the VCPKG version of udis86, but I still don't know why this error was appearing.

LINK : fatal error LNK1146: no argument specified with option '/MT'

I'm using Visual Studio 2019 and trying to compile a program that was compatible with Windows XP 32-bit.
When I first ran my .exe on my VM it said that it wasn't compatible with Win32.
I've then changed the Platform Toolset to Visual Studio 2017 - Windows XP (v141_xp).
Now it says I'm missing a VCRUNTIME140d.dll, and following instructions that said to change my Runtime Library to /MT I get the error stated in the title.
Any suggestions would be very much appreciated.
VCRUNTIME140d.dll is Visual C++ Redistributable for Visual Studio 2015.You need to download and install. And this is Debug versions of DLL. You must compile in Release mode.

Visual Studio 2015 link error LNK2005

I need to link a static library against a given object file. I neither have the source code of that file nor any influence on it.
When using Visual Studio 2010 I can create a library and link it against the given file.
On a different machine I only have VS 2015. When I build and link my C-Code to the given lib I get the following error:
LIBCMT.lib(vfprintf.obj) : error LNK2005: __vfprintf_l already defined in c_fun.obj
LIBCMT.lib(printf.obj) : error LNK2005: _printf already defined in c_fun.obj
For testing purpose I use the following simplified code:
#include <stdio.h>
void c_fun(double C_IN, double *C_OUT)
{
*C_OUT = C_IN * 2.0;
printf("Hallo C!\n");
}
When I commend the printf line out, then I can successfully link the lib created with VS2015 but I need the printf statements for visualization purpose.
To compile my lib I use the same parameters on the command line. Is there a compiler or linker option to generate a VS 2010 compatible library?
When I use dumpbin /all for both libs, I get the following outputs:
Lib created with VS2010:
2 public symbols
BC _F_FUN
310 _c_fun
Lib created with VS2015:
7 public symbols
1DE _F_FUN
432 ?_OptionsStorage#?1??__local_stdio_printf_options##9#9
432 ___local_stdio_printf_options
432 __real#4000000000000000
432 __vfprintf_l
432 _c_fun
432 _printf
I would expect to get the same symbols with both versions.
The compiler options i use are both times "/MT /W3 /EHsc /c"
The Visual Studio 2015 compilers aren't compatible with object files created with earlier versions of the compiler. There was a major reorganization of the C runtime library that broke the C object level backwards compatibility that Visual Studio used to have. You'll need to use the older compiler to compile and create the static library and then link it with the object file created by the older compiler. You can do this in Visual Studio 2015 by installing Visual Studio 2010 and in your Visual Studio 2015 project properties selecting "Visual Studio 2010 (v100)" under Configuration Properties -> General -> Platform Toolset.

Visual Studio unresolved symbol _InterlockedCompareExchange

I'm porting some C code from GCC into Visual C++ and I'm running into this error when trying to add SQLite3 as a static lib.
I've compiled SQLite as another Visual Studio project, but when I try to add sqlite3.lib in Properties->Liner->"Additional Dependencies" I get the following error:
error LNK2001: unresolved external symbol _InterlockedCompareExchange | File sqlite3.lib(sqlite3.obj)
It seems to be referring to this function, but that's a bit over my head.
Thanks!
SQLite's system call redirection mechanism tries to access InterlockedCompareExchange through a function pointer. This does not work on x64 architectures, where it is a macro.
This is fixed ([1], [2]) in version 3.8.6.

error LNK2001: unresolved reference with Pro*C code with Visual C++

I'm getting an error when trying to build a DLL file with a C file preprocessed with Pro*C, the command I'm using to build my dll is:
link /NOLOGO /DLL /SUBSYSTEM:WINDOWS /NODEFAULTLIB:libc.lib /IMPLIB:orasql11.lib /IMPLIB:orasqx11.lib /OUT:qvc.dll\
/IMPLIB:oraxa11.lib /IMPLIB:oci.lib \
/LIBPATH:"$(ORACLE_HOME)\precomp\lib\msvc" /LIBPATH:"$(ORACLE_HOME)\precomp\lib" #files.lnk
The error is:
error LNK2019: unresolved external symbol _sqlcxt
How can I fix this?
The /IMPLIB option is to specify a name for an import library that's being created - instead you want to have the linker use the ProC libraries as input:
link /NOLOGO /DLL /SUBSYSTEM:WINDOWS /NODEFAULTLIB:libc.lib orasql11.lib orasqx11.lib /OUT:qvc.dll\
oraxa11.lib oci.lib \
/LIBPATH:"$(ORACLE_HOME)\precomp\lib\msvc" /LIBPATH:"$(ORACLE_HOME)\precomp\lib" #files.lnk
I got the same message trying to link an oracle database application using the same visual C++ 2005 project as before but with oracle12c instead of oracle 11.
It seems that the orasql12.lib was generated with a code that add an underscore as prefix but visual studio needs an import library without leading underscore.
So I fix this problem by regenerating the orasql12.lib. For this, you must use the DUMPBIN and LIB commands in a visual studio tool command line console. Open the VC++ command line console in the directory where the oraclesql12.dll was installed and type:
DUMPBIN /EXPORTS orasql12.dll > orasql12.def
this will generate a def file that you have to edit in order to remove all except the name column symbols and add two header lines, the firts lines of your orasql12.def file will look like this:
LIBRARY orasql12
EXPORTS
DSNTIAR
ORASQL8
...
then use LIB command in VC++ tools console and type:
LIB /DEF:orasql12.def /MACHINE:X86 /LIBPATH:D:\users\Appl\oracle\client_12c\bin
(LIBPATH is set to the orasql12.dll installation directory, change X86 if needed)
A new orasql12.lib has been generated without leading underscores.
error LNK2019: unresolved external symbol _sqlcxt on **Visual Studio VC++ Error Solved**
If you are using Oracle Client you might have this Error because of the corrupted Libraries (may be) . such as orasqx12.lib and orasqx12.lib . There might be some bugs with these libraries. if you have downloaded Oracle Client 12.2.0.1 or may be with Earlier Versions you will be fine. However if you are downloading 64bit version of Oracle database or Oracle Client
you must change your Visual Studio Platform to **64bits instead of 32bits at the Configuration Manager of the Project Solution.**
If you are a beginner and trying to learn how to use Pro* C with your Visual Studio , You might want to Download the Oracle Database 11g release 2 Express Version. because that library file (orasql11.lib) works fine without giving you this Error **_sqlcxt .**
I would say this Error is caused by the library, Its looking for function defined in that library and it is could not find it , may be because its corrupted. I am not sure. since there are a lot of people have this problem and I decided to post this. Also this is only for the beginners who are trying to learn Pro* C with Visual Studio. Not for the Experts. also You may not get this Error with the Standard Edison of Oracle database.
.

Resources