C++ project not compiling - c++

I created an empty c++ console application with visual studio 2010 and dragged and dropped the source files from http://blogs.msdn.com/b/matthew_van_eerde/archive/2008/12/16/sample-wasapi-loopback-capture-record-what-you-hear.aspx but when I click on rebuild I get a load of errors which dont direct me anywhere in the source... The executable provided with the source works fine So can you please check it out and tell me what am I missing.
update:
Error 1 error LNK2001: unresolved external symbol _AvRevertMmThreadCharacteristics#4 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\loopback-capture.obj tr
Error 2 error LNK2001: unresolved external symbol __imp__mmioWrite#12 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\loopback-capture.obj tr
Error 3 error LNK2001: unresolved external symbol __imp__mmioCreateChunk#12 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\loopback-capture.obj tr
Error 4 error LNK2001: unresolved external symbol __imp__mmioAscend#12 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\loopback-capture.obj tr
Error 5 error LNK2001: unresolved external symbol _AvSetMmThreadCharacteristicsW#8 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\loopback-capture.obj tr
Error 6 error LNK2001: unresolved external symbol __imp__mmioOpenW#12 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\main.obj tr
Error 7 error LNK2001: unresolved external symbol __imp__mmioClose#8 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\main.obj tr
Error 8 error LNK2001: unresolved external symbol __imp__mmioDescend#16 c:\Users\Admin\documents\visual studio 2010\Projects\tr\tr\main.obj tr
Error 9 error LNK1120: 8 unresolved externals c:\users\admin\documents\visual studio 2010\Projects\tr\Release\tr.exe tr

Well if you check in your source folder, you'll see that there are a few libraries that must be linked to:
TARGETLIBS = \
$(SDK_LIB_PATH)\avrt.lib \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\winmm.lib \
In this particular case, you will want to go into your VS2010 settings for the project you've created and include these files. I believe the option will fall under Additional Dependencies, although I don't have VS2010 handy to double check.
I believe in the neighborhood of Properties > C++ > Linker > Additional Dependencies
That may not be exact, but it should get you close to where you need to be. You'll need to include avrt.lib, ole32.lib, winmm.lib.

Related

How should I deal with "Fatal error LNK1120" when I tried to compile Ipopt-3.9.3 in Windows 10 & Visual C++ 2010

all.
I’m compiling Ipopt-3.9.3 in Windows 10 & Visual C++ 2010 Express.
I’ve built the projects of libCoinBlas, libConHSL, libCoinLapack as well as libIpopt, and generated libCoinBlas.lib, libCoinHSL.lib, libCoinLapack.lib as well as libIpopt.lib in the correct paths but with some warnings.
While when I tried to build the projects of IpoptAmplSolver and hs071_cpp, there exists the following fatal errors.
5>  Generating Code...
5> Creating library Release\IpoptAmplSolver.lib and object Release\IpoptAmplSolver.exp
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>Release\IpoptAmplSolver.exe : fatal error LNK1120: 3 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
5>------ Rebuild All started: Project: hs071_cpp, Configuration: Release Win32 ------
5>  hs071_main.cpp
5>  hs071_nlp.cpp
5>  Generating Code...
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlc_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlc_
5>dlascl.obj : error LNK2019: unresolved external symbol _disnan_ referenced in function _dlascl_
5>dpotf2.obj : error LNK2001: unresolved external symbol _disnan_
5>LIBCMT.lib(wincrt0.obj) : error LNK2019: unresolved external symbol _WinMain#16 referenced in function ___tmainCRTStartup
5>Release\hs071_cpp.exe : fatal error LNK1120: 4 unresolved externals
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
Is there anyone who can kindly tell me how should I deal with it?
Thank you very much for your attention, and I’m looking forward to your kind aid.
Finally, I've solved this problem which is due to the undefined functions. I think my case is about a released software package rather than some specific procedure code, hence, it's a little different and relative simple.
Without knowing the specifics of the libraries you are using, I recommend that you try the following to deal with this error:
The error tells you that the linker is missing code for some function calls. This probably means that a library file is not found. Make sure that the linker can find all needed lib files. Check the property pages. Under the Linker->General->Additional library directories, make sure that the directories where your lib-files are located are present and under Linker->Input->Additional dependencies, make sure that the the lib-files are listed. Also make sure that the parameters are present for the different Configurations.
If this still does not help, check if your libraries depend on other libraries. These should be mentioned in the documentation of the libraries you are using.
I've not built this, but here's what I would try from the start. From what you've said, you've compiled the .lib files that it links against and it's failing during linking.
So here are your options...
1) You've either missed a .lib file in the input list for the linker.
2) The actual .lib file doesn't contain the symbol that the linker needs (you can check this by dumping the symbols of the .lib file)
3) Your .lib file is compiled with either the wrong platform than what you're linking with or with the wrong type ie. release/debug.
4) The symbols in your lib are decorated because you're compiling as C++ instead of C, or visa-versa.
If you go through the above steps above, I'm pretty sure you'll find your problem, but you've not really given enough information to properly answer your question. Personally, I'd have a guess that you're compiling C as C++ or you've got the wrong platform type set for one of your lib files.
Thank you all very much for your patient and detailed advices that inspired me, and I finally find out that I should add some C files which define the necessary functions into my project. The detailed solution is as follows.
For example, I want to eliminate
5>dlarf.obj : error LNK2019: unresolved external symbol _iladlr_ referenced in function _dlarf_
5>dlarfb.obj : error LNK2001: unresolved external symbol _iladlr_
Step 1: Run
f2c iladlr.f
In the Visual Stuido Command Prompt and generate iladlr.c.
Step 2: Add iladlr.c to my project.
Step 3: Rebuild.
Finally, everything goes well.

