curl_easy_setopt fails on 64 bit CentOS 6

Linux specific forum
User avatar
mariosk8s
Enthusiast
Enthusiast
Posts: 103
Joined: Wed Apr 06, 2011 11:37 am
Location: Hüfingen, Germany
Contact:

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by mariosk8s »

Thanks for the tip @Shardik, but Linux and Mac work.

It's only M$ that's giving me head aches.
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by idle »

the command was right for creating an import library
you can check the imports generated in the lib file using podump curl.lib /IMPORTS
did you try Import on windows instead of ImportC
and you may need to alias the Imports if they're decorated with an underscore on windows

Import
curl_easy_setopt(curl, tag, value) as "_curl_easy_setopt"
...
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by Shardik »

mariosk8s wrote:Thanks for the tip @Shardik, but Linux and Mac work.
Sorry, my understanding was that you have difficulties with the Linux version, especially as Linux expert idle tried to help you...
mariosk8s wrote:It's only M$ that's giving me head aches.
I had to experience the same head aches when generating the libcurl.lib file for Windows... :lol:

This worked for me to generate a usable libcurl.lib for x86 Windows:
- Download the developer version curl-7.30.0-devel-mingw32 from here (this is the 32 bit version).
- Decompress the downloaded archive
- Change into the \lib folder
- Edit libcurl.def
- Insert the following line as top line
LIBRARY libcurl
- Save libcurl.def
- For ease of operation copy polib.exe from PureBasic's compiler folder to libcurl's lib folder
- Open console
- CD into libcurl's lib folder
- Generate libcurl.lib:
> polib /DEF:libcurl.def /OUT:libcurl.lib /MACHINE:x86
User avatar
mariosk8s
Enthusiast
Enthusiast
Posts: 103
Joined: Wed Apr 06, 2011 11:37 am
Location: Hüfingen, Germany
Contact:

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by mariosk8s »

First of all, thanks for your help guys.

@Shardik I managed to create libcurl.lib without a problem, it's subsequent linking that fails. I'm using libcurl built from source 7.32 using mingw. I did not manage to find a libcurl.def anywhere in there through.

@idle Here's what podump reports

Code: Select all

Dump of libcurl.lib

File type: LIB
...
libcurl-4.dll: curl_easy_send (curl_easy_send)
libcurl-4.dll: curl_easy_setopt (curl_easy_setopt)
libcurl-4.dll: curl_easy_strerror (curl_easy_strerror)
...
The first thing i noticed is that the lib uses the original lib name, which i later changed from libcurl-4.dll to libcurl.dll. Making a copy so i have both and then running yields no results either.

Code: Select all

polink.exe -DLL rfsetopt.o -OUT:rfsetopt.dll -DEFAULTLIB:/path/to/libcurl.lib -NOENTRY
POLINK: error: Unresolved external symbol '_curl_easy_setopt'.
POLINK: fatal error: 1 unresolved external(s).
[
So here i'm actually trying to make a lib out of my object file. Only the C code on top of this post is involved. PB is not yet involved.

On the PB side i'm getting the same error. It can find the functions in my wrapper just fine. It's the wrapper's use of curl_easy_setopt that fails to resolve when linking. There's no PB code directly referencing curl_easy_setopt.

I never dreamed, it would be such a bitch making a lib on Windows. :|
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by Shardik »

mariosk8s wrote:@Shardik I managed to create libcurl.lib without a problem, it's subsequent linking that fails. I'm using libcurl built from source 7.32 using mingw. I did not manage to find a libcurl.def anywhere in there through.
As I emphasized above you have to download the developer version which definately contains libcurl.def (my above link was to the older version 7.30.0). Here is the link to the newest developer version containing libcurl.def:
http://curl.haxx.se/gknw.net/7.32.0/dis ... ingw32.zip

I would nevertheless advise to generate a new libcurl.lib because I also experienced problems with subsequent linking which all vanished after generating a proper libcurl.lib as described above... :wink:
sec
Enthusiast
Enthusiast
Posts: 792
Joined: Sat Aug 09, 2003 3:13 am
Location: 90-61-92 // EU or ASIA
Contact:

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by sec »

http://curl.haxx.se/docs/faq.html#Link_ ... ing_libcur

it is needed: libcurl_imp.lib ( download at: https://github.com/bitmovin/libdash/tre ... ibcurl/lib )

Code: Select all

ImportC "libcurl_imp.lib"
  curl_easy_setopt(curl, tag, value) As "_curl_easy_setopt"
EndImport

curl_easy_setopt(0,0,0)
User avatar
mariosk8s
Enthusiast
Enthusiast
Posts: 103
Joined: Wed Apr 06, 2011 11:37 am
Location: Hüfingen, Germany
Contact:

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by mariosk8s »

Shardik wrote:As I emphasized above you have to download the developer version which definately contains libcurl.def (my above link was to the older version 7.30.0). Here is the link to the newest developer version containing libcurl.def:
http://curl.haxx.se/gknw.net/7.32.0/dis ... ingw32.zip
Ah, so it's generated during the build then. And the mingw build probably doesn't generate it.
User avatar
mariosk8s
Enthusiast
Enthusiast
Posts: 103
Joined: Wed Apr 06, 2011 11:37 am
Location: Hüfingen, Germany
Contact:

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by mariosk8s »

Thanks @sec
This post was helpful in bringing me closer. Since i used mingw to build curl i'm using libcurldll.a.

This made it compile :D

Unfortunately the then my compiled DLL, not libcurl, won't dlopen :(

Of course now i'm trying to load a DLL that imports the wrapper function which links to libcurl.
Then i also dlopen libcurl.

Is there some way of debugging OpenLibrary. Currently it just reports "No", but not "Why".
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: curl_easy_setopt fails on 64 bit CentOS 6

Post by Kukulkan »

Just an idea:
Is there a way to correctly call curl_easy_setopt() by using inline ASM functionality?
In other words: Is it possible to call a function of a loaded DLL from inline ASM?

Maybe this avoids the need of a wrapper and can be done by a macro using ASM?

Kukulkan
Post Reply