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.
Related
I've built a statically linked library from a project which I downloaded from here InfinityHook project
I'm getting the following two (2) errors in Visual Studio 2017 when I reference any of the functions which are available for export.
Error LNK2019 unresolved external symbol IfhInitialize referenced
in function
DriverEntry HelloWorld_Driver C:\Users\MYSELF\Documents\Visual Studio
2017\Projects\HelloWorld_Driver\HelloWorld_Driver\Driver.obj
Error LNK1120 1 unresolved externals
HelloWorld_Driver C:\Users\MYSELF\Documents\Visual Studio
2017\Projects\HelloWorld_Driver\x64\Debug\HelloWorld_Driver.sys
I get the same type of error when I reference another function from the same infinityhook.h header file and which is statically built in the libinfinityhook.lib file. So basically none of the functions that are "exported" are available to be called and are giving linking errors when referenced from the main project. Before arriving at this conclusion I tried several possible solutions found on StackOverflow but none of them have worked. I've added the statically linked file libinfiinityhook.lib in Visual Studio 2017 Configuration Properties->Linker->Input->Additional Dependencies and the file is located in the correct directory on disk so the linker can find it. But I also added the directory path to this library file to the following settings in VS2017 Configuration Properties->Linker->General->Additional Library Directories.
If anyone else is having the same issue the problem was that I was calling the two C++ defined functions, declared as C++ functions from a "C" based module. Recompiled the static library with the keyword extern and all is working as it should.
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.
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 am trying to compile the Win32 Example of the Parrot ARDrone SDK v1.8 using Visual Studio 2012 Express for Windows Desktop. I am running Windows 7 64-bit. The SDK is written in C, not C++.
I've managed to get through every error so far, but this one has me stumped.
When Run, I get these 3 messages in the Error List:
Warning 1 warning LNK4001: no object files specified; libraries used C:\Users\Netex\Desktop\ARDrone_SDK_Version_1_8_20110726\ARDrone_SDK_Version_1_8_20110726\Examples\Win32\VCProjects\ARDrone\Win32Client\LINK Win32Client
Error 2 error LNK2001: unresolved external symbol _mainCRTStartup C:\Users\Netex\Desktop\ARDrone_SDK_Version_1_8_20110726\ARDrone_SDK_Version_1_8_20110726\Examples\Win32\VCProjects\ARDrone\Win32Client\LINK Win32Client
Error 3 error LNK1120: 1 unresolved externals C:\Users\Netex\Desktop\ARDrone_SDK_Version_1_8_20110726\ARDrone_SDK_Version_1_8_20110726\Examples\Win32\VCProjects\ARDrone\Debug\Win32Client.exe Win32Client
I've tried many suggested solutions, including setting the SubSystem in Linker->System to "Not Set" and setting the entry point manually, which gets rid of the 2 errors and replaces it with:
`Error 2 error LNK1221: a subsystem can't be inferred and must be defined'
I've tried setting the Platform Toolset to v90 (which it was originally compiled in, I believe), which gets rid of the warning, but the errors persist.
QUESTION: What is causing these messages, and how can I fix it? Is it because I am trying to compile a Win32 console program on a 64-bit system?
Any help is much appreciated,
Dan
I'm using Qt VS Tools extension with Visual Studio 2019 and working in C++ on a Qt Gui Application created using the new project wizard. In my project properties under Configuration Properties | Linker | System, I have set SubSystem to "Console (/SUBSYSTEM:CONSOLE)" to cause a console window to come up alongside my GUI when debugging. This allows me to view outputs that I've added using qDebug like this:
qDebug() << "Testing";
What I have found is that if I perform a Build | Clean Solution and then Build | Build Solution, I get this error on the first build:
LNK2001 unresolved external symbol mainCRTStartup
Initially I was trying to figure out how to fix this (and ran across this post), but then I found that if I repeated Build | Build Solution the error goes away on subsequent builds, so my solution is to remember to build twice after a clean.
To see what would happen if I had never changed SubSystem to "Console (/SUBSYSTEM:CONSOLE)", I created a new Qt Gui Application project using the wizard. In this project SubSystem is set to "Windows (/SUBSYSTEM:WINDOWS)" as the default. Again I get the error on first build after a clean, but in this case it is a different unresolved symbol:
LNK2001 unresolved external symbol WinMainCRTStartup
Although I'm curious about the cause of the problem, the build twice solution is working for me for now.
in my case, the solution was to explicitly name the 'entry point', e.g. with the command line:
ml64 main.asm /subsystem:console /entry:main
the last option: '/entry:main' was crucial
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.
.