I am trying to use cURL in a C++ project I am working on in VS2010.
I downloaded the latest cURL source and I am building the solution included in the archive. When I build this project the only output lib appears to be "libcurld_imp.lib". I was expecting a "libcul.lib". In any case I have pointed VS to the include directory where the headers live and added the above mentioned lib to my linker's dependencies. Finally, I add the folder path of this "libcurld_imp.lib" to the links additional libraries search locations.
I cannot build my project because of the following linker error:
error LNK1104: cannot open file 'libcurld_imp.lib'
This file does exist in a folder that I added to the linker's additional libraries search path. What am I missing? Thanks
update
Ok.. So was able to get a libcurl.lib file by editing the libcurl proj. The default build settings were set to output a DLL. I changed this to as static library. Now that I have a libcurl.lib I am getting these linking errors:
Error 3 error LNK2019: unresolved external symbol _imp_curl_easy_setopt referenced in function _main
Error 2 error LNK2019: unresolved external symbol _imp_curl_easy_perform referenced in function _main
Anyone know how to link this friggen thing?
Another update
The documentation included in the source download includes a file, "build.windows". The directions say to build the lib using the following command:
nmake /f makefile.vc mode=
I have done this using "static" as my mode and "VC=10" as my option. This builds the library but it is called libcurl_a.lib. Linking to this lib gives the same errors :(
Thanks
the _imp suffix in libcurld_imp.lib most likely stands for Import Library. You are building a DLL and this file is the lib you need to link to your exe to call the DLL implicitely.
The solution should contain other configurations that will let you build a static library.
You need both to succeed. Try this suggestion (it's for vs2008 but should work):
http://curl.haxx.se/mail/lib-2009-05/0097.html
Related
I have the following files (https://www.dropbox.com/s/2bfhylzb2evrggp/Lib.rar?dl=0)
It contains the header file, .so and .dll file.
I added the aditional paths under C/C++ and Linker (to the dll.s and .h files)
I have also used the sample code in the rar file and VS2015 picks up the code
include "swi32.h"
But as soon as I try to use a method defined in the headerfile I get the following
Severity Code Description Project File Line Suppression State
Error LNK1120 1 unresolved externals ConsoleApplication1 C:\Users\Donald Jansen\Desktop\CPPTest\Swi32Test\ConsoleApplication1\Debug\ConsoleApplication1.exe 1
Error LNK2019 unresolved external symbol _WiCreateRawImage#0 referenced in function _main ConsoleApplication1 C:\Users\Donald Jansen\Desktop\CPPTest\Swi32Test\ConsoleApplication1\Console.obj 1
I am not sure what I am missing
If you are implicitly linking the dll, then you must have also received a .lib file which you need to link with your console application. This should remove the unresolved symbol warning. The operating system loads the DLL when the executable using it is loaded.
If you are explicitly linking the dll, then your code should explictly load and unload the DLL to access the exported functions.
The .so you mention probably is a linux shared object file and not useful on windows platform. I may be wrong though.
I'm trying to create a .dll with Visual Studios 2013. The project includes libpq functionality.
Per other stackoverflow posts, and other sources I've found on the internet, I've (as far as I'm aware) correctly added the postgres lib and include directories to the project. However, when I go to build the project, it returns a number of "unresolved external symbol" errors.
My paths are C:\Program Files\PostresSQL\9.3\... so I have them surrounded by quotation marks in the Additional Library/Include Directory fields. I've included the libpq-fe.h header file in the project... I'm just not sure what I'm doing wrong.
Another note, I can compile a test program from the command line using g++ with the -I, -L, and -lpq flags, but I'm not sure how to compile to a .dll from the command line (plus it adds complexity that I just don't want to deal with).
These are the specific errors I'm getting:
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQconnectdb
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQstatus
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQerrorMessage
1>sql_arma.obj : error LNK2001: unresolved external symbol _PQfinish
1>C:\Users\tills13\documents\visual studio 2013\Projects\sql_arma\Release\sql_arma.dll : fatal error LNK1120: 4 unresolved externals
I have, as suggested below, included #pragma comment(lib, "libpq.lib") in the source file for my project, I still receive these errors.
I've successfully compiled the sample program by setting these project properties:
Add <pgsql install path>\include and \lib to VC++ Directories->Include and ->Library, correspondingly
Add libpq.lib to Linker->Input->Additional dependencies
This is the standard way to reference 3rd-party libs. It's just that they recommend using environment variables for their "base dirs" to avoid patching the project when it's under a VCS.
To be able to run the app from VS (both with and without debugging), I also specified PATH=%PATH%;<pgsql install path>\bin in Debugging->Environment since this dir isn't in PATH on my system.
It's not sufficient add the postgres lib directory to the project, you must also add
reference to libpq.lib. Just add this line to one of your source .cpp files:
#pragma comment(lib, "libpq.lib")
As noted by Marco A. the library must match a program bitness (32 or 64 bit): if you build 32-bit DLL (referred as Win32) you must use 32 bit library; if 64-bit (x64) - 64-bit library.
I have also faced same issue. Then I realized that I was building my application as a 32bit. I changed the target of my application to x64 and it compiled successfully
I'm currently following the openglbook.com tutorials (set up) (Tutorial) and have run into an issue fairly early on. I'm getting the following two errors:
1>main.obj : error LNK2019: unresolved external symbol __imp__glewGetErrorString#4 referenced in function _Initialize
1>main.obj : error LNK2019: unresolved external symbol __imp__glewInit#0 referenced in function _Initialize
I have downloaded and compiled freeglut 2.8.0 as well as the glew 1.9.0 binaries. I have copied the libs and includes to C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Lib and Include respectively.
The Lib and Include paths have also been added to my project properties under Additional Library/Include directories.
I have also defined glew32.lib and freeglut.lib in my linker->Input->Additional dependencies.
I have included GL/glew.h and GL/freeglut.h at the top of my main file.
What am I missing? Every other thread I've found has been solved by adding the directories to the project properties. Does anyone have any ideas?
This means that you try to use GLEW as a DLL (because your application looks for a name that begins with __imp, like "import" ), but you didn't built GLEW as a DLL (because otherwise it would work).
3 possible options :
Rebuild GLEW with the GLEW_BUILD preprocessor definition (Project->Properties->C++->Preprocessor->Additional definitions). Then rebuild your application.
Don't build GLEW at all. Simply put glew.c in your application's project. This is the easiest way.
(my favourite) Define GLEW_STATIC in your application's preprocessor definitions, and rebuild.
I have been at this for some time now. I hope someone can tell me what I am doing wrong.
These are the steps I have taken so far:
-Downloaded the latest version of cURL (7.21.7).
-Opened the solution in Visual Studio 2010 using the vc6curl.dsw and converted the projects to VS2010.
-Set the libcurl project configuration to "release" and built. Build succeeded.A folder called "LIB-Release" is created. It contains several obj files and the "libcurl.lib" file resides here as well.
Test Application:
-In the project's settings I pointed the compiler to the curl includes (headers).
C/C++ >> General >> Additional Include Directories
-Added "CURL_STATICLIB" to the preprocessor definitions
C/C++ >> Preprocessor Definitions
-Added the path to the "libcurl.lib" folder in my linker additional library dependencies
Link >> General >> Additional Library Directories
-Added "libcurl.lib" to my linker additional dependencies
Link >> Input >> Additional Dependencies
-Set my projects configuration to "Realease" and hit build!
I get 42 unresolved externals errors:
Error 65 error LNK1120: 42 unresolved
externals C:\Users\Nick\Documents\Visual Studio
2010\Projects\curl_static_lib\Release\curl_static_lib.exe curl_static_lib
Error 61 error LNK2001: unresolved external symbol
___WSAFDIsSet#8 C:\Users\Nick\Documents\Visual Studio
2010\Projects\curl_static_lib\curl_static_lib\libcurl.lib(select.obj) curl_static_lib
Error 59 error LNK2001: unresolved external symbol
_imp_accept#12 C:\Users\Nick\Documents\Visual Studio
2010\Projects\curl_static_lib\curl_static_lib\libcurl.lib(ftp.obj) curl_static_lib
Error 46 error LNK2001: unresolved external symbol
_imp_ber_free C:\Users\Nick\Documents\Visual Studio
2010\Projects\curl_static_lib\curl_static_lib\libcurl.lib(ldap.obj) curl_static_lib
Error 26 error LNK2001: unresolved external symbol
_imp_bind#12 C:\Users\Nick\Documents\Visual Studio
2010\Projects\curl_static_lib\curl_static_lib\libcurl.lib(connect.obj) curl_static_lib
I have tried building using the "Debug" configuration as well. Can someone please tell me where I am going wrong?
The best way to build CURL for windows is to use NMake with provided Makefiles.
You can
Modify Makefile in root folder of CURL to set VC version you use and then run nmake vc-all (or choose any other VC target suitable for you). Check "Win32" section of ./docs/INSTALL file.
Use Makefile.vc from ./winbuild folder. Check ./winbuild/BUILD.WINDOWS.txt on how to use it.
These errors mean that there are functions that libcurl uses that are not in any of the import libraries specified in your linker config.
Sounds like at least the sockets import lib (ws2_32.lib) should be there.
Note that if you compile libcurl as a DLL then all the import libraries are specified as part of the linking of the DLL, so your application then does not need to import all these libraries and just needs to link against the curl import lib. The fact that you chose to compile curl as a static lib makes the curl code part of your application so all the support libs must be provided in your app's linker config.
Help me guys,
I've been searching for a really long time.
I'm using visual studio 2010 and I tried to include an external lib but I get an unresolved external error.
The external project is composed of files in the following way
backend.cpp
//some functions
frontend.cpp
//some functions
header.h
I build this project using SCons then I includes the .lib file in the project and refered to its path and I copied the .h file to msvc directory .
VS seems to access and read the functions in backend.cpp(from the auto complete) but when I run the project it says that there is an unresolved external # the called function
I'm not a Visual Studio expert, but I guess that it being able to auto complete your code is associated with it finding the headers of your source code.
Unresolved external means that the compiler can't find the object files in the linking process. This could mean that you failed to add the lib files correctly, or that you are missing some .cpp file.
That may happen for a variety of reasons. But all of them end up being one of the following:
You are not linking the correct .lib file.
The symbol name you are using in your program is not identical to the one provided in the .lib.
The first one is easy enough to check, so please, double check it.
The second one is trickier. The symbol name used in your program is output in the error message "unresolved external symbol abc", or whatever. The symbols available in the library can be listed with the command: dumpbin /all name.lib.
If you cannot find the problem, please post the exact error you are getting and the output of the dumpbin program.