开发者

Linking problems using libcurl with Visual C++ 2005: "unresolved external symbol __imp__curl_easy_setopt"

I am planning to use libcurl in my project. I had downloaded the library source,built and integrated it in a small POC application. I am able to build and run the application without any issues with the generated libcurl.dll and libcurl_imp.lib files. Now when I integrate the same library in my project I am getting linker errors.

6>foo.obj : error LNK2001: unresolved external symbol __imp__curl_easy_setopt

6>foo.obj : error LNK2001: unresolved external symbol __imp开发者_运维问答__curl_easy_perform

6>foo.obj : error LNK2001: unresolved external symbol __imp__curl_easy_cleanup

6>foo.obj : error LNK2001: unresolved external symbol __imp__curl_global_init

6>foo.obj : error LNK2001: unresolved external symbol __imp__curl_easy_init

I have researched and tried all manners of workarounds like adding CURL_STATICLIB definitions , additional libraries , changing to /MT even copying the libs to the release directory but nothing seems to work. As far as I can see the only difference between approach #1 and #2 in my steps are #1 is an console application using the libcurl.dll while in my main project this is another dll which is trying to link to libcurl.dll.. Would that necessitate any change in approach? Can I use the same generated multi threaded DLL /MD file for both(Tried /MT also with no success)? Any other ideas?

Following are the linker options.

-------------------------------------------------Working-------------------------------------------------

/OUT:"C:\SampleFTP\Release\SampleFTP.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\SampleFTP\SampleFTP\Release" /MANIFEST /MANIFESTFILE:"Release\SampleFTP.exe.intermediate.manifest" /DEBUG /PDB:"c:\SampleFTP\release\SampleFTP.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /MACHINE:X86 /ERRORREPORT:PROMPT libcurl_imp.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

-------------------------------------------------Working-------------------------------------------------

----------------------------------------------NotWorking-------------------------------------------------

/OUT:".......\nt\Win32\Release/foo__tests.dll" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\FullLibPath\libcurl_libs" /LIBPATH:"......\nt\Win32\Release" /DLL /MANIFEST /MANIFESTFILE:".\foo__tests\Win32\Release\foo__tests.dll.intermediate.manifest" /DEBUG /PDB:".......\nt\Win32\Release/foo_tests.pdb" /OPT:REF /OPT:ICF /LTCG /IMPLIB:".......\nt\Win32\Release/foo_tests.lib" /MACHINE:X86 /ERRORREPORT:PROMPT odbc32.lib odbccp32.lib util_process.lib wsock32.lib Version.lib libcurl_imp.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "......\nt\win32\release\otherlib1.lib" "......\nt\win32\release\otherlib2.lib"

----------------------------------------------NotWorking-------------------------------------------------


did you run the commands

curl-config --cflags
curl-config --libs

With the results from --libs i could find how to link my application.


Ok...This embrassing....I had managed to resolve the issue and as you might guess it has nothing to do with libcurl..Basically the file which is linking to libcurl is part of multiple projects. So while I have defined the libs correctly in the first project, I have not in the others..And the build log shows the projects(success/failure messages) one after another and I could notice the problem only while going through togeather with my senior...All in all a humbling experience..

Lesson learnt(for future visitors here) would be - Libcurl is a mature product and is unlikely to crib for basic bundling - Only thing necessary if you are going to use windows .dll would be 1) Download source. Open soln file. Build(as release dll). 2) Include additional header path for curl libraries. 3) Include .lib file as a dependency while linking. 4) Start making curl calls (including ther curl headers in source)

and you should be good to go. For starting off(other than the excellent repository at the home page) I have fount a good tutorial here...

http://www.luckyspin.org/?p=28


I agree to user88595. Additionally, we may need to look out for the following things(out of experience).

This is if you have some shared library in your project:

Say you have a Visual Studio solution with "A" is a shared library project "B" is the target executable project(most cases the startup project). So, you need to really see who is actually calling the API's of libcurl.lib, it they are being called within "A", you need to go to the "librarian" property of the project "A" and then add libcurl.lib dependency there. Also, add the lib paths. I had done a mistake of adding the dependency to the "linker" property and the lib paths to "B", which caused this same problem.

Some additional linker errors w.r.t LDAP:

Once you resolve the linker errors mentioned in this section, you will get some more errors with respect to LDAP, to resolve this add wldap32.lib under the linker dependancy of "B".

All the best, Arjun

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