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.
Related
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.
I have a c++ application built in Visual studio 2015, It seems c++ apps have need visual c++ 2015 (In my case) to be installed (on targeted windows version). Then i decided to convert my c++ source to c and use CLion 2018 for build this project. It has no error but the output executable has visual c++ 2015 (It says: vcruntime140.dll is missing) dependency again. Here is my questions:
Does C written executable's have any external dependencies ? What are those dependencies ?
Im new to CLion2018, How to build c projects to work without dependency on all windows versions and architectures ?
Is still any way to use VS2015 to create and build c projects ? (Already tried changing compile as: option to /TC and changing extensions to .c. Build was successful but Output has VCRUNTIME140.dll error).
Note1: Both output files (In CLion and VS) are working on windows 7,8.1,10 with visual c++ 2015 installed. And both have "VCRUNTIME140.dll is missing" error on raw windows 7,8.1,10 without visual c++ 2015 installed.
Note2: Don't want to pack those dll's with my file, Or installing vc++ 2015.
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!
I have a custom dll written for MATLAB and it works fine on our development machines. However, when I try it on a clean machine with no development tools, I get the message:
>> loadlibrary CMatLab CMatLab.h
??? Error using ==> loadlibrary at 279
Microsoft Visual C++ 2005 or 2008 is required to use this feature.
After some research it seemed clear that a compiler was required to parse the header file at runtime, so I installed the standard Windows SDK, ran mex -setup to select the compiler but I still get the same error message. This is what I did for select the compiler.
>> mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? mex -setup
Select a compiler:
[1] Microsoft Visual C++ 2008 SP1 in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2008 SP1
Location: C:\Program Files (x86)\Microsoft Visual Studio 9.0
Are these correct [y]/n? y
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2008 require
that Microsoft Visual Studio 2008 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
***************************************************************************
Trying to update options file: C:\Users\adriane\AppData\Roaming\MathWorks\MATLAB\R2010b\mexopts.bat
From template: D:\Matlab\bin\win64\mexopts\msvc90opts.bat
Done . . .
I really do not want to install Visual Studio on this machine as it reduces it's utility as a testbed for release builds of our other tools and software. Any ideas anyone? I see that others have the same problem but I did not see a clear solution. The OS is Windows 7 pro 64 bit. The dll was built with VS2008.
Try using the 'MFILENAME' option to loadlibrary to produce a "protofile", which can be used in the future to load the DLL via the #PROTOFILE syntax. Generate the file on your development machine, and bring it along to the test machine.
So, on the dev machine:
loadlibrary('CMatLab', 'CMatLab.h', 'mfilename', 'cmatlab_proto');
Bring along to the test machine the DLL, the file labelled 'thunk', and cmatlab_proto.m. On the test machine, run:
loadlibrary('CMatLab', #cmatlab_proto)
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.
.