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
Related
I'm trying to replicate a bug from a legacy VB4 application. The EXE itself doesn't have any Windows APIs in the import table; instead they are all loaded from the VB runtime DLL.
I want to recreate a similar scenario but using C in Visual Studio. Later I will create my equivalent of the runtime DLL with Windows API imports, however the first step is to ensure no Windows APIs are in the import table within my EXE.
So far I have removed nearly everything from import table by using /SUBSYSTEM:CONSOLE, removing all .LIB from Linker -> Input -> Additional Dependencies , and setting runtime library to Multi-threaded Debug (/MTd).
However kernel32.dll APIs are still in the import table. While I realise /SUBSYSTEM:NATIVE is typically for drivers, I'm not sure if that's what I need to use, however I couldn't get a minimal application (i.e. one that launches, then exits without crashing) to compile with that option.
If I use Linker -> Input -> Ignore All Default Libraries -> Yes (/NODEFAULTLIB) I get the following errors:
Severity Code Description Project File Line Suppression State Suppression State
Error LNK2001 unresolved external symbol _mainCRTStartup Minimalist C:\Users\chentiangemalc\source\repos\Minimalist\Minimalist\LINK 1
Error LNK2019 unresolved external symbol __RTC_CheckEsp referenced in function _main Minimalist C:\Users\chentiangemalc\source\repos\Minimalist\Minimalist\Minimalist.obj 1
Error LNK2001 unresolved external symbol __RTC_InitBase Minimalist C:\Users\chentiangemalc\source\repos\Minimalist\Minimalist\Minimalist.obj 1
Error LNK2001 unresolved external symbol __RTC_Shutdown Minimalist C:\Users\chentiangemalc\source\repos\Minimalist\Minimalist\Minimalist.obj 1
The code I'm trying to compile has no includes and is just:
int main()
{
}
Raymond Chen's comment sent me in the right direction. To create this program in Visual Studio 2019 used
New Project | C++ Console Program
Renamed .cpp to .c (If you want to create a C program)
Replaced code with custom entry point:
int myMain()
{
}
In Project properties | C/C++ Code Generation set Basic Runtime checks to nothing (erase the text), set Runtime library to Multi-threaded Debug (/MTd) for debug build or Multi-threaded (/MT) for release build, set Security Check to Disable Security Check (/GS-)
In Project properties | Linker | Input | remove everything from Additional Dependencies and set Ignore All Default Libraries to Yes (/NODEFAULTLIB)
In Project properties | Linker | Advanced set Entry point to myMain
You now have a program with a completely empty import table.
I have one windows project built in VS 2015 in windows7. Now I have to use one third party library (implemented in C) built in Mingw - 64 bit (for windows). When I try to link this library I am getting one compilation error :--
Unresolved external symbol __chkstk_ms.
Now I have resolved this issue by linking 2 more libs - libgcc.a and libssp.a.
But after, that when I run my application, I have started getting memory exception in some routines which was working fine previously.
I have doubt I should not solve this compilation error by using these 2 libraries (as these are not windows). Instead of it, there should be some windows / VC run time library which should be providing implementation of this routine.
Can someone please suggest right way to resolve this linking error.
When building my application in Debug mode: The build works. The application works.
When building my application in Release mode, I get the following error message
error LNK2019: unresolved external symbol __imp__GetClassNameA#12 referenced in function _eachWindow#8
All implementation files of my application have a .c extension; that however doesn't mean I would know which compiler is used by visual studio.
From the documentation of GetClassNameA I can see that a library User32.lib is required. I have found a library with that name in
C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib>
I have added that directory to the property pages:
Configuration Properties > Linker > General > Additional Library
Directories
but that did not help. I am still receiving that error message.
Thanks for help. I know this question has been asked before, but the previous answers did not help me.
Please help in baby steps, I am still overwhelmed by Windows programming.
Does _eachWindow call GetClassName? Then you need to link user32.lib. Check the additional dependencies in the project's linker settings, not the additional library directories.
– dxiv
dxiv's comment … makes the application work. – chris j
A windows application I've been working on, is due to delivred without the use of CRT.
There's a few good articles descirbing the guidlines and benefits of doing so (none of which I could find upon writing this question - sorry) . Other then not using CRT symbols explicitly, it's all about linker and compailer configuration. My Release and Debug configurations are nearly identical now , and both specify /NODEFAULTLIB:"LIBCMT" only diffrence is the Run time flag /MT (in Release) vs. /MTd (in Debug) - that is required as I'm using __try/__except syntax for SEH, and so the only needed function is _except_handler3(). However, the Debug version is beeing built successfully, and the Release version fail with Unresolved Symbol _except_handler3 linkage error. When forcing Release version to compile with /MTd - this issue is solved.
How is that possible? which .lib contains the _except_handler3 export? and how can I solve this?
For an application without CRT see: http://blog.kalmbach-software.de/2008/02/02/smallest-application-size-for-win32-console-application/
But if you want to use __try / __except you need to use the CRT; or you need to write your own "_except_handler3".
See also: _except_handler3
Also you have the CRT source, and you can take a look into the source, to see what it is doing!
See: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src
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.
.