This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can you make a DLL from a library that requires caller-defined functions?


Thanks again, Yaakov.
The problem now that the linker doesn't like the undefined references for a static library any better then it does for a DLL.? I can get a static library file if I just run the defualt makefiles which use?"ar" followed by "randlib" to make a table,?but?that doesn't?produce viable executibles when I link it to the test files including the X11 libraries,?carefull observing the linking? order as Yaakov suggested.
On the other hand,?if I try to create the?static library?using the linker instead (via gcc) as in
gcc -o?staticfoo.a? foo_1.o ... foo_n.o?-lXpm -lX11??? 
it gives exactly the same "undefined reference" errors as in the case for?when I try to make a shared library (DLL)?with the addition of
/lib/libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain@16'
I suppose I left something important out of that line.? I know I can run ld directly or pass it options with "-Wl" but I?must not?know the right options to set in any event.?Sorry, I'm?very inexperienced at making libraries.? I've tried to use?the ar/randlib approach after compiling with what I know are the right include directories and linking with the correct library paths,?but the resulting executibles still aren't working.

It occurs to me that the simple way to compile?an executible?using this library is just?to forget making it a separate library and link all the library's object files directly to?the executible.? That seems like the?simplest solution and I don't see why it won't work as long as I specify the X11 library dependencies correctly at link time.

Mike

----- Original Message ----
From: Yaakov (Cygwin Ports) <yselkowitz@users.sourceforge.net>
To: cygwin-xfree@cygwin.com
Sent: Thursday, August 7, 2008 10:53:38 AM
Subject: Re: Can you make a DLL from a library that requires caller-defined functions?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

http://cygwin.com/acronyms/#PCYMTWLL !

Michael Rogers wrote:
| Yes, precisely.? It has symbols for routines that are declared in a
| header file and called in some of the library routines.? But they
| are actually required to be defined in the calling program. Thinking
| back to libraries I've linked to in the past, I don't think this
| is an entirely uncommon practice, at least with not static libraries.

It's not, and in those cases, generally a static library is necessary.

| It's fine with me to make it static but it has dependencies on the X11
| and Xpm libraries, which are DLLs.? So would it be ok to make it at
| static library?

Yes, as long as you make sure that you link the executable in the right
order. IOW:

gcc -o bar.exe bar.o -lstaticfoo -lXpm -lX11

If you change the order of the link libraries, it will not work.

| The original library was static and was intended to be linkable
| against arbitrary calling programs, as long as they define the
| three required functions within them.? I want this library only
| because it is used in one specific physics program - that's my real
| goal. So I don't absolutely need it to be linked against any other
| programs (but the test programs? would be nice).

Sounds like static is the way to go, particularly if you're not linking
other libraries against this one.


Yaakov
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEAREIAAYFAkibKJIACgkQpiWmPGlmQSPWCACfZHj0FVqi0hoAIlqWki15P67l
vOsAnjtKPa5PYZgCZvzx4f6VfakTBhSp
=sV9p
-----END PGP SIGNATURE-----

--
Unsubscribe info:? ? ? http://cygwin.com/ml/#unsubscribe-simple
Problem reports:? ? ? http://cygwin.com/problems.html
Documentation:? ? ? ? http://x.cygwin.com/docs/
FAQ:? ? ? ? ? ? ? ? ? http://x.cygwin.com/docs/faq/


 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]