From: *jeffdb AT netzone DOT nospam DOT com (Mikey) Subject: Re: [Help] Undefined referece to fopen and other Stdlib functions when compileing a dll 21 Jul 1997 06:56:51 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <33d357eb.11676717.cygnus.gnu-win32@smtp.netzone.com> References: <199707210121 DOT SAA27257 AT rohan DOT sdsu DOT edu> Reply-To: *jeffdb AT netzone DOT nospam DOT com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Original-To: plasencia , gnu-win32 AT cygnus DOT com In-Reply-To: <199707210121.SAA27257@rohan.sdsu.edu> X-Mailer: Forte Agent 1.01/32.397 Original-Sender: owner-gnu-win32 AT cygnus DOT com When using ld.exe directly, instead of using the compiler driver gcc.exe you must specify all of the libraries you want to link into the application, like this -lkernel32 -luser32 -lgdi32 you must also tell the linker where to find these libraries like this -L/my/lib/dir It's usually much easier to let gcc link in the appropriate libraries, by using gcc -mwindows when you are ready to link, although -m anything is a bad name for a gcc option, because it's reserved for processor options by the specs file, but that's what cygnus did. the quickest way that I know of to find out what libraries are needed is to cd into the directory where your libraries are, typically .../H-i386-cygwin32/i386-cygwin32/lib and do grep -l functionname * small (L) functionname without the @16 on the end do that for 2 or three of the functions that are showing up as not found, and then relink with whichever libraries contain the function. also on your link line below you need to use --dll -e _DllMain AT 12 (or whatever your dll init function is) On Sun, 20 Jul 1997 18:21:54 -0700 (PDT), you wrote: > >Hi Folks, >I have been using GCC for some time now. I have never had any problems with Gcc Cygwin > until I tired to compile some source code that was developed using MSVC++4.0. > > The source code is a Dll. > > When I create and compile my own Dlls using Cygwin I have no problems. However now that I > am trying to compile the MSVC++ code I am gettion all sorts of undefined references to > standard lib files. > > > I have a pentium 32MB RAM. > Cygwin vew b18 and have the Unix utils setup. > Windows95 > > > The source code does compile. I do get my object files. It is durint like time that I get > my errors. > > I am not using a make file, but I am using a Bash srcipt to compile my dll. The script is > small and looks like this > > *******----------------------------------********************** > #!/bin/sh > > INCLUDE="/Gator/Test/IOTEST~1/GCC-DLLs/Include" > > gcc -c commio.c -I $INCLUDE > > gcc -c timer.c -I $INCLUDE > > echo EXPORTS > commioB.def > > > nm commio.o timer.o | grep '^........ [T] _' | sed 's/[^_]*_//' >> commioB.def > > dlltool --def commioB.def --output-exp commio.exp --output-lib commio.a --dllnam > e commio.dll > > ld -o commio.dll commio.exp commio.o timer.o > > *******----------------------------------********************** > > As I said eariler, the code did compile, but during link time I got this errors > > commio.o(.text+0x885):commio.c: undefined reference to `fprintf' > commio.o(.text+0x897):commio.c: undefined reference to `fclose' > commio.o(.text+0x91e):commio.c: undefined reference to `fopen' > commio.o(.text+0x92d):commio.c: undefined reference to `Sleep AT 4' > commio.o(.text+0x93d):commio.c: undefined reference to `GetCommState AT 8' > commio.o(.text+0x95b):commio.c: undefined reference to `SetCommState AT 8' > commio.o(.text+0x96a):commio.c: undefined reference to `GetCommProperties AT 8' > commio.o(.text+0x97d):commio.c: undefined reference to `ClearCommError AT 12' > commio.o(.text+0x99a):commio.c: undefined reference to `OutputDebugStringA AT 4' > commio.o(.text+0x9bb):commio.c: undefined reference to `WriteFile AT 20' > commio.o(.text+0x9f1):commio.c: undefined reference to `fprintf' > commio.o(.text+0xa28):commio.c: undefined reference to `fprintf' > commio.o(.text+0xa3e):commio.c: undefined reference to `fprintf' > commio.o(.text+0xa50):commio.c: undefined reference to `fclose' > commio.o(.text+0xa92):commio.c: undefined reference to `fopen' > > There are alot more, I just wanted to give a sample. > > It looks to me like the code I not linking to the libaries, but I do not know enough > about Cygwin to find out exactly what libs are linked or not. > > > Thanks in advanced > -- >-- >______________________________________________________________________________ > Xavier Plasencia | > San Diego State University | Internet : plasenci AT rohan DOT sdsu DOT edu >______________________________________________________________________________ > > >- >For help on using this list (especially unsubscribing), send a message to >"gnu-win32-request AT cygnus DOT com" with one line of text: "help". > (*jeffdb AT netzone DOT nospam DOT com) Remove *&.nospam from the above to reply Mikey - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".