Subject: Re: Linking against .lib libraries
From: [email-masked] (Paul Garceau)

6 Sep 1998 05:07:57 -0700
Message-ID: <[email-masked]>
References: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7BIT
To: [email-masked]

Hi folks,

On 4 Sep 98, at 21:53, the Illustrious Serge Torres wrote:

> I'm trying to build a dll wich has a code written and compiled with
> cygwin32 and at the last stage has to be linked it a .lib library from
> Microsoft.
> 
> I need this combination to create a dll that implements new extended
> procedures
> in MS SQLSERVER.

	I understand...I had to attempt to do something similar with DirectX3.  
Alas, it is the nature of MS to make it, or so it seems, as difficult as possible 
for anyone to link their .lib files without their compilers/linkers.  It is sad but 
true.

	Here is something else you may want to try (I haven't been able to do it 
with my NT4 system due to the fact that I've not ever had MSVC/C++ on this 
system); compile and build the object code using Cygwin, or, better yet, 
convert to EGCS 1.1, and then attempt to link using the MS link program if 
you still have it available.  Forgive the analogy, even so, this is a "shot-in-the-
dark" sort of approach.  Even so, if you "hit" something, at least you know 
you had your tool aimed properly and can work from there. (guns were tools 
before they became weapons...)
> 
> I have manged to link to the library but I get a lot of warnings
> ("ignoring duplicate  section `.text`" as mentioned, in a not very
> different context by Berend Ozceri from Istanbul.

	It sounds like linking errors.

	As another approach, impdef the MS SQL .dll files you need into .def 
files, then massage the files to have the right "@xx" postfixes so that they 
may become useable by something like Cygwin or EGCS, if they aren't 
already listed in the .def files with the "@xx" postfixes.

	[Colin Peters has an excellent tutorial on generating .dll files for, as far 
as I recall, that works for _both_ EGCS-1.1 and Cygwin32:
	http://www.geocities.com/Tokyo/Towers/6162/gcc.html (US Mirror)
	http://www.fu.is.saga-u.ac.jp/~colin/gcc.html (Japanese Site)]

	From the .def files, generate .a files using something like dllwrap or 
dlltool using one of the .dll helper binutils that, I believe, were created Colin 
Peters for Mingw32.  If you are using EGCS-1.1, then you probably won't 
have any problems using the SQL calls that you wish to use and everything 
will, at the very least, link.  Runtime testing would become the next step.

	If you're not using EGCS-1.1, then I would encourage you to download 
EGCS-1.1-Mingw32.

	[See Mumit Khans Gnu-Win32 web site:  	
		http://www.xraylith.wisc.edu/~khan/software/gnu-win32/]

	EGCS-1.1 is slowly replacing the Cygwin32 branch of Gnu-Win32 and is 
very stable.

	This approach, for the most part, has always worked with very few 
exceptions...

		I hope that this helps.

			Peace,

				Paul G.
> 
> The dll is definetly unworkable, it will not be loaded by SQL SERVER and
> when viewed under an hex editor will show a lot of source code included.
> 
> I think I've understood that .lib file format is not compatible with .a
> format.
> 
> Is it ture ? Is it really impossible to link cygwin (egcs 2.0.1) generated
> against .lib libraries ? Is it really hopeless ? I would not like to have
> to move back to VC.
> 
> Thanks
> 
> Serge Torres
> Centre National de Documentation Pedagogique
> 
> 
> 
> 
> -
> For help on using this list (especially unsubscribing), send a message to
> "[email-masked]" with one line of text: "help".
> 

Information Systems Consultant
NewDawn Productions
http://www.teleport.com/~pgarceau/newdawn/
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".