?
Solved

cvstrac compile - ld: fatal: Symbol referencing errors. collect2: ld returned 1 exit status

Posted on 2007-08-07
16
Medium Priority
?
192 Views
Last Modified: 2016-05-28
I am attempting to compile cvstrac for Solaris 9 ad Solaris 10.  I get the following error(s):  

$ make
gcc -g -O0 -Wall -o cvstrac attach.o  browse.o  cgi.o  common.o  cvs.o  db.o  format.o  git.o  history.o  index.o  login.o  main.o  md5.o  rss.o  search.o  setup.o  svn.o  test.o  throttle.o  ticket.o  timeline.o  tools.o  user.o  view.o  wiki.o  wikiinit.o -lsqlite3 -lcrypt -lm
Undefined                       first referenced
 symbol                             in file
bind                                cgi.o
accept                              cgi.o
listen                              cgi.o
socket                              cgi.o
fdatasync                           /usr/local/lib/gcc/sparc-sun-solaris2.9/3.4.6/../../../libsqlite3.so
setsockopt                          cgi.o
getpeername                         cgi.o
inet_ntoa                           cgi.o
ld: fatal: Symbol referencing errors. No output written to cvstrac
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `cvstrac'


I am unfamiliar with the linking protocol of gcc.  It looks like I am missing a reference to some sort of networking binaries library in my Makefile.  

Here is my LD_LIBRARY_PATH environment setting:

$  echo $LD_LIBRARY_PATH
/usr/openwin/lib:/usr/lib:/usr/local/lib:/lib

Has anyone successfully compiled cvstrac for Solaris?  

Here is the Makefile.  It is very simple and straightforward.  It is also possible that I am using the wrong cvstrac Makefile.

$ cat Makefile
#!/usr/bin/make
#
#### The toplevel directory of the source tree.
#
SRCDIR = /export/home/afsas/cvstrac/cvstrac-2.0.1

#### C Compiler and options for use in building executables that
#    will run on the platform that is doing the build.
#
BCC = gcc -g -O2

#### The suffix to add to executable files.  ".exe" for windows.
#    Nothing for unix.
#
E =

#### C Compile and options for use in building executables that
#    will run on the target platform.  This is usually the same
#    as BCC, unless you are cross-compiling.
#
#TCC = gcc -O6
TCC = gcc -g -O0 -Wall
#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage

#### Extra arguments for linking against SQLite
#
LIBSQLITE = -lsqlite3 -lcrypt -lm

#### Installation directory
#
INSTALLDIR = /var/www/cgi-bin


# You should not need to change anything below this line
###############################################################################
include $(SRCDIR)/main.mk
0
Comment
Question by:sbing
  • 9
  • 6
16 Comments
 
LVL 62

Expert Comment

by:gheist
ID: 19651822
What is your PATH setting? GCC version?
Does it compile simple blank file?
0
 

Expert Comment

by:ScottBing
ID: 19657364
GCC version 3.4.6
$ echo $PATH
/usr/bin:/usr/sbin:/etc:/usr/ccs/bin:/usr/ucb:/usr/openwin/bin:/usr/local/bin:/u01/app/ant/bin:.
$
Does it compile simple blank file? - Yep...
$ more simple.c
int main(void) {
  return 0;
}
$ g++ simple.c
$
0
 

Expert Comment

by:ScottBing
ID: 19657940
also all of the .o files were successfully generated by the Makefile
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 62

Accepted Solution

by:
gheist earned 1000 total points
ID: 19660370
There is problem with "ld" utility which links *.o files into executable.
It can be part of solaris system, or GNU binutils.
Compiler is fine - no need to fix it.


Try putting /usr/local/bin in path before /usr/bin and redo the build.
0
 

Expert Comment

by:ScottBing
ID: 19662631
Thanks - Your'e absolutely right...
in addition to moving /usr/local/bin to front of my path, I need to get a copy of the gnu ld program.  When I did a 'which ld', I got some very old copy of the ld program - probably not the gnu version.  I found the gnu version of ld along with micellaneous other gnu utiities on sunfreeeware in the binutils pkg.  I will download do a pkgadd and try it.
0
 

Expert Comment

by:ScottBing
ID: 19666278
got the same error when using the gnu ld utility
had /usr/local/bin at beginning of $PATH and made sure I was using correct ld by issuing a 'which ld'
0
 

Expert Comment

by:ScottBing
ID: 19666311
Are there some additional lib(s) I should place into my LD_LIBRARY_PATH variable?

0
 
LVL 62

Expert Comment

by:gheist
ID: 19679615
run
ldd /usr/local/lib/gcc/sparc-sun-solaris2.9/3.4.6/../../../libsqlite3.so

It may show some more to add for sqlite.
0
 

Expert Comment

by:ScottBing
ID: 19688036
did the following:

-bash-3.00$ ldd /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../libsqlite3.so
        libc.so.1 =>     /usr/lib/libc.so.1
        libgcc_s.so.1 =>         /usr/local/lib/libgcc_s.so.1
        libm.so.2 =>     /usr/lib/libm.so.2
        /platform/SUNW,Sun-Fire-280R/lib/libc_psr.so.1
-bash-3.00$ LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/platform/SUNW,Sun-Fire-280R
-bash-3.00$ export LD_LIBRARY_PATH
-bash-3.00$ echo $LD_LIBRARY_PATH
/usr/local/lib:/usr/lib:/platform/SUNW,Sun-Fire-280R/lib

make

and got the same thing..

I even coded SQLLITELIB  -L/usr/local/lib:/usr/lib:/platform/SUNW,Sun-Fire-280R/lib in Makefile and it still gave me the same linkage error
0
 
LVL 62

Expert Comment

by:gheist
ID: 19692032
You have to add -lc to LIBSQLITE setting.
0
 

Expert Comment

by:ScottBing
ID: 19703228
Getting closer&

1.  I issued a find command and discovered that this particular system did not have the Bind package installed on it.  I downloaded Bind 9.3.1 and installed it.

2.  I added -lbind -lsocket lnsl to the LIBSQLITE specification in the makefile

That just leaves me with one undefined symbol left (fdatasync).  Heres the latest output from my make command:

gcc -g -O -I/usr/local/include -o cvstrac attach.o  browse.o  cgi.o  common.o  cvs.o  db.o  format.o  git.o  history.o  index.o  login.o  main.o  md5.o  rss.o  search.o  setup.o  svn.o  test.o  throttle.o  ticket.o  timeline.o  tools.o  user.o  view.o  wiki.o  wikiinit.o -L/usr/local/lib -lsqlite3 -lcrypt -lm -lbind -lsocket -lnsl
Undefined                       first referenced
 symbol                             in file
fdatasync                           /usr/local/lib/libsqlite3.so
ld: fatal: Symbol referencing errors. No output written to cvstrac
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `cvstrac'
0
 