Chromium Embedded Framework VS2013 strings error

I am converting a project which uses CEF, from VS2010 Express to VS2013 Express. I recompiled libcef_d.lib and libcef_dll_wrapper_d.lib with VS2013 just fine. But now I have problems when I try to link the libs in my main project. How can I resolve this?
WebBrowser_Handler.obj : error LNK2001: unresolved external symbol _cef_string_utf16_clear
WebBrowserManager.obj : error LNK2001: unresolved external symbol _cef_string_utf16_clear
libcef_dll_wrapper_d.lib(browser_ctocpp.obj) : error LNK2001: unresolved external symbol __imp__cef_string_list_alloc
libcef_dll_wrapper_d.lib(cookie_manager_ctocpp.obj) : error LNK2001: unresolved external symbol __imp__cef_string_list_alloc
libcef_dll_wrapper_d.lib(drag_data_ctocpp.obj) : error LNK2001: unresolved external symbol __imp__cef_string_list_alloc
First, make sure that libcef_dll_wrapper uses the same runtime library as your project: http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx.
Second, if you build CEF from source code and you'd changed something in CEF include folder, you need to run the translator tool:
cd x:\path\to\cef\tool
translator.bat

Build C++ XPCOM dependency error

I am building my C++ XPCOM for extension with Gecko sdk 24, but I got below error:
Error 15 error LNK2001: unresolved external symbol __imp__NS_CStringContainerInit2 xpcomglue_s_nomozalloc.lib
Error 16 error LNK2001: unresolved external symbol __imp__NS_CStringContainerFinish xpcomglue_s_nomozalloc.lib
Error 17 error LNK2001: unresolved external symbol __imp__NS_CStringContainerInit xpcomglue_s_nomozalloc.lib
Error 18 error LNK2001: unresolved external symbol __imp__NS_GetServiceManager xpcomglue_s_nomozalloc.lib
Error 19 error LNK2001: unresolved external symbol __imp__NS_GetComponentManager xpcomglue_s_nomozalloc.lib
Error 20 fatal error LNK1120: 5 unresolved externals ..\..\..\firefoxExtension\xpi\components\gecko24\nsWin32Util.dll
Preprocessor:
MOZ_NO_MOZALLOC
XP_WIN
XP_WIN32
Additional Dependency:
xpcomglue_s_nomozalloc.lib
I used to build XPCOM with Gecko 10 and dependency are
nspr4.lib
xpcom.lib
xpcomglue_s_nomozalloc.lib
But I cannot find nspr4.lib and xpcom.lib in Gecko 24, So what's the correct settings for Gecko 24?
Try linking against xul.lib? Note that this is a temporary workaround, though; upstream is getting pretty downright hostile about binary extensions, and you'll probably have better luck doing things via JS-ctypes where possible. Haven't tested that against nomozalloc, though; not sure how well that will work.

error when compiling a project in VS 2010 C ++

