Trying to compile program that uses zlib. Link unresolved error - c++

While trying to compile program, that uses zlib, i got following errors:
Error 1 error LNK2019: unresolved
external symbol _compress referenced
in function "void __cdecl
save_image_in_pakfile(class
std::basic_ofstream > &,struct
_IplImage *)" (?save_image_in_pakfile##YAXAAV?$basic_ofstream#DU?$char_traits#D#std###std##PAU_IplImage###Z) buffer_management.obj
Error 2 error LNK2001: unresolved
external symbol
_compress fern_based_point_classifier.obj
And two more same errors but related to uncompress function.
I use the vs2008 C++, and at the project properties I added in
C/C++ : Additional include directories the path to header files of zlib.
And at linker properties I added at additional dependencies:
zlibwapi.lib and zlibstat.lib files.
How to resolv the problem?
If I made some mistakes please show me them..

Related

Live555 and Visual Studio 2010

I am trying to compile Live555 test programs in Visual Studio 2010, but I wasn't able to do so.
I compiled the libraries without any problems
BasicUsageEnvironment.lib
groupsock.lib
liveMedia.lib
UsageEnvironment.lib
but when it comes to the test programs, I just couldn't get anywhere. Here is the compiler message when I compile files in the mediaServer.
Has anyone encountered this problem before?
error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3#YAXPAX#Z)
error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2#YAPAXI#Z)
error LNK2001: unresolved external symbol ___security_cookie
error LNK2001: unresolved external symbol ___CxxFrameHandler3
error LNK2001: unresolved external symbol #__security_check_cookie#4
error LNK2001: unresolved external symbol __RTC_CheckEsp
error LNK2001: unresolved external symbol __RTC_Shutdown
error LNK2001: unresolved external symbol __RTC_Shutdown
error LNK2001: unresolved external symbol __RTC_InitBase
error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info##6B#)
error LNK2001: unresolved external symbol "public: virtual bool __thiscall Medium::isSource(void)const " (?isSource#Medium##UBE_NXZ)
<more errors>
Complete dump here: http://pastebin.com/4bVQAcdp
Update
I failed to build the project earlier because I unchecked the "Precompiled header" option when creating projects for all the libraries. When linking the libraries to my mediaServer project, VS was unable to resolve all the functions.
I was able to make it work by rebuilding them with "Precompiled header" option checked, and add #include "stdafx.h" to each and every *.cpp file.
Afterthought: I have a feeling that I only need to turn on "Precompiled header" option for the mediaServer project. Let me know if you have tried and succeeded. ;-)
Update 2
Nope. I had to turn on Precompiled Header for each and every one of the static library projects. And add #include "stdafx.h" to ~200 *.cpp files. Yep.
Update
I took a look at your full dump:
1>UsageEnvironment.lib(HashTable.obj) : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3#YAXPAX#Z)
Based on this first error, what ever source you compiled for your UsageEnviroment Lib, has a reference to a delete operator function. My guess is that either you don't have the correct source code you altered it. Can paste the UsageEnvironment.hh file contents?
I happened to be working on building this right now, I just got it working this morning, and per your request I compiled the Test Program "mediaServer". We are operating on a few assumptions here, we are assuming that you built the static libraries correctly.
Assuming the static libraries are correct this is the solution your looking for:
Include:
c:\Live555\BasicUsageEnvironment\include
c:\Live555\liveMedia\include
c:\Live555\UsageEnvironment\include;
c:\Live555\groupsock\include
$(IncludePath)
Lib Paths:
"*Insert path to your lib files here*";
$(LibraryPath)
Linker input:
Ws2_32.lib
groupsock.lib
BasicUsageEnvironment.lib
liveMedia.lib
UsageEnvironment.lib
libBasicUsageEnvironment.lib
libgroupsock.lib
Your solution folder should look like this:
Make sure the files in Bold are there.
your Source Folder should have the following files:
mediaServer:
**DynamicRTSPServer.cpp**
**DynamicRTSPServer.hh**
**live555MediaServer.cpp**
mediaServer.vcxproj
mediaServer.vcxproj.filters
ReadMe.txt
**rtcp_from_spec.c**
**rtcp_from_spec.h**
stdafx.cpp
stdafx.h
targetver.h
**version.hh**
Based on your errors its looks like you have incorrect source files included in your project, those unresolved reference don't appear anywhere in the live555 project tar file.
http://live555.com/liveMedia/public/live555-latest.tar.gz
If this solution doesn't work, please provide screen shots of your project settings for the following tabs:
include directories
Linker Input
File listing for your project folder.
Let me know if this helps, if this doesn't work we will have to look into how your static libraries were built. We need to see where in your code, those external references are being made, and what ever is making those references need to be excluded as they don't appear in the live555 archive referenced in the link below.

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

Fix LNK2019: unresolved external symbol with freeglut

