Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#1 libset libs="xx,yy,zz" wasn't working (Solaris)

Daniel Feistamel

I needed to use the CC compiler on UnixWare and
Solaris. My code compiled all the .cpp files to .o
files but, the linker step didn't add the libraries to
the command line. Follwoing is the XML that I tried to

<cc outfile="results/myexe" objdir="work" >
<compiler name="CC">
<compilerarg value="-O"/>
<compilerarg value="-Kthread"/>
<fileset dir="dir1/src" />
<fileset dir="dir2/src"/>
<linker name="CC">
<linkerarg value="-O"/>
<linkerarg value="-Kthread"/>
<linkerarg value="-L/mylib"/>
<libset libs="socket,nsl,++">
location="mydir/include" />
<sysincludepath location="/usr/include/CC" />

This is a simplified version for sake of discussion.
The libset libs= (system libraries) line gets ignored
when parsed becuase the code is trying to append a
path to the above library basenames and make them real
libraries to make sure they exist (there isn't a path
to append). To get your libraries to work, all of the
examples show the use of:
<fileset dir="/usr/lib" includes="libnsl.so"/>
within the libset. This gets the the library put on
the command line as a user library before the .o
files. This may work for g++ but not for CC on
UnixWare since the linker is a single pass linker (all
symbols are resolved in command line order, libraries
need to be last). I did some overhauling of the code
to put the user and system libraries last. I also
simplified the visitSystemLibraries and all underlying
code to not expand the library and try to make sure
they are real (the compiler will do that). I just
wanted to get the basename with the linker dependent
library flag (.i.e. -l for CC) on to the end of the
command line. The visit method for the System
libraries in CCTask.java had to be changed to just
create an array of basenames (Strings), I kept the
hashtable for the sake of modifying a lot but the key
is passed as both arguements to the hashtable. I
modify the link() method (The one that takes the
system libraries as an arguement) and made it add the
system libraries after my .o's and put
linker.addLibrary(String) in the interface. This
prepends the -l (for CC) and returns -l<basname>.
These changes make my case work and compile correctly.
The followiong is the verbose output(simplified) of my
link command:
[cc] CC -O -Kthread -L/mydir/lib -L/other/lib -
o/results/cpp/myexe /work/cpp/first.o /work/cpp/second.
o /work/cpp/last.o -lsocket -l++ -lnsl

I have the source and would like to share it. It does
change a lot of what visitSystemLibraries (simplies
it) does and the compiler/AbstractLinker.java isLibrary
() (added an end with .* (system library designation).
Also, the linker.bid() method needs to bid for things
ending with .* This took me a day to do. If you want
the code, let me know what I should do. I don't want
it put into CVS as it changes the interface and may
break devestudio and gcc. Adding the CC compiler was
easy (2 hours). I added it as cc because CC added too
many captial C's in a row. CC works on Unixware (UCS
C++) and Solaris (Forte C++).


  • Logged In: NO

    It works for me as long as the length of the libs was
    more then 3 characters. For example libs="pthread" works
    but libs="dl" or libs="pthread,dl" causes an exception.

  • Curt Arnold
    Curt Arnold

    • summary: libset libs="xx,yy,zz" wasn't working --> libset libs="xx,yy,zz" wasn't working (Solaris)