I'm trying to compile a project that I created, a software management program, in VS 2010. In VS6 and VS2005, it compiles perfectly.
1 - visual studio 6 2 - Visual Studio 2005 3 - Visual Studio 2010
The original version has some bugs that I would like fix later, but first of all I need it to compile.
With VS 6 and VS 2005 it compiles perfectly.
I added the library #pragma comment(lib, "bufferoverflowU.lib") corresponding to each file that needs it (.cpp)
However, it did not solve anything with bufferoverflowU.lib
errors are:
1>------ Operación Volver a generar todo iniciada: proyecto: Gestion_v1, configuración: Release Win32 ------
1> StdAfx.cpp
1> WDoS.cpp
1> Helpers.cpp
1> Gestion.cpp
1> WWW.cpp
1>WWW.cpp(141): warning C4018: '<' : no coinciden signed/unsigned
1>WWW.cpp(136): warning C4101: 'dwTmp' : variable local sin referencia
1>WWW.cpp(481): warning C4244: '=' : conversion from 'DWORD' to 'char'; possible loss of data
1>WWW.cpp(482): warning C4244: '=' : conversion from 'DWORD' to 'char'; possible loss of data
1> Generando código...
1>LINK : warning LNK4108: /ALIGN specified without /DRIVER; image may not run
1>WDoS.obj : error LNK2019: unresolved external symbol ___security_cookie referenced in function "unsigned long __stdcall WDoS_HTTP(void *)" (?WDoS_HTTP##YGKPAX#Z)
1>Gstion.obj : error LNK2001: unresolved external symbol ___security_cookie
1>WWW.obj : error LNK2001: unresolved external symbol ___security_cookie
1>WDoS.obj : error LNK2019: unresolved external symbol #__security_check_cookie#4 referenced in function "unsigned long __stdcall WDoS_HTTP(void *)" (?WDoS_HTTP##YGKPAX#Z)
1>Gestion.obj : error LNK2001: unresolved external symbol #__security_check_cookie#4
1>WWW.obj : error LNK2001: unresolved external symbol #__security_check_cookie#4
1>.\Release/Gestion_v1.exe : fatal error LNK1120: 2 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Any ideas?
Thanks
Your unresolved externals are a consequence of compiling with the /GS (Buffer Security Check) compiler flag, but not linking against the CRT (/NODEFAULTLIB). If /GS is not specified it defaults to being enabled. You can try to disable Buffer Security Checks by specifying /GS-.
Alternatively you can attempt to add the pieces of code you need. __security_cookie is declared in <process.h> and defined in <gs_cookie.c> as part of the CRT source that ships with Visual Studio. Since you also explicitly specified WinMain as the entry point and don't rely on the CRT to perform the required initialization you will have to call __security_init_cookie yourself. There may be more to get this to compile, but this should serve as a starting point.
Make sure your project is not set to unicode. Your library may be that is different.
Try : Project properties -> Configuration properties -> General -> Character set = not set
Ok, try this question :
error LNK2001: unresolved external symbol

OpenGL compiling issues

I am using Visual Studio C++ and GLEW. The Project Settings are all set (Includes/Libs).
MenuState.obj : error LNK2001: unresolved external symbol __imp____glewUseProgramObjectARB
MenuState.obj : error LNK2001: unresolved external symbol __imp____glewLinkProgramARB
MenuState.obj : error LNK2001: unresolved external symbol __imp____glewAttachObjectARB
MenuState.obj : error LNK2001: unresolved external symbol __imp____glewCompileShader
MenuState.obj : error LNK2001: unresolved external symbol __imp____glewShaderSource
MenuState.obj : error LNK2001: unresolved external symbol __imp____glewCreateShader
MenuState.obj : error LNK2001: unresolved external symbol __imp____glewCreateProgramObjectARB
These are the only Messages I get. Everything worked fine until I tried to implement a Shader.
The Problem is I am working within a VM, so my question is: Does GLEW need opengl32.lib as a dependency? Because if I dont add the opengl32.lib to the Linker I get even more errors. And if so could the Problem be caused by the opengl32.lib? Because I think the opengl32.lib is the standard windows opengl32.lib, that would mean it's only opengl 1.1, and therefor it can't link...
So what is the issue about these errors?
Make sure to #define GLEW_STATIC in the project before including GLEW in Windows. Then you can just include the entire source code in your project files. Otherwise, you need to have the proper GLEW DLL file in with your executable.