ingydotnet / inline-c-pm

10 stars 19 forks source link

Can't call libcurl with Inline::C on Windows #95

Closed xiaoyafeng closed 5 years ago

xiaoyafeng commented 5 years ago

please reference here https://www.perlmonks.org/?node_id=11108859 I suspect Inline::C can't tell dll.a file correctly. Is there a way to know why dynaloader can't call xs.dll file?

sisyphus commented 5 years ago

AFAICT, if both libcurl.dll.a (import library) and libcurl.a (static library) exist in the same folder, then "-lcurl" will link to libcurl.a. If one wants to link to libcurl.dll.a then one has to either: a) remove or rename libcurl.a or b) link by specifying "-lcurl.dll"

I think this behaviour is controlled by gcc's linker, and has nothing to do with Inline::C.

Cheers, Rob

xiaoyafeng commented 5 years ago

Hi Rob, When I explicitly use -lcurl.dll.a, linker will sucessfully get thing done, but Dynaloader throw an error: Finished Build Compile Stage

Had problems bootstrapping Inline module 'bb_pl_d714'

Can't load 'C:\Users\Administrator\Downloads\curl-7.67.0_4-win64-mingw\curl-7.67.0-win64-mingw_Inline\lib/auto/bb_pl_d714/bb_pl_d714.xs.dll' for module bb_pl_d714: load_file:The specified module could not be found at C:/perl/perl/lib/DynaLoader.pm line 193. at C:/perl/perl/site/lib/Inline.pm line 541.

at bb.pl line 6. BEGIN failed--compilation aborted at bb.pl line 6.

sisyphus commented 5 years ago

I get the same thing if I don't have the location of the libcurl dll in my path:

Finished Build Compile Stage

Had problems bootstrapping Inline module 'bb_pl_8e02'

Can't load 'C:_32\pscrpt\inline_Inline\lib/auto/bb_pl_8e02/bb_pl_8e02.dll' for module bb_pl_8e02: load_file:The specified module could not be found at C:/_64/perl530_810/lib/DynaLoader.pm line 193. at C:/_64/perl530_810/site/lib/Inline.pm line 541.

at bb.pl line 6. BEGIN failed--compilation aborted at bb.pl line 6.

I also get a pop-up telling me that libcurl-4.dll could not be found, though I gather you're not seeing that pop-up.

But when I add the location of libcurl-4.dll to my path, everything goes fine. I just need to do: set PATH=%PATH%;C:_64\msys64\mingw64\bin and then re-run perl bb.pl.

I'm not actually using Strawberry Perl, and that means my perl-5.30.0 builds "bb_pl_8e02.dll" instead of "bb_pl_8e02.xs.dll". However, I'm quite sure that difference is not causing any problem.

BTW, I noticed you specified "-lcurl.dll.a". If you really did specify "-lcurl.dll.a" then the build should have died before "Finished Build Compile", so I guess that was just a typo in your post. I mention it because it's worth being mindful of the need to NOT specify the ".a". Failure to do that can lead to much head scratching (or worse ;-)

Cheers, Rob

On Tue, Nov 19, 2019 at 6:02 PM xiaoyafeng notifications@github.com wrote:

Hi Rob, When I explicitly use -lcurl.dll.a, linker will sucessfully get thing done, but Dynaloader throw an error: Finished Build Compile Stage

Had problems bootstrapping Inline module 'bb_pl_d714'

Can't load 'C:\Users\Administrator\Downloads\curl-7.67.0_4-win64-mingw\curl-7.67.0-win64-mingw_Inline\lib/auto/bb_pl_d714/bb_pl_d714.xs.dll' for module bb_pl_d714: load_file:The specified module could not be found at C:/perl/perl/lib/DynaLoader.pm line 193. at C:/perl/perl/site/lib/Inline.pm line 541.

at bb.pl line 6. BEGIN failed--compilation aborted at bb.pl line 6.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ingydotnet/inline-c-pm/issues/95?email_source=notifications&email_token=AAAR3PDNZYPFLGF4BNA47YLQUOFRDA5CNFSM4JO47IJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEENC6JQ#issuecomment-555364134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAR3PFAT6EH5P37NOGWTN3QUOFRDANCNFSM4JO47IJA .

xiaoyafeng commented 5 years ago

Thanks Rob, If I use pure portable strawberry perl, it's still failed even if I add bin into PATH. but if I use libcurl in MSYS2 , it goes fine. Since Idon't want to deploy both MSYS2 and strawberry perl, I'll try copy libcurl to strawberryperl directory.