Using this manual, I tried to get freeglut OpenGL application to compile on my computer. This means I:
Copied files from freeglut archive to MS program files folder
Specified freeglut.lib in additional dependencies
Set explicitly the freeglut.lib path in libraries folders
But all takes no effect. The C++ header files are found right, but the libraries not - so I get these errors:
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutMainLoop#0 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutSpecialFunc#4 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol "void __cdecl specialKeys(int,int,int)" (?specialKeys##YAXHHH#Z) referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutDisplayFunc#4 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutInitDisplayMode#4 referenced in function _wmain
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp____glutInitWithExit#12 referenced in function _glutInit_ATEXIT_HACK#8
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp____glutCreateWindowWithExit#8 referenced in function _glutCreateWindow_ATEXIT_HACK#4
1>OpenglTest.obj : error LNK2019: unresolved external symbol __imp__glutSwapBuffers#0 referenced in function "void __cdecl display(void)" (?display##YAXXZ)
So my questions:
Could you guess what may be wrong? (not easy, but I cannot find this out obviously)
Is there some other manual google didn't find, but better than the one I used?
Is there some other archive I should download?
My C++ code comes from here. All functions are well found in freeglut header files. Just the libraries are missing.
This seems like a C vs C++ linkage issue. You are compiling a C source code from there as a C++ code (maybe you saved it with C++ specific extensions and the compiler assumed it is C++).
C++ will mangle function names. For example __imp__glutMainLoop#0 is most probabley a call to glutMainLoop in your source code.
The library must have been from a C code. Hence it will have a non mangled version of the function simply as glutMainLoop. That's why it can not be found.
The solution is either compile your code as C code or use extern "C".
EDIT: Some Links on how to deal with with C/C++ linkage issues (Moved from the comments).
http://www.thegeekstuff.com/2013/01/mix-c-and-cpp/
Combining C++ and C - how does #ifdef __cplusplus work?
http://www.parashift.com/c++-faq-lite/c-calls-cpp.html

Protobuffers in c++ and error LNK2019: unresolved external symbol

I am new to c++ and visual studio 2012 so probably the problem is between the screen and the chair. I performed the following steps;
I made a simple proto file with the option optimize_for = LITE_RUNTIME
Create the matching h and c files with protoc
Compiled the library libprotobuf-lite.lib
Created a new console Visual Studio 2012 project.
Copied the libprotobuf-lite.lib where my single source file is.
Created a new folder named protobuffers
Copied the c, h and the google directory from the protobuffers src directory to the protobuffers folder
Added the protobuffers folder as an Additional Include Directory
Added the library file to the linker through Additional Dependencies
Compiled the following source file;
#include <iostream>
#include "protobuffers\genome.pb.h"
int main()
{
genomeMessage::Genome genome;
return 0;
}
Stuck... I get the following error;
1>Source.obj : error LNK2019: unresolved external symbol "public: __cdecl genomeMessage::Genome::Genome(void)" (??0Genome#genomeMessage##QEAA#XZ) referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl genomeMessage::Genome::~Genome(void)" (??1Genome#genomeMessage##UEAA#XZ) referenced in function main
1>C:\Projects\testproto\x64\Debug\testproto.exe : fatal error LNK1120: 2 unresolved externals
So I know it is not a missing lib file because if I move the lib file the linker complains that it can't find it. The problem is that I have no clue how to fix this ... anyone?
According to this message:
1>Source.obj : error LNK2019: unresolved external symbol "public: __cdecl genomeMessage::Genome::Genome(void)" (??0Genome#genomeMessage##QEAA#XZ) referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl genomeMessage::Genome::~Genome(void)" (??1Genome#genomeMessage##UEAA#XZ) referenced in function main
the source file that declares genomeMessage::Genome::Genome(void) and genomeMessage::Genome::~Genome(void) is not part of your project.
In particular, it sounds like you haven't added the genome.pb.cc file (which is created by the Protocol Buffers compiler) to your project.

error LNK2019: unresolved external symbol _Direct3DCreate9Ex#8 referenced in function "protected: XYX()"

I am getting the following LINK error while compiling my C++ solution:
error LNK2019: unresolved external symbol _Direct3DCreate9Ex#8
referenced in function "protected: XYX()
The symbol "Direct3DCreate9Ex' is defined in "ddraw.h" header file found in "C:\Program Files\Microsoft SDKs\Windows\v7.0\Include". And verified that the header file "ddraw.h" is present in this location. Also I have included this path in VS settings "Tools-->Options-->VC++ Directories -> Includes".
But still I am getting the link error as "error LNK2019: unresolved external symbol _Direct3DCreate9Ex#8 referenced in function "protected: XYX()" ".
Can anyone kindly help me in getting rid of this link error while compiling my C++ solution.
I am using VS 2008 on 64 bit Win7.
Thanks in advance.
Based on reference page for Direct3DCreate9Ex you need to link with D3D9.lib.