X-Spam-Check-By: sourceware.org Message-ID: <5f0807670708110341m5fc98238j12697c696c6b3c@mail.gmail.com> Date: Sat, 11 Aug 2007 03:41:25 -0700 From: "Pradip Jadav" To: cygwin AT cygwin DOT com Subject: Re: Creating dll in cygwin gives "Undefined reference" errors In-Reply-To: <46AB5AFF.A5AA4C8E@dessent.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5f0807670707280532t44a7d607vf92a06231313d5d9 AT mail DOT gmail DOT com> <5f0807670707280535u71d26ef6s4b0af545f30cd04f AT mail DOT gmail DOT com> <46AB5AFF DOT A5AA4C8E AT dessent DOT net> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 7/28/07, Brian Dessent wrote: > Pradip Jadav wrote: > > > But when I compiles in cygwin it gives me some "Undefined reference" errors. > > Take an example, > > > > /cygdrive/e/DOCUME~1/LOCALS~1/Temp/ccLMFYUe.o:sample.c:(.text+0x4c): > > undefined reference to `createlog(int, char*, ...)' > > > > Now this "createlog" function is defined in one of .cpp file of my > > main program.(Just for your information) > > > > Can you help me to solve problem of "undefined reference" ?? > > The undefined reference is because fundamentally ELF (Linux) and PE/COFF > (Windows) are very different in terms of how linking works under the > hood. The short explanation is that PE/COFF requires all references to > be resolved at link-time, thus you have to explicitly tell the linker > where createlog() is to be found. > > But I've typed this explanation so many times, I think I'll just start > linking to past copies of it: > > http://www.cygwin.com/ml/cygwin/2005-07/msg00675.html > http://www.cygwin.com/ml/cygwin/2006-12/msg00592.html > http://www.cygwin.com/ml/cygwin/2007-06/msg00450.html > > Brian > > -- > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple > Problem reports: http://cygwin.com/problems.html > Documentation: http://cygwin.com/docs.html > FAQ: http://cygwin.com/faq/ > > Hi Brian, First of all thanx for your reply. Secondly, sorry for not going through all previous helps. BTW, following link helped me a lot. http://www.cygwin.com/ml/cygwin/2006-12/msg00592.html YEAH, Now I am able to create .dll file and also succeeded in attaching it to the main executable. Steps are ... ###create main.c and do dllexport for a function. For example, In main.c ==> __declspec(dllexport) int func1() ###create object file. g++ -c main.c ###create main.exe file. g++ -o main.exe main.o -ldl ###create .def file dlltool.exe --export-all-symbols --output-def main.def main.o ###create main library file. dlltool.exe --dllname main.exe --def main.def --output-lib libmain.dll.a ###create DLL. g++ -shared -o theDLL.dll theDLL.c -L. -lmain Thats it ...!! :) But scene is not this much only.. This was the scene with a single function. What if we want to export more than one function from main program? What if we want to use a class which is declared in main program(Using this class I Want to create a derived class in dll code)? Do I need to specify "__declspec(dllexport)" for all? Is there any other way? Its because my program is quite big. So managing code will be very tough na? Waiting for reply. -- Regards, Pradip K. Jadav (Mob.)+91-9323315353 -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/