cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Mac OS 32-bit libcurl (was Re: use libcurl source files directly rather than link with library)

From: Daniel Johnson <daniel.johnson31_at_gmail.com>
Date: Mon, 30 May 2011 16:03:58 -0400

On May 30, 2011, at 1:41 PM, Tom Bishop, Wenlin Institute wrote:

>
> On May 30, 2011, at 12:14 AM, Michael Wood wrote:
>
>> I see you're using Csh.... maybe try "setenv" instead of "set".
>
> Yes, thank you, this worked:
>
> setenv CFLAGS "-arch i386"
> ./configure --disable-shared
>
> -- at least as far as producing a library with "size of long... 4".
>
> When I added libcurl.a to the project and tried to run, however, I got this error:
>
> -------------------------
> Running…
> dyld: Library not loaded: /usr/lib/libcurl.3.dylib
> Referenced from: /Users/tbishop/wenlin/build/Development/Wenlin.app/Contents/MacOS/Wenlin
> Reason: no suitable image found. Did find:
> /usr/lib/libcurl.3.dylib: mach-o, but wrong architecture
> /usr/lib/libcurl.3.dylib: mach-o, but wrong architecture
> Cannot access memory at address 0x0
> Cannot access memory at address 0x0
> -------------------------
>
> Throwing caution to the wind, I deleted the dylib:
>
> sudo rm /usr/lib/libcurl.3.dylib
>

This is very bad. Deleting anything in /usr/lib is likely to break system components.

> Now I get this:
>
> -------------------------
> Exception Type: EXC_BREAKPOINT (SIGTRAP)
> Exception Codes: 0x0000000000000002, 0x0000000000000000
> Crashed Thread: 0
>
> Dyld Error Message:
> Library not loaded: /usr/lib/libcurl.3.dylib
> Referenced from: /Applications/Wenlin4/Wenlin.app/Contents/MacOS/Wenlin
> Reason: image not found
> -------------------------
>
> There is still something in the project that's making it try to load the dylib, but I can't figure out what it is or how to remove it. I've cleaned the project, deleted and rebuilt the application, but still get the same result.

By default with Xcode 3.2.6 and earlier, the Mac OS X linker will always search every directory in its search path for a shared library in the form of libfoo.dylib first. Only if it doesn't find one will it go back and look for a static library, libfoo.a. That's why it's finding /usr/lib/libcurl.dylib and ignoring your static library. You can override this behavior by using the switch -search_paths_first when linking. The -search_paths_first option became the default with Xcode 4.

Daniel

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-05-30