我在 Ubuntu/Oneiric 上最简单的程序时遇到问题:
#include <glibmm/ustring.h>
int main()
{
Glib::ustring s = "Test string";
}
使用 Makefile
PACKAGES=glibmm-2.4 glib-2.0 gtkmm-3.0 gtk+-3.0
CC=g++
CFLAGS=`pkg-config --cflags $(PACKAGES)` --std=c++0x
LD=g++
LDFLAGS=`pkg-config --libs $(PACKAGES)`
build: ./main
run: build
./main
clean:
rm ./main.o
rebuild: clean build
./main: ./main.o
$(LD) $(LDFLAGS) ./main.o -o ./main
./main.o: ./main.cc
$(CC) $(CFLAGS) ./main.cc -c -o ./main.o
在 make 出现以下错误:
./main.o: In function `main':
main.cc:(.text+0x15): undefined reference to `Glib::ustring::ustring(char const*)'
main.cc:(.text+0x21): undefined reference to `Glib::ustring::~ustring()'
collect2: ld returned 1 exit status
make: *** [main] Error 1
在 Ubuntu/Maverick 上,完全相同的代码可以很好地链接到完全相同的文件...如果在 main.o 上使用 ld 它也可以成功链接,但是(正如预期的那样)_start 丢失了...
有什么建议么?