Dave Korn wrote:
  Wrong reasoning.  The actual problem is that you need to remove the 'lib'
prefix when supplying a library name:

g++ -o hello -L/lib hello.cpp -lcrypt
g++ -o hello -L/lib hello.cpp -lbfd

  Ordinary .a files are for static linking, .dll.a files are for runtime
linking against dlls, gcc selects the right one for you by using one of the
-shared or -static flags.

Err, no. gcc (by default) will use .dll.a files in preference to .a files -- more completely, the search pattern for -lxxx is, in each directory:

          libxxx.dll.a
          xxx.dll.a
          libxxx.a
          xxx.lib
          cygxxx.dll
          libxxx.dll
          xxx.dll
          libxxx.a (again, for architectural reasons)
          xxx      (this is so that stuff like -lmyspecific.o will
                    work as expected).

     before moving on to the next directory in the search path.

With -static, -lxxx only looks for:

          libxxx.a
          xxx

Note that, oddly, in -static mode a MS-style library name "xxx.lib" will be ignored, while in (normal) mode it will be used if found (and the other patterns ahead of it are not found). Just an odd little quirk.

-shared is something competely different. It means: make the output file a DLL instead of an executable.

--
Chuck

--
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/

Reply via email to