Expert Comment

by:ScottBing
ID: 19703371
SUCCESS!!!
after I added -lrt -ldl to the LIBSQLITE specification in the makefile, cvstrac compled successfully.

here's the final LIBSQLITE specification:
LIBSQLITE = -L/usr/local/lib -lsqlite3 -lcrypt -lm -lbind -lsocket -lnsl -lrt -ldl

Now when I execute it, I am getting the following error:
root@db5 # ./cvstrac start
Starting cvstrac (bug tracker)...ld.so.1: cvstrac: fatal: libsqlite3.so.0: open failed: No such file or directory
17693 Killed

I'm probably missing some sort of library in my $PATH
0
 

Expert Comment

by:ScottBing
ID: 19708437
Thanks - everything is working now

The LD_LIBRARY_PATH enviornment variable was set incorrectly.

Once I fixed it, everything executed successfully
0
 
LVL 62

Expert Comment

by:gheist
ID: 19715085
LD_LIBRARY_PATH contains runtime directories where linker seeks libraries
-lxxx linker parameter tells linker to write required library name into final executable

You can use ldd command to examine executables for missing libraries.
0
 

Expert Comment

by:EE_AutoDeleter
ID: 41592303
I've requested that this question be deleted for the following reason:

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Not enough information to confirm an answer.

If you feel this question should be closed differently, post an objection and a moderator will read all objections and then close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Auto Deleter
0
 
LVL 62

Expert Comment

by:gheist
ID: 41592304
Author confirms ID: 19660370
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question