integrating library causing errors C++ - c++

I am working in a VC++ 2010 windows project that incorporates DirectX SDK (June 2010), and another team generated a physics library to incorporate into the program. When I go through and perform all required calls to the library, and all. and I followed the directions that they gave to integrate the library:
extract the director containing the .h files into my c:\
in C/C++>general>Additional Include Directories place
c:\physics_core // without additional additional dependencies
then in Linker>Input>Additional Dependencies place
C:\physics_core\PhysicsCore\Release\PhysicsCore.lib // without additional additional dependencies
then include the manager, and use the namespace provided wherever the methods, and objects need to be called (intellisence even attempts to suggest auto completes correctly). but then my compiler throws the following list. I am pretty sure that the first 6 have to do with the library itself, and the others have to do with directX.
1> PhysicsCore.lib(PhysicsMgr.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
1>PhysicsCore.lib(PhysicsMgr.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Box3D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Circle3D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Box2D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>PhysicsCore.lib(Circle2D.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in MainCore.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__UpdateWindow#4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__ShowWindow#8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExW#48
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__RegisterClassExW#4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__LoadCursorW#8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcW#16
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage#4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__InvalidateRect#12
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__AddFontResourceExW#12
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__GetWindowRect#8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageW#4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage#4
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__PeekMessageW#20
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__UnregisterClassW#8
1>MainCore.obj : error LNK2001: unresolved external symbol __imp__RemoveFontResourceExW#12
1>C:\general\...\Engine\Debug\test.exe : fatal error LNK1120: 15 unresolved externals
the thing is when I roll the program back to before I integrate the Physics Library everything works like it is supposed to. the people who created the library tell me that it works fine on all the system(s) they tried to used it on, but they never attempted to use it in a windows program, and they assure me that it is nothing to do with it being a windows application. when I asked if they used any special flags like the first linker warning states they said that they used no such flag (the lead programmer didn't even know what they were, or how to set them). the build before integrating physics had directX working fine even rendering.
any help would be great.
Update: changed the Linker>input>Additional Dependencies to
C:\physics_core\PhysicsCore\Debug\PhysicsCore.lib
may need to change this under release to be the original
that fixed the first 6 errors, but the unresolved externals still exist
Update:
situation solved.
the all errors were solved by taking 2 actions regarding the same properties line.
1 insuring that a debug build of the Library was being used during debug mode.
2 checking the dependencies of the library in question, and including them if there is any overlap. as the compiler first checks the dependencies list of any libraries being used, and then checks the dependencies of the project. if there is any overlap the first one stands, and all those there after are ignored, but if the include dependencies flag is not set to true the compiler will not include them.
so the corrected line to solve the situation was in the Linker>Input>Additional Dependencies needed to be changed to:
C:\physics_core\PhysicsCore\Debug\PhysicsCore.lib // include additional dependencies
again thank you for all your help.

had to modify one of the properties lines in order to clear all errors.
first change was that the directory of the .lib had to be rectified to match that of the build Debug with Debug, and release with release.
the other issues were resolved when the "inherit from parent, or project default" check box in the library Linker was reactivated. (though the direction to incorporate the library said otherwise.

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.

unresolved external symbol inflateEnd (and others) while using boost Zlib

I'm in the process of converting 32bit project to x64. In most cases it just means appending 64 to library paths (and eventually building those libraries for x64). Now I assume all libraries are already ready and the code is also x64 compatible. But I keep getting errors for boost zlib library, like these:
error LNK2019: unresolved external symbol inflateEnd
error LNK2019: unresolved external symbol inflate
error LNK2019: unresolved external symbol inflateInit_
error LNK2019: unresolved external symbol deflateEnd
error LNK2019: unresolved external symbol deflate
error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::default_compression"
error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::deflated"
error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::default_strategy"
I enabled verbose mode for linker (in MS Visual Studio you do this by adding /VERBOSE:LIB to additional linker options). Thanks to that, I can see this output line:
Searching .\..\..\libs\boost145\stage\lib64\libboost_zlib-vc100-mt-gd-1_45.lib
That would imply that the library was found in the boost145\stage\lib64. So what should I be looking for now?
One strange thing is that file that defines the first group of missing symbols (those that are not within boost) has header files within the project, zlib.h and zconf.h. Maybe this is some hint? The zlib.h defines external symbols as:
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
Obvious question is: where the hell is lib file for this header file?
I had the same issue, to resolve the errors I download the source from zlib and built the x64 dlls/libs locally. There were a couple issues with solution file downloaded, fixes are described below.
Zlib 1.2.8 source code: http://zlib.net/zlib128.zip
Solution File for VS2012 is located at: zlib-1.2.8\contrib\vstudio\vc11\zlibvc.sln
Fixes:
Change:
<Command>cd ..\..\..\contrib\masmx64
bld_ml64.bat</Command>
to:
<Command>cd ..\..\contrib\masmx64
bld_ml64.bat</Command>
In zlibvc project properties -> Linker -> Advanced -> Image Has Safe Exception Handlers -> set to No (/SAFESEH:NO). Info about SAFESEH: Compiling libffi with VS2012 fails with fatal error LNK1281: Unable to generate SAFESEH image

'LIBCMT' conflicts with use of other libs + unresolved external symbols

I have a program using OpenGL 3.2(+libs) and FreeType2. Then an other program with Boost and OpenSSL. The OpenGL side was to make sure text could be rendered and the boost/openssl program is to do a secure login/game server.
Both programs work fine by them selfs.
However adding Boost and OpenSSL to the game(GL + freetype) project caused it to fail to link.
I have linked the following libs as well as including there includes folder.
glimg.lib
glutil.lib
glfw.lib
opengl32.lib
freetype.lib
glew32.lib
user32.lib
libeay32.lib
ssleay32.lib
The linker error is.
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__DeregisterEventSource#4
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__ReportEventA#36
1>libeay32.lib(cryptlib.obj) : error LNK2001: unresolved external symbol __imp__RegisterEventSourceA#8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteDC#4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__DeleteObject#4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetBitmapBits#12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__BitBlt#36
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetObjectA#12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__SelectObject#8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateCompatibleBitmap#12
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__GetDeviceCaps#8
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateCompatibleDC#4
1>libeay32.lib(rand_win.obj) : error LNK2001: unresolved external symbol __imp__CreateDCA#16
1>.\BasicTexture.exe : fatal error LNK1120: 13 unresolved externals
Runtime Library is set to Multi-threaded DLL (/MD)
I have no idea what to do I would really appreciate any help.
You are trying to compile with /MD, which is probably the right choice, but some code (probably one of the libraries) was built with /MT, and you can't have it both ways in the same program. You need to figure out which library was built with /MT and rebuild it with /MD.
Unresolved external error messages are produced when the compiler generates code referencing externally defined objects or functions and the linker fails to find those. To generate code invoking a function call the compiler only needs a declaration:
extern "C" BOOL DeregisterEventSource ( HANDLE hEventLog );
This is enough information to produce a call instruction (except for the target address). The extern keyword informs the compiler that the implementation is defined elsewhere. Consequently it cannot know the target address which has to be filled in later. When the compiler is done it is the linker's job to connect the pieces together. It uses the information gathered from the import libraries to look up the required offsets.
Windows API calls are easily spotted in the error log. They have an __imp__ prefix and sometimes an A or W postfix followed by #<n> where <n> indicates the number of bytes required for the arguments. In the case of a Windows API call you can then look up the function in the MSDN (like DeregisterEventSource). Towards the bottom are the Requirements where you can find the import library name.
The conflict warning indicates that not all of the modules use the same runtime library. Even though this is just a warning it is a serious issue and should be resolved. You get this warning if you mix /MD and /MT compiler switches, but also, if you mix release and debug runtime libraries (like /MD and /MDd). To diagnose this message you can use the /VERBOSE:LIB linker switch to determine which libraries the linker is searching. Additional information on this warning can be found at this MSDN link.

WMI Linker Error on x64

I'm trying to use the WMI example from msdn:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384724%28v=vs.85%29.aspx
I've copied the last set of code there verbatim into a console application in VS2008. If I have the application in release or debug for the win32 platform, it compiles (and runs) fine. If I have it in release or debug for the x64 platform, I get the following linker errors:
CppConsole.obj : error LNK2001: unresolved external symbol IID_IWbemConfigureRefresher
CppConsole.obj : error LNK2001: unresolved external symbol CLSID_WbemRefresher
CppConsole.obj : error LNK2001: unresolved external symbol IID_IWbemRefresher
CppConsole.obj : error LNK2001: unresolved external symbol CLSID_WbemLocator
CppConsole.obj : error LNK2001: unresolved external symbol IID_IWbemLocator
fatal error LNK1120: 5 unresolved externals
I've already tried putting the wbemuuid.lib into the linker input directly in the project properties, but that didn't make a difference from the pragma.
Has anybody made this work with x64? Or is there something else I'm doing wrong?
I give credit to RRUZ for this, as he/she at least put me on the right track, but as they haven't posted an answer-answer (just a comment) I can't click them for credit.
Basically, because of the work environment I'm in, the project directories are set up in a "non-standard" way. There was already a copy of wbemuuid.lib in another directory that was not the correct version (not x64), and that directory was higher on the library include list, thus never getting to the right Windows Platform library directory.
So if you ever have problems with x86 vs x64 and library includes, check your directories and check the ORDER of them as well.

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.