0

我在 Cygwin 中编译我的程序时遇到了麻烦。我用 setup.exe 程序安装了 MySQL 库,我得到了这个错误 g++ 编译器。

build/Debug/Cygwin-Windows/db.o:db.cpp:(.text+0x19): undefined reference to `_mysql_init'
build/Debug/Cygwin-Windows/db.o:db.cpp:(.text+0x5b): undefined reference to `_mysql_real_connect'
build/Debug/Cygwin-Windows/db.o:db.cpp:(.text+0x71): undefined reference to `_mysql_error'
build/Debug/Cygwin-Windows/db.o:db.cpp:(.text+0x7b): undefined reference to `_mysql_errno'
build/Debug/Cygwin-Windows/db.o:db.cpp:(.text+0xb2): undefined reference to `_mysql_error'
build/Debug/Cygwin-Windows/db.o:db.cpp:(.text+0xbc): undefined reference to `_mysql_errno'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: build/Debug/Cygwin-Windows/db.o: bad reloc address 0x0 in section `.ctors'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: final link failed: Invalid operation

我现在应该做什么?

解决方案...为了编译这个,我改进了我的 Makefile:

g++ -O3 -g funcs.o db.o main.o -lm -o myprogram $(shell mysql_config --cflags) $(shell mysql_config --libs)

谢谢!

4

1 回答 1

0

看看这个,我浏览了一下,我认为它可以提供帮助。 http://cygwin.com/ml/cygwin/2006-01/msg00772.html

于 2012-12-28T13:06:47.003 回答