How to compile curl 7.35 and use it in project? - c++

I built libcurl and added it to project (specified include directory, library directory and library to use: libcurl.lib/libcurl_imp.lib - I both tried to compile and link static and dynamic library). In both cases (static/dynamic) I faced following:
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_cleanup referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_perform referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_setopt referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>tmp.obj : error LNK2019: unresolved external symbol _curl_easy_init referenced in function "void __cdecl perform(char *)" (?perform##YAXPAD#Z)
1>C:\Users\Public\Documents\Project\curl-7.35.0\Debug\tmp.exe : fatal error LNK1120: 4 unresolved externals
All solutions I found was different variations of "add libcurl.lib".
Now just to clarify my configuration:
dynamic: include directory specified, library directory specified, libcurl_imp.lib specified as additional dependency, libcurl.dll copied to the directory where executable files should be generated.
static: include directory specified, library directory specified, libcurl.lib specified as additional dependency.
using vs2005

Well, it's silly but I was trying to use x64 library in x32 project.

Related

opencv : unresolved external symbol

I know this question is all over the place, but still the magic stick of adding the library directories to the project properties is not working for me.
I followed the tutorial for Visual Studio (2013 I have here) and the environment variable setup for opencv 3.0 beta.
And it's the same code on the Test it! section. Here's the header of build output in vs:
1>------ Build started: Project: OpenCVTest, Configuration: Debug Win32 ------
1>opencv_core300d.lib(matrix.obj) : error LNK2019: unresolved external symbol _ippicvsFlip_16u_I#8 referenced in function "enum IppStatus (__stdcall*__cdecl cv::getFlipFunc(int))(void *,int)" (?getFlipFunc#cv##YAP6G?AW4IppStatus##PAXH#ZH#Z)
1>opencv_core300d.lib(matrix.obj) : error LNK2019: unresolved external symbol _ippicvsFlip_32f_I#8 referenced in function "enum IppStatus (__stdcall*__cdecl cv::getFlipFunc(int))(void *,int)" (?getFlipFunc#cv##YAP6G?AW4IppStatus##PAXH#ZH#Z)
1>opencv_core300d.lib(matrix.obj) : error LNK2019: unresolved external symbol _ippicvsFlip_64f_I#8 referenced in function "enum IppStatus (__stdcall*__cdecl cv::getFlipFunc(int))(void *,int)" (?getFlipFunc#cv##YAP6G?AW4IppStatus##PAXH#ZH#Z)
1>opencv_core300d.lib(matrix.obj) : error LNK2019: unresolved external symbol _ippicvsFlip_8u_I#8 referenced in function "enum IppStatus (__stdcall*__cdecl cv::getFlipFunc(int))(void *,int)" (?getFlipFunc#cv##YAP6G?AW4IppStatus##PAXH#ZH#Z)
1>opencv_core300d.lib(matrix.obj) : error LNK2019: unresolved external symbol _ippicvsSortAscend_8u_I#8 referenced in function "enum IppStatus (__stdcall*__cdecl cv::getSortFunc(int,bool))(void *,int)" (?getSortFunc#cv##YAP6G?AW4IppStatus##PAXH#ZH_N#Z)
1>opencv_core300d.lib(matrix.obj) : error LNK2019: unresolved external symbol _ippicvsSortDescend_8u_I#8 referenced in function "enum IppStatus (__stdcall*__cdecl cv::getSortFunc(int,bool))(void *,int)" (?getSortFunc#cv##YAP6G?AW4IppStatus##PAXH#ZH_N#Z)
The rest of the log is the same. I've used the opencv\build\x86\vs12 directory contents for the lib and bin directories. I'm blindly using the /MDd option in C/C++->Code Generation->Runtime Library option. What's wrong?
I added $(OPENCV_DIR)\staticlib to Library Directories and also to Linker->Additional Library Directores and added the following to Linker->Input->Additional Dependencies:
ippicvmt.lib
IlmImfd.lib
libtiffd.lib
libpngd.lib
libjasperd.lib
libjpegd.lib
libwebpd.lib
zlibd.lib
comctl32.lib
And the example now works.
Unfortunately that solution did not work for me. For those in a similar situation:
It can work by adding as additional dependencies(Linker -> Input -> Additional Dependencies:) only those libraries located in my $(OPENCV_DIR)\lib folder. Namely: opencv_ts300d.lib;opencv_world300d.lib.

Unresolved externals using boost::asio(visual studio12, x64)

I've downloaded and installed the boost_1_55_0-msvc-12.0-64.exe executable from here: http://sourceforge.net/projects/boost/files/boost-binaries/1.55.0-build2/.
I extracted the binaries to C:\boost_1_55_0 and added the include and linker directories to visual studio project properties.
Include directory: c:\boost_1_55_0
Link directory: c:\boost_1_55_0\lib64-msvc-12.0
error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::system_category(void)" (?system_category#system#boost##YAABVerror_category#12#XZ) referenced in function "public: __thiscall boost::system::error_code::error_code(void)"
\error LNK2019: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::generic_category(void)" (?generic_category#system#boost##YAABVerror_category#12#XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'errno_ecat''(void)" (??__Eerrno_ecat#system#boost##YAXXZ)
What am I doing wrong?
You're probably using the 32 bit compiler / linker, since you downloaded the 64 bit libs make sure you invoke the 64 bit compiler.

Setting up OpenGL - it won't work

I just bought a new laptop with windows 8 64bit and I am using Visual Studio 2012.
I did the usual procedure with installing a 3d party lib just as I installed them on my previous PCs:
Download freeglut, glew, glfw, glut, sdl
Copy headers into "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include"
Copy libs into "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib"
Copy dll's into "C:\Windows\SysWOW64"
Then I downloaded the project I was developing on my other PC (was developed under windows 8 32bit if that's of any importance) and it would'n compile. The compiler threw me the following linking error:
Error 1 error LNK2001: unresolved external symbol __imp__glDrawArrays#12 - about 50 of these
Error 63 error LNK2019: unresolved external symbol __imp__glClear#4 - again about 50 of these
The project is working perfectly on my old PC.
I did try to make a simple new project: http://pastebin.com/GfEieL6f
Linked the following libraries (Properties->Linker->Input->Additional Dependencies)
opengl32.lib
glut32.lib
glu32.lib
And again it wouldn't compile, again the same linking errors:
Error 1 error LNK2019: unresolved external symbol __imp__glBegin#4 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 2 error LNK2019: unresolved external symbol __imp__glClear#4 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 3 error LNK2019: unresolved external symbol __imp__glClearColor#16 referenced in function _main P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 4 error LNK2019: unresolved external symbol __imp__glColor3f#12 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 5 error LNK2019: unresolved external symbol __imp__glEnd#0 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 6 error LNK2019: unresolved external symbol __imp__glFlush#0 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 7 error LNK2019: unresolved external symbol __imp__glLoadIdentity#0 referenced in function _main P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 8 error LNK2019: unresolved external symbol __imp__glMatrixMode#4 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 9 error LNK2019: unresolved external symbol __imp__glOrtho#48 referenced in function _main P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 10 error LNK2019: unresolved external symbol __imp__glRotatef#16 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
Error 11 error LNK2019: unresolved external symbol __imp__glVertex3iv#4 referenced in function "void __cdecl drawcube(void)" (?drawcube##YAXXZ) P:\OpenGL_Setup\OpenGL_Setup\opengl_setup.obj
I don't know if I am missing something, can you give me some ideas ?
PP: I managed to fix the simple program and run it, but I cannot run my old project. Maybe it's a problem because of the platform change ? How can I fix it?
Don't add files to the compiler lib directory. Instead add another library search path to your project.
You probably downloaded library files that aren't compatible with VC++ 2012 and your project build settings. In native code, you can't mix x86, x64, etc. Static libraries need to match your project bitness, not your OS. And Microsoft also changes/extends the library file format, as well as runtime library components used by the library, so you really should get a library file designed for your version of VC++.

unresolved external symbol in eclipse cdt

I try to build cpp file using eclipse cdt. Linker throws "unresolved external symbol", however path to lib file that contains implementation for function is listed in LIB environment variable on Project properties->C/C++ Build->Environment
What am I doing wrong?
UPD I try to build file. There is lib RpcRT4.Lib on the path C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib\
And linker fails:
**** Build of configuration Debug for project test cpp ****
**** Internal Builder is used for build ****
link /debug /nologo /OUT:test cpp.exe main.obj
main.obj : error LNK2019: unresolved external symbol __imp__RpcStringFreeA#4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)"(?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterClassA#4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidToStringA#8 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__UuidCreate#4 referenced in function "bool __cdecl Initialize_CreateWindowClass(void)" (?Initialize_CreateWindowClass##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA#16 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc##YGJPAUHWND__##IIJ#Z)
main.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage#4 referenced in function "long __stdcall SkypeAPITest_Windows_WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?SkypeAPITest_Windows_WindowProc##YGJPAUHWND__##IIJ#Z)
main.obj : error LNK2019: unresolved external symbol __imp__UnregisterClassA#8 referenced in function "void __cdecl DeInitialize_DestroyWindowClass(void)" (?DeInitialize_DestroyWindowClass##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA#48 referenced in function "bool __cdecl Initialize_CreateMainWindow(void)" (?Initialize_CreateMainWindow##YA_NXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DestroyWindow#4 referenced in function "void __cdecl DeInitialize_DestroyMainWindow(void)" (?DeInitialize_DestroyMainWindow##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA#4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage#4 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__GetMessageA#16 referenced in function "void __cdecl Global_MessageLoop(void)" (?Global_MessageLoop##YAXXZ)
main.obj : error LNK2019: unresolved external symbol __imp__PostMessageA#16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread##YAXPAX#Z)
main.obj : error LNK2019: unresolved external symbol __imp__SendMessageA#16 referenced in function "void __cdecl Global_InputProcessingThread(void *)" (?Global_InputProcessingThread##YAXPAX#Z)
main.obj : error LNK2019: unresolved external symbol __imp__RegisterWindowMessageA#4 referenced in function _main
test cpp.exe : fatal error LNK1120: 15 unresolved externals
Build error occurred, build is stopped
Time consumed: 2438 ms.
And environment settings for project
I'm not entirely clear on whether you've already done this based on the question, but just adding the directory to your linker's search path isn't enough for any compiler/linker I've ever used. There could be hundreds of different libraries in there, even different versions of the same library, and the linker has no idea which ones you do and don't want. You need to tell it, explicitly, to link against the library using the appropriate parameter.
It looks like you're using the Microsoft linker, which I've never used, so I can't help you with the specific flag but it should be easy enough to find what it is in the documentation if that's the issue. I presume Eclipse has a method of specifying this in the GUI as well which should be generic across the various compilers it supports.

error LNK2019: unresolved external symbol "public:

I am creating an torrent application using libtorrent in VS 2008. I tried the example given in the link http://www.rasterbar.com/products/libtorrent/examples.html
BUt it is showing me these error....how to solve them?
Linking...
main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::~torrent_info(void)" (??1torrent_info#libtorrent##QAE#XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::torrent_info::torrent_info(struct libtorrent::lazy_entry const &)" (??0torrent_info#libtorrent##QAE#ABUlazy_entry#1##Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "class std::basic_ostream > & __cdecl libtorrent::operator<<(class std::basic_ostream > &,struct libtorrent::lazy_entry const &)" (??6libtorrent##YAAAV?$basic_ostream#DU?$char_traits#D#std###std##AAV12#ABUlazy_entry#0##Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "int __cdecl libtorrent::lazy_bdecode(char const *,char const *,struct libtorrent::lazy_entry &,int)" (?lazy_bdecode#libtorrent##YAHPBD0AAUlazy_entry#1#H#Z) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "public: void __thiscall libtorrent::lazy_entry::clear(void)" (?clear#lazy_entry#libtorrent##QAEXXZ) referenced in function "public: __thiscall libtorrent::lazy_entry::~lazy_entry(void)" (??1lazy_entry#libtorrent##QAE#XZ)
main.obj : error LNK2019: unresolved external symbol "void __cdecl libtorrent::to_hex(char const *,int,char *)" (?to_hex#libtorrent##YAXPBDHPAD#Z) referenced in function "class std::basic_ostream > & __cdecl libtorrent::operator<<(class std::basic_ostream > &,class libtorrent::big_number const &)" (??6libtorrent##YAAAV?$basic_ostream#DU?$char_traits#D#std###std##AAV12#ABVbig_number#0##Z)
main.obj : error LNK2019: unresolved external symbol "public: struct libtorrent::peer_request __thiscall libtorrent::file_storage::map_file(int,__int64,int)const " (?map_file#file_storage#libtorrent##QBE?AUpeer_request#2#H_JH#Z) referenced in function "public: struct libtorrent::peer_request __thiscall libtorrent::torrent_info::map_file(int,__int64,int)const " (?map_file#torrent_info#libtorrent##QBE?AUpeer_request#2#H_JH#Z)
C:\Users\photoshop3\Documents\Visual Studio 2008\Projects\Lib2\Debug\Lib2.exe : fatal error LNK1120: 7 unresolved externals
The .lib is not included in your project. Make sure you are linking it in;
Configuration Properties -> Linker -> Input -> Additional Dependencies
Another altnerative is to simply copy the .lib to your project folder but don't, it's bound to create problems later on.
Sometimes the .lib is not shipped with the library, so you need to compile it yourself.
The README will tell you this. If this is the case, they usually ship with a .sln file you can open and the just compile it into a .lib file which you then reference in your main application, as I wrote above
Have you added the path of header files in the "Configuration Properties" --> "C/C++“ --> "General" --> "Additional Include Directories"?
The link gives you only the sources (including headerfiles) of libtorrent. You should compile this sources to get a .lib file. Add this .lib file to your client:
Configuration Properties/Linker/Input -> Additional Dependencies: libtorrent-rasterbar.lib
The best starting point for compiling should be the README file.
public: isn't the unresolved symbol. It's just there because the linker it trying to tell you that (most) of the unresolved symbols are public member functions.
It looks like you've included the header for "libtorrent", but not linked to the "libtorrent" library.
You have probably not linked with the torrent library or specified the wrong path to it so that the linker cannot find it.
If the input libraries are of 32bit and your are using them in building a 64bit it might be one of the reasons
For me, I had it included in my project, but it turned out that it was a plugin that was designed to not create an instance of in my unit test.