Code using archive file that compiles with g++ on linux but gives linking problem with g++ on cygwin

Ganesh Ramakrishnan ganramkr@gmail.com
Wed Jun 14 18:10:00 GMT 2006


Hi

I have an archive libminipar.a. I have a C++ program pdemo.cpp that
makes use it. I am pasting the contents of the makefile at the end of
this email. When I compile the program on  linux, I get no errors.
However, when I compile it on cygwin using g++ version 3.4.4, I get
the following linking error (note that the relative paths of the lib
and include directories which I use are same on the linux and windows
machines):

*************************************************************************************************
$ make
g++ -o pdemo pdemo.o -I../include  -L../lib -lminipar -lz -lm
pdemo.o:pdemo.cpp:(.text+0x118c): undefined reference to `initialize_minipar(cha
r const*)'
pdemo.o:pdemo.cpp:(.text+0x11a3): undefined reference to `extract_features(char
const*)'
pdemo.o:pdemo.cpp:(.text+0x11bb): undefined reference to `ParseTree::ParseTree()
'
pdemo.o:pdemo.cpp:(.text+0x1252): undefined reference to `interpret_command_line
(char const*)'
pdemo.o:pdemo.cpp:(.text+0x126f): undefined reference to `ParseTree::reset()'
pdemo.o:pdemo.cpp:(.text+0x1287): undefined reference to `parse(char const*, Par
seTree&)'
pdemo.o:pdemo.cpp:(.text+0x1359): undefined reference to `ParseTree::~ParseTree(
)'
pdemo.o:pdemo.cpp:(.text+0x1395): undefined reference to `ParseTree::~ParseTree(
)'
pdemo.o:pdemo.cpp:(.text$_ZN15TRSTreeIteratorIP9ParseNodeEC1EPK7TRSTreeIS1_E[TRS
TreeIterator<ParseNode*>::TRSTreeIterator(TRSTree<ParseNode*> const*)]+0x14): un
defined reference to `SlistIterator::SlistIterator(Slist const*)'
collect2: ld returned 1 exit status
make: *** [pdemo] Error 1
*************************************************************************************************

Any idea why this should happen? I tried to use the -static flag while
linking on the linux machine and tried using the binary on cygwin. But
cygwin did not recognize the binary. The contents of the makefile are
(libminipar.a is located in ../lib/):

*************************************************************************************************
.SUFFIXES: .c .cpp
CC=g++
CFLAGS=-I../include $(GO)
LIBS=-lminipar

%.o:    %.cpp
        $(CC) -c -o $@ $(CFLAGS) $<

%.o:    %.c
        cc -c -o $@ $(CFLAGS) $<

pdemo:  pdemo.o
        $(CC) -o pdemo pdemo.o $(CFLAGS) -L../lib $(LIBS) -lz -lm

depend:
        gcc -M $(CFLAGS) *.cpp >.dep

clean:
        rm -f *.o

*************************************************************************************************
-- 
Thanks and regards,
Dr. Ganesh Ramakrishnan,
IBM India Research Labs,
Block 1, IIT Delhi,
Hauz Khas, New Delhi - 16, India.
Ph: +91 11 41292193
Mobile: +91 9891313644

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



More information about the Cygwin mailing list