0

NetBeans cygwin g++ コンパイラを使用してプロジェクト ( rar ファイル) をビルドしようとしていました。ubuntumakesrc/ディレクトリで実行することでビルドできました。しかし、cygwin では、それは私に与え続けましたundefined reference to...

(コンパイルする前に、私はsrc/MakefileCC = g++に変更しCC = g++-3ました。)

エラーはundefined reference to BufMgr::pinPage(int, Page*&, int, char const*)、 wherepinPage()include/にあると述べました。

これがプロジェクトの構造です。

project/
    include/
        buf.h (where pinPage() was defined)
        other header files
    src/
        Makefile
        other source files

以下は元の Makefile とエラーです。

メイクファイル:

#
# Makefile for CS564 Minibase project.  Needs GNU make.
#
# Define DEBUGREL for some kind of debugging output (not from us, from
# the original Minibase implementors.)
#
# Warning: make depend overwrites this file.

.PHONY: depend clean backup setup

MAIN = btree

MINIBASE = ..

CC = g++

#CFLAGS = -DUNIX -Wall -g
CFLAGS = -g

INCLUDES = -I${MINIBASE}/include -I.

LFLAGS = -L. -lbtree -lm

SRCS = main.C btree_driver.C btfile.C btindex_page.C btleaf_page.C btree_file_scan.C key.C db.C new_error.C sorted_page.C system_defs.C

OBJS = $(SRCS:.C=.o)

$(MAIN):  $(OBJS)
    $(CC) $(CFLAGS) $(INCLUDES) $(OBJS) -o $(MAIN) $(LFLAGS)

.C.o:
    $(CC) $(CFLAGS) $(INCLUDES) -c $<

depend: $(SRCS)
    makedepend $(INCLUDES) $^

clean:
    rm -f *.o *~ $(MAIN)
    rm -f my_output

backup:
    -mkdir bak
    cp Makefile *.[Ch] bak

run:
    rm -rf my_output
    ./btree > my_output

# Grab the sources for a user who has only the makefile
setup:
    /bin/cp -i $(MINIBASE)/src/*.[Ch] .
    /bin/cp -i $(MINIBASE)/src/*.sample .

# DO NOT DELETE THIS LINE -- make depend needs it 

エラー:

$ make
g++-3 -g -I../include -I. -c main.C
g++-3 -g -I../include -I. -c btree_driver.C
g++-3 -g -I../include -I. -c btfile.C
g++-3 -g -I../include -I. -c btindex_page.C
g++-3 -g -I../include -I. -c btleaf_page.C
g++-3 -g -I../include -I. -c btree_file_scan.C
g++-3 -g -I../include -I. -c key.C
g++-3 -g -I../include -I. -c db.C
g++-3 -g -I../include -I. -c new_error.C
g++-3 -g -I../include -I. -c sorted_page.C
g++-3 -g -I../include -I. -c system_defs.C
g++-3 -g -I../include -I. main.o btree_driver.o btfile.o btindex_page.o btleaf_page.o btree_file_scan.o key.o db.o new_error.o sorted_page.o system_defs.o -o btree -L. -lbtree -lm
btfile.o: In function `_ZN9BTreeFileC2ER6StatusPKc':
/cygdrive/c/Users/Trantor/Documents/NetBeansProjects/DB-HW6/src/btfile.C:78: undefined reference to `BufMgr::pinPage(int, Page*&, int, char const*)'
btfile.o: In function `_ZN9BTreeFileC1ER6StatusPKc':
/cygdrive/c/Users/Trantor/Documents/NetBeansProjects/DB-HW6/src/btfile.C:78: undefined reference to `BufMgr::pinPage(int, Page*&, int, char const*)'
btfile.o: In function `_ZN9BTreeFileC2ER6StatusPKc8AttrTypeii':

.....
4

1 に答える 1

0

ファイル拡張子が.C. 大文字と小文字を区別するファイル システム (Unix) では、大文字の.C拡張子は C++ コードを意味し、小文字.cはプレーンな古い C コードを意味します。そのため、コンパイラはそれを C コードとしてコンパイルしようとする可能性があり、異なる関数名が生成されます。

これが理由である場合、可能な修正:

  • CFLAGS に正しいコンパイル スイッチを追加して、gcc に C++ のコンパイルを強制します ( -x c++、クイック グーグルは言います)。
  • ファイルの名前を に変更し.cpp、Makefile の拡張子も修正します
于 2012-12-18T08:10:02.620 に答える