| With gcc, just "-lcsound" can mean libcsound.a, libcsound.so, csound.so, and if there are symbolic links in the lib directory, maybe things like libcsound64.so.5.1, libcsound64.so, and so on, with (I certainly hope) only one physical .so/.a pair or one .so or .a file, and all other references being symbolic links to the physical file.
You will usually get undefined reference errors when using ld to link with one shared library at build time, if another shared library that the first one depends on cannot be found by the linker. This can be resolved by linking explicitly as you did, or in other ways (gets technical, but mainly by properly installing all the shared libraries involved, or by passing -rpath-link [path] to ld).
LD_LIBRARY_PATH is used by the operating system linking loader ld.so at run time, to find libraries that have not been "properly installed," the meaning of which depends on the specific operating system. You can either try installing all the libraries (may involve using ldconfig, see its man page), or you can just set up your .cshrc or .profile or whatever, the shell script file that runs by default whenever you login or whenever you open a console, to export this variable so it is always available (this is what I do).
There is no shame in using LD_LIBRARY_PATH, you should use whichever solution makes the most sense for you in your situation. If you are often building Csound from sources, exporting LD_LIBRARY_PATH to enable running Csound from the build directory makes a lot of sense, this is what Victor Lazzarini and I do (I also, separately, install Csound so I can run it that way also to make sure the installation works). If you seldom or never build Csound from sources, you should install it properly.
What ldconfig does is whatever it takes to get the operating system linking loader to automatically find and load shared libraries....
Read the man pages for ld.so and ldconfig to understand how Linux handles shared libraries.
Hope this helps,
Mike
-----Original Message-----
>From: James Hearon
>Sent: Aug 20, 2008 12:41 PM
>To: csound@lists.bath.ac.uk
>Subject: [Csnd] GCC Linux
>
>
>Hi,
>A bit stumped on GCC Linux (fedora) differences from MinGW GCC. Trying to compile simple api example (interfaces/csound/csound_main.c) using GCC from the command line using csound5 or build as the current directory. Linking to libcsound.a, but get lots of undefined ref errors.
>
>$ gcc -Wall -O2 -IH -L. csound_main.c -o csound_main -lcsound
>
>Works fine in MinGW. Tried all sorts of things with Linux GCC (permissions, direct paths, static flag, different versions etc.), but only work around I could stumble upon was also include any shared lib (ex. librtalsa.so), to make the undefined reference errors go away.
>
>$ gcc -Wall -O2 -IH -L. csound_main.c -o csound_main -lcsound -lrtalsa
>
>But then I need to set the LD_LIBRARY_PATH variable to run the binary file because of the linked .so lib.
>
>Just seems odd. Wonder if anyone could help explain. Thanks.
>
>gcc --version
>gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)
>
>
>_________________________________________________________________
>Get ideas on sharing photos from people like you. Find new ways to share.
>http://www.windowslive.com/explore/photogallery/posts?ocid=TXT_TAGLM_WL_Photo_Gallery_082008
>
>Send bugs reports to this list.
>To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
|