delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/06/14/14:01:05

X-Spam-Check-By: sourceware.org
Message-ID: <f89350620606141100o798515b4w45358227f0902ba8@mail.gmail.com>
Date: Wed, 14 Jun 2006 23:30:46 +0530
From: "Ganesh Ramakrishnan" <ganramkr AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Code using archive file that compiles with g++ on linux but gives linking problem with g++ on cygwin
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019