This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: I want to build a library rather than an executable
- From: "Lev Assinovsky" <LAssinovsky at algorithm dot aelita dot com>
- To: <jan at theRTDC dot com>,<gcc-help at gcc dot gnu dot org>
- Date: Wed, 20 Oct 2004 16:20:39 +0400
- Subject: RE: I want to build a library rather than an executable
First of all get rid of:
-L/usr/local/lib -lstdc++\
-L/usr/local/lib/gcc/sparc-sun-solaris2.9/3.4.1 -lgcc
from LDFLAGS. They'll be added automatically.
Secondary, you really build an executable.
If you want shared library add -shared to the command line for all:
Hope this help.
-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]On Behalf Of Jan Croker
Sent: Wednesday, October 20, 2004 2:10 PM
To: gcc-help@gcc.gnu.org
Subject: I want to build a library rather than an executable
Anyone,
I am currently porting an existing application from Solaris 2.6 to Solaris
2.9 and switching to the GNU compiler 3.4.1 as well!! (previously used the
Sun compiler)
As a first stab, I am just trying to build a library that is used by the
other applications.
I can compile OK but I keep hitting a link problem that reports:
Building the Common library
Undefined first referenced
symbol in file
main
/usr/local/lib/gcc/sparc-sun-solaris2.9/3.4.1/crt1.o
ld: fatal: Symbol referencing errors. No output written to libcommon.a
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `all'
Is there any way that I can force the linker to ignore looking for 'main' as
this is not a requirement when building a library.
The relevant lines in the makefile are:
OBJECTS = $(SRCS:.cpp=.o)
LDFLAGS = -L. \
-L/usr/local/lib -lstdc++\
-L/usr/local/lib/gcc/sparc-sun-solaris2.9/3.4.1 -lgcc\
-lnsl -lsocket -lthread -lposix4
.SUFFIXES : .cpp
.cpp.o :
@echo "Compiling '$<'"
@$(CPLUSPLUS) -c $(CCFLAGS) $(DEBUG) $(INCLUDE) $<
all : $(OBJECTS); @echo "Building the Common library"
@$(CPLUSPLUS) -o $(LIB) $(LDFLAGS) $(DEBUG) $(OBJECTS)
where CPLUSPLUS = g++
If anyone can help, I would appreciate it because I am banging my head on
the wall at the moment!!!
Jan
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004