libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: different linker parameters from similar Makefiles when building MSV


From: Peter Rosin
Subject: Re: different linker parameters from similar Makefiles when building MSVC DLLs in cygwin (with erlang wrappers)
Date: Tue, 28 Jun 2011 21:08:37 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11

Den 2011-06-28 16:00 skrev Peter Rosin:
> Den 2011-06-28 13:47 skrev Dave Cottlehuber:
>> Hi libtoolers,
>>
>> I am building 2 Win32 DLLs to be loaded into the erlang runtime VM as NIFs,
>> based on snappy (mixed C & C++) and ejson/yajl (in C), all part of porting
>> latest CouchDB trunk to Windows - config is at [8].
>>
>> They use a similar Makefile.am [2],[3] and share configure.ac [1], but during
>> compile & linking ejson succeeds [7] and snappy doesn't [6], despite the
>> Makefiles being almost identical.
>>
>> There are 2 errors reported;
>> - output filename is specified twice & therefore fails
>>
>>         LINK : fatal error LNK1149: output filename matches input
>> filename 'C:\cygwin\relax\git_couch\src\snappy\.libs\snappy_nif.dll'
>>
>> - libtool adds unwanted flags, instead of -DLL (per working build)
>>
>>         LINK : warning LNK4044: unrecognized option '/shared'; ignored
>>         LINK : warning LNK4044: unrecognized option '/nostdlib'; ignored
>>         LINK : warning LNK4044: unrecognized option
>> '/-enable-auto-image-base'; ignored
>>         LINK : warning LNK4044: unrecognized option '/Xlinker'; ignored
>>         LINK : warning LNK4044: unrecognized option '/-out-implib'; ignored
>>         LINK : warning LNK4044: unrecognized option '/Xlinker'; ignored
>>
>> Only the final link phases differ materially in the parameters passed. If 
>> [7] is
>> manually run with these changes, bringing it into line with [6], it works:
>>
>>     - remove '-Xlinker --out-implib -Xlinker \$lib'
>>     - swap '-shared -nostdlib' ' for '-dll'
>>
>> When libtool is hacked up [4], I can get a cleanish link [5] but this clearly
>> isn't the Right Thing To Do.
>>
>> What do I need to change, to ensure libtool passes the linker the same 
>> options
>> in both DLLs? What am I missing?
>>
>> Finally, given we are using these makefiles/configure.ac on multiple 
>> platforms
>> have you got any other suggestions to improve things?
> 
> Lots of questions. Here's a a couple of my questions...
> What is cc.sh? Some kind of wrapper I suppose? Have you checked how the
> libtool testsuite fares when run with that wrapper?
> How did you configure the different packages?
> Have you tried to build with MinGW?
> 
> In my experience, attempting to write ad-hoc wrappers that makes MSVC look
> like gcc is not what works best. I dearly recommend that you ditch the
> cc.sh wrapper and instead use the compile wrapper from automake and trigger
> its use with AM_PROG_CC_C_O in your configure.ac. Unfortunately you need
> to get copies of a recent version the compile wrapper from the Automake git
> repository (master branch, in the lib subdir). Also grab the ar-lib wrapper
> script from there. Then configure your packages along these lines:
> 
> .../configure CC="cl -nologo" CFLAGS=-MD CXX="cl -nologo" CXXFLAGS=-MD 
> LD=link AR=/path/to/ar-lib NM="dumpbin -symbols" STRIP=: RANLIB=:

Oops, forgot to say, you need to do that from an MSYS shell, not a Cygwin
shell. Sorry about that...

Cheers,
Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]