This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Building cpan module that links with proprietary libs

On 5/29/2014 1:29 AM, Csaba Raduly wrote:
Hi Andrew,

On Thu, May 29, 2014 at 4:12 AM, Andrew DeFaria  wrote:
I'm attempting to build a cpan module (well actually it's not a cpan module
but rather a module that uses MakeMaker and has the familiar perl
Makefile.PL, make, make test, make install installation procedure.
Additionally I need to link it to a set of proprietary libs that I am given
only the .lib files for. If you must know this is for Perforce's P4Perl
which I'd like to get working with Cygwin's Perl natively.

I download the P4API bundle (the package that has include files and the .lib
files pre-compiled).

The C++ P4 API is platform-specific; which platform did you choose?
If it really contains .lib files (not .a), those are not recognized by
Cygwin's gcc.

I had two archives two choose from. One was for Windows and contained the .lib files. The other was for Linux and contains .a files. I first tried the Linux one but that failed with:

g++  -shared P4.o  -o blib/arch/auto/P4/P4.dll lib/libp4.a      \
/usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE/cygperl5_14.dll -L/cygdrive/a/p4perlBuild/p4api/lib -lclient -lrpc -lsupp -lp4sslstub \

collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped
Makefile:531: recipe for target 'blib/arch/auto/P4/P4.dll' failed
make: *** [blib/arch/auto/P4/P4.dll] Error 1

I can give you more output if you need it.

Then I switched to the Windows archive that contained the .lib files.

I think the issue is that their Windows P4Perl build system uses Visual Studio to build and on Linux it uses g++. Their installation package is only for ActiveState. Supposedly at 5.18 ActiveState is changing to a g++ based backend using MingW I think so they'll eventually have to figure this out. Meantime I'm just trying to get it working under Cygwin's Perl...

Next I need to do:

$ perl Makefile.PL --api-dir /.../path/to/unzipped/p4api

This works fine and I procedure with the make. This fails with things like:

make[1]: Leaving directory '/cygdrive/a/perl/P4Perl.Cygwin/lib'
g++ -c  -I/cygdrive/a/perl/ -Ilib -x c++
-DUSEIMPORTLIB -O3   -DVERSION=\"2014.1\" -DXS_VERSION=\"2014.1\"
-DID_OS="\"CYGWIN17THREAD\"" -DID_REL="\"2014.1\"" -DID_PATCH="\"842847\""
-DID_Y="\"2014\"" -DID_M="\"05\"" -DID_D="\"06\"" -DOS_CYGWIN -DOS_CYGWIN17
-DID_API="\"2014.1/821990\"" P4.c
Running Mkbootstrap for P4 ()
chmod 644
rm -f blib/arch/auto/P4/P4.dll
g++  -shared P4.o  -o blib/arch/auto/P4/P4.dll lib/libp4.a      \
   /usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE/cygperl5_14.dll        \

P4.o:P4.c:(.text+0x45ac): undefined reference to `ClientApi::SetClient(char
P4.o:P4.c:(.text+0x45ac): relocation truncated to fit: R_X86_64_PC32 against
undefined symbol `ClientApi::SetClient(char const*)'
P4.o:P4.c:(.text+0x4a9c): undefined reference to `ClientApi::SetHost(char

Notice that it removes P4.dll, so it seems to know it's working with dll's,
but then it calls g++ with a -o for libp4.a!

No it doesn't. The argument to -o is blib/arch/auto/P4/P4.dll
lib/libp4.a is the next input file.

Good catch! I missed that.

> What does the following say?

nm lib/libp4.a | c++filt


Meantime it fails with many undefined references. I think I might need to do
perl Makefile.PL with other opts to tell it that while it's using Cygwin and
can be very Linux-like, it needs to produce .dll's and not .a's or .o's.

It seems to be on the right track; "g++ -shared -o P4.dll" sounds good to me.

Thanks for your help.
Andrew DeFaria

Attachment: nm.libp4.a.out
Description: Text document

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]