Skip to main content

Topic: Having problems implementing cURL (Read 2429 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • damrass
  • [*]
Having problems implementing cURL
I have it working in the Winamp version of my plugin, but my foobar version is throwing all kinds of weird link errors at me when building. Here are a few:

Code: [Select]
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _calloc already defined in LIBCMTD.lib(dbgcalloc.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _realloc already defined in LIBCMTD.lib(dbgrealloc.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj)
1>MSVCRTD.lib(MSVCR90D.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgmalloc.obj)


I'm using the static version of the cURL library which I myself built from the sources. In case I'm missing something, here are my Compile and Linker command-lines respectively:

Code: [Select]
/Od /I "C:\Documents and Settings\Jonathon\Desktop\beenplaying\libcurl\include" /I "C:\Documents and Settings\Jonathon\Desktop\SDK-2008-11-29\foobar2000" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "BEENPLAYING_EXPORTS" /D "CURL_STATICLIB" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MTd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /ZI /TP /errorReport:prompt


Code: [Select]
/OUT:"C:\Documents and Settings\Jonathon\Desktop\SDK-2008-11-29\Debug\foo_BeenPlaying.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Documents and Settings\Jonathon\Desktop\beenplaying\libcurl\lib\Debug" /LIBPATH:"C:\Documents and Settings\Jonathon\Desktop\SDK-2008-11-29\foobar2000\shared" /DLL /MANIFEST /MANIFESTFILE:"Debug\foo_BeenPlaying.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Documents and Settings\Jonathon\Desktop\SDK-2008-11-29\Debug\foo_BeenPlaying.pdb" /SUBSYSTEM:WINDOWS /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT shared.lib shlwapi.lib libcurl.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 "..\..\foobar2000\foobar2000_component_client\debug\foobar2000_component_client.lib" "..\..\debug\pfc.lib" "..\..\debug\foobar2000_sdk_helpers.lib" "..\..\foobar2000\sdk\debug\foobar2000_sdk.lib"


Any help whatsoever would be greatly appreciated. I've been scouring the web for the last few hours trying to find a solution. If you think it'll help, let me know and I'll post the command-lines for my Winamp plugin project.

  • Zao
  • [*][*][*][*][*]
  • Developer (Donating)
Having problems implementing cURL
Reply #1
Ensure that you are using the same CRT runtime DLL setting in VC++ for both your component and your libraries. (Project Properties -> C/C++ -> Code Generation -> Runtime Library.)
Personally I tend to go with the non-DLL debug/release one for foobar2000 components to avoid having to redistribute the runtime redist, which virtually no user seems to be able to install correctly.
Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered.

  • damrass
  • [*]
Having problems implementing cURL
Reply #2
Well I got it to build moments before you posted Zao! (Don't you hate it when you figure something out shortly after posting for help online??)

To fix it, I went to the Linker Input section of the Config, and
  • Added "libcmtd" to Ignore Specific Library
  • Added "ws2_32.lib" to Additional Dependencies (had it in my Winamp plugin project, forgot to add it here... d'oh!)


But I'll definitely take that into consideration though Zao, as I realized I was having problems running my Winamp plugin on other people's machines. Thanks!

Edit: Actually, now that I think about it... I set all my components and libraries to MTd (or MT for release). I prefer statically-linking for the same dependency nightmares you mention.

Edit 2: Actually, now that I went and looked for sure I was using MDd for both my Winamp plugin project and for the cURL library project. I'll try recompiling cURL with MTd, and see if that works. Thanks again.
  • Last Edit: 03 January, 2010, 12:54:37 PM by damrass

  • Zao
  • [*][*][*][*][*]
  • Developer (Donating)
Having problems implementing cURL
Reply #3
For normal code, I wouldn't dream of linking statically to the runtime as that would prevent me from using the standard C++ library across DLL boundaries, but in an environment like foobar2000 where the pfc and services bits exist, multi-DLL development with a static runtime is feasible.
Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered.

  • damrass
  • [*]
Having problems implementing cURL
Reply #4
For normal code, I wouldn't dream of linking statically to the runtime as that would prevent me from using the standard C++ library across DLL boundaries, but in an environment like foobar2000 where the pfc and services bits exist, multi-DLL development with a static runtime is feasible.


Hmm, I bet that's why I had set my Winamp project and the cURL library to link dynamically; I think I recall it not being able to build when statically-linked. (Now if I could just figure out why that stupid thing crashes on other machines I'd be keen, but I suppose that discussion isn't relevant here.)

Thanks for being patient to an old C++ programmer that hasn't seriously looked at the code in over 10 years. I'm relearning all the nuances all over again.

  • damrass
  • [*]
Having problems implementing cURL
Reply #5
So I rebuilt cURL to link statically and then removed libcmtd from Ignore Specific Library that I added in my previous post, and of course you were right--it built fine.

One question though... the original "fix" I posted above, would that have caused any harm (having libcmtd ignored)? It didn't seem to affect *my* plugin's behavior, but I'm just curious if it would or could have caused problems for foobar or the other installed plugins.

  • Zao
  • [*][*][*][*][*]
  • Developer (Donating)
Having problems implementing cURL
Reply #6
I'm not quite sure, but I believe it wouldn't matter too much in the case of dynamic vs. static runtime. The scary scenario would be if you tried to mix debug and release runtimes, resulting in lovely ODR violations, if you could even get it to link at all.
Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered.