Problems when trying to add libcurl as a Reference [duplicate] - c++

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 6 years ago.
I'm trying to include libcurl into my C++ Project, therefore i built the .lib file placed it in a folder called "curl/lib" and then i copied the included folder from the curl folder i downloaded into "Curl/" (i got that from a tutorial online...). Then i copied that "curl" folder i created into the directory where my program is located, then i added the curl path to "Additional Include Directories" und "C++/General" and "Linker/General" in my Project Properties. Then i created a piece of code that uses stuff from that uses code from curl.h (i included that). And the codingg looked fine and there were no errors, but then i built my Project and i got a "fatal error LNK1120: 6 unresolved externals" error and a bunch of "LNK 2019"-errors, told me where the unresolved symbols are:
1>dll_load.obj : error LNK2019: unresolved external symbol curl_easy_cleanup referenced in function "void __cdecl lel(void)" (?lel##YAXXZ)
1>dll_load.obj : error LNK2019: unresolved external symbol curl_easy_strerror referenced in function "void __cdecl lel(void)" (?lel##YAXXZ)
1>dll_load.obj : error LNK2019: unresolved external symbol curl_easy_perform referenced in function "void __cdecl lel(void)" (?lel##YAXXZ)
1>dll_load.obj : error LNK2019: unresolved external symbol curl_easy_setopt referenced in function "void __cdecl lel(void)" (?lel##YAXXZ)
1>dll_load.obj : error LNK2019: unresolved external symbol curl_easy_init referenced in function "void __cdecl lel(void)" (?lel##YAXXZ)
1>dll_load.obj : error LNK2019: unresolved external symbol curl_global_init referenced in function "void __cdecl lel(void)" (?lel##YAXXZ)
anyone knows what i'm missing or how i can fix this, because it's really annoying and stops me from finishing my project! Any help is greatly appreciated!

It sounds like visual studio (windows), but the same thing applies to any compiler. You tell it where to look for a library file, but you didn't tell it to actually use libcurl, so it didn't look for it.
In visual studio, try Linker, Input, Additional Dependencies
add "libcurl.lib" (or whatever the actual name is).

Related

in search of libraries for visual studios 2013, where & how to obtain

i have found some source file online and the individual responsible for it hasn't reply back, i need to know how does one go about finding this particular libraries if one was to need in the near future?
in processing its easy you just go to the library download manager and type the name of that library.
is there a way to do this in Visual studios?
below you can see what i think i need to fix my issue.
#include<opencv/cvaux.h>// in need of it
#include<opencv/cxcore.h>//in need of it
this is why i think i need those files above,
ERRORS:
Error 4 error LNK2019: unresolved external symbol cvReleaseMemStorage
referenced in function
main
Error 2 error LNK2019: unresolved external symbol cvInRangeS
referenced in function
main
Error 5 error LNK2019: unresolved external symbol cvGetSeqElem
referenced in function
main
Error 3 error LNK2019: unresolved external symbol cvCreateMemStorage
referenced in function
main
Error 1 error LNK2019: unresolved external symbol cvCreateImage
referenced in function
main
Error 6 error LNK2019: unresolved external symbol cvCircle referenced
in function
main
Error 7 error LNK1120: 6 unresolved
externals
1>Source.obj : error LNK2019: unresolved external symbol cvCreateMemStorage referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol cvReleaseMemStorage referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol cvGetSeqElem referenced in function main
1>Source.obj : error LNK2019: unresolved external symbol cvCircle referenced in function main
the funny thing is that there's no squiggly red lines in the code telling me that this! is whats wrong, this is why im guessing that the problem is cuz of the lacking of those files.
For starting the development process using libraries like OpenCV or OpenGL,you need to install some packages and do a bunch of configurations on your Visual Studio.From here you can download the missing packages for windows,you can also have a Quick start on the website which will get you on the path for beginning,to be more specific here is a complete guide of building OpenCV apps inside Visual Studio

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

Migration from IBM VisualAge C++ 3.6.5 to VS 2010

We're in the process of migrating 32-bit C++ application to 64-bit application (VS 2010). This application was developed 10 years back with IBM VisualAge C++ 3.6.5 for Windows. Since IBM has stopped support of this compiler, we're facing issues while migrating it to VS 2010.
This is mostly because of some missing libraries.
Sample errors:
error LNK2019: unresolved external symbol __uopen referenced in function "int __cdecl allocate_heap_storage_(void)" (?allocate_heap_storage##YAHXZ)
error LNK2019: unresolved external symbol __ucreate referenced in function "int __cdecl allocate_heap_storage_(void)" (?allocate_heap_storage##YAHXZ)
error LNK2019: unresolved external symbol __udestory referenced in function "int __cdecl deallocate_heap_storage_(void)" (?deallocate_heap_storage##YAHXXZ)
error LNK2019: unresolved external symbol __uclose referenced in function "int __cdecl deallocate_heap_storage_(void)" (?deallocate_heap_storage##YAHXXZ)
error LNK2019: unresolved external symbol __umalloc referenced in function "int __cdecl alloc_share_mem_(int,int)" (?alloc_share_mem#YAPAXHH#Z)
The above functions are defined in umalloc.h but we are missing the definitions.
How can we resolve this?
For the errors above, these function "_ucreate",_udestory , _uclose,_umalloc" are not found when linking, I think these functions were in the run time libraries provided by Visual Age. if you can find the lib files of the these run time libraries, you can put them in the input of link, it may pass the compiling phase, but may fail to launch.
One suggestion here is to replace the functions above with windows functions. All the functions above are related with memory allocations.

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.