我想运行一个使用libusb与USB设备通信的项目。我已经在Linux上使用它了,它在那里工作得很好,所以我想在Cygwin的Windows上运行它。我在Cygwin中安装了libusb for Windows和libusb,然后尝试编译它。事实证明,你需要pciutils,不像在Linux上,它很容易得到它。在Cygwin,这是一个问题。
在克服了一些困难之后,我设法进一步了解了在Cygwin环境中编译pciutil的目的。我完成了以下步骤:
我收到了这个错误:
gcc lspci.o ls-vpd.o ls-caps.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/libpci.a -o lspci
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x95): undefined reference to `_outpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0xd3): undefined reference to `_outpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0xf1): undefined reference to `_outpw'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x110): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x170): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x184): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x1af): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x204): undefined reference to `_outpw'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x218): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x242): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x259): undefined reference to `_outpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x2d5): undefined reference to `_outpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x30c): undefined reference to `_inpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x328): undefined reference to `_inpw'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x348): undefined reference to `_inp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x3b2): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x3c6): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x3ed): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x417): undefined reference to `_inpw'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x42f): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x447): undefined reference to `_inp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x457): undefined reference to `_inpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x65a): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x666): undefined reference to `_inpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x67c): undefined reference to `_outpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x688): undefined reference to `_inpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x69f): undefined reference to `_outpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x6c3): undefined reference to `_outpd'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x729): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x73d): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x751): undefined reference to `_outp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x75d): undefined reference to `_inp'
lib/libpci.a(i386-ports.o):i386-ports.c:(.text+0x778): undefined reference to `_inp'
collect2: error: ld returned 1 exit status
Makefile:96: recipe for target 'lspci' failed
make: *** [lspci] Error 1
我去了第96行的Makefile,但是我不知道要改变什么才能使它工作(如果你愿意,我也可以发布整个makefile):
%: %.o
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
答案 0 :(得分:2)
由于您使用的是32位版本的Windows,因此可以使用pciutils的Cygwin端口。 win32
子目录中的文件实际上是MinGW端口的文件,这就是导致链接错误的原因。
你应该做的第一件事就是将源文件解压缩到一个新目录,这样你就可以从新的开始。使用Cygwin编译它不是必需的更改和修改。请确保这次不复制win32
目录中的任何文件,不需要它们。另外,不要复制winio32
文件,也不需要它们。不要对任何文件进行任何更改。
接下来要做的是使用Cygwin的setup-x86.exe
安装 ioperm 包。在搜索框中键入ioperm
,以便在所有其他包中快速找到它。安装完成后,从Cygwin提示符运行ioperm -i
以安装允许应用程序执行直接I / O的驱动程序。
接下来将目录更改为解压缩pciutils的新副本的目录,并从Cygwin shell运行以下命令:
make HOST=i386-pc-cygwin
这应该是创建库和实用程序所需要做的全部工作。