Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <17B78BDF120BD411B70100500422FC6309E21F@IIS000> From: Bernard Dautrevaux To: "'robert DOT jan DOT schutten AT philips DOT com'" , cygwin AT sources DOT redhat DOT com Subject: RE: How to compile a .LIB with cygwin for use in MS Visual C Date: Wed, 28 Feb 2001 17:46:44 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" > -----Original Message----- > From: robert DOT jan DOT schutten AT philips DOT com > [mailto:robert DOT jan DOT schutten AT philips DOT com] > Sent: Wednesday, February 28, 2001 4:45 PM > To: cygwin AT sources DOT redhat DOT com > Subject: How to compile a .LIB with cygwin for use in MS Visual C > > > Hi all, > > I am trying to compile library using cygwin. This library compiles > perfectly with gcc on various unix platforms and with the > cygwin version > on gcc on a MS-windows machine. Also usage of this library is > working perfectly on all these platforms. > > Now the problem: > > I would like to use the compiles library as a .LIB under MS Visual C. > > So why don't I just distribute source code of my library so that it > can be compiled with Visual C. > Reason: I rely on automatic source code generation, which works > with a combination of makefiles and standard unix tools. This is > difficult to port to Visual C. > > What did I try: > > I tried including my library (it's called libcpfspd.a) at > the linking stage > of Visual C by just adding this to the line "Object/library modules" > > I get the following linking error: > > --------------------Configuration: cpfspd_test2 - Win32 > Release-------------------- > Linking... > libcpfspd.a(cpfspd_hdr.o) : error LNK2001: unresolved > external symbol __impure_ptr > libcpfspd.a(cpfspd_low.o) : error LNK2001: unresolved > external symbol __impure_ptr > libcpfspd.a(cpfspd_low.o) : error LNK2001: unresolved > external symbol __alloca > libcpfspd.a(cpfspd_low.o) : error LNK2001: unresolved > external symbol ___errno > Release/cpfspd_test2.exe : fatal error LNK1120: 3 unresolved externals > Error executing link.exe. > > cpfspd_test2.exe - 5 error(s), 0 warning(s) > > Next try: compile the library with -mno-cygwin: > Following result: > > --------------------Configuration: cpfspd_test2 - Win32 > Release-------------------- > Linking... > libcpfspd-mno-cygwin.a( > ) : error LNK2001: unresolved external symbol ___imp__iob > libcpfspd-mno-cygwin.a( > ) : error LNK2001: unresolved external symbol ___imp__iob > libcpfspd-mno-cygwin.a( > ) : error LNK2001: unresolved external symbol __alloca > Release/cpfspd_test2.exe : fatal error LNK1120: 2 unresolved externals > Error executing link.exe. > > cpfspd_test2.exe - 4 error(s), 0 warning(s) > > > So, is it possible to compile with cygwin and use the result > with Visual C, > or am I asking for the impossible? > I'm not sure of the exact procedure to follow, but at least you must use -mno-cygwin when compiling this kind of code (and you must check the the mingw32 support is properly installed, depending on your cygwin version). This was already discussed a number of times on this list so e search of the archive should provide the necessary links. In fact to interoperate with Visual-C code you MUST compile in MinGW32 mode, not cygwin. Moreover you can ONLY share C code (that's why I say Visual-C and not Visual-C++); gcc-generated C++ code cannot be called from Visual-C++-compiled C++ code, nor the other way round. They cannot and would most certainly NEVER work together. HTH Bernard -------------------------------------------- Bernard Dautrevaux Microprocess Ingenierie 97 bis, rue de Colombes 92400 COURBEVOIE FRANCE Tel: +33 (0) 1 47 68 80 80 Fax: +33 (0) 1 47 88 97 85 e-mail: dautrevaux AT microprocess DOT com b DOT dautrevaux AT usa DOT net -------------------------------------------- -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple