0
我已經通過相關鏈接庫到計算器AC文件多的問題消失了,當無法找到libary文件,我也跟着方法如下錯誤:試圖鏈接庫文件
注:我的圖書館文件位於.c文件的相同位置。
如何解決這些錯誤?
- 使用庫名與擴展
CC consoleDemo.c -L。 -lusbcan64.a
-L {文件路徑包含庫} -1- $ {庫名稱} 以下是編譯的
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lUSBCAN64.a
collect2: error: ld returned 1 exit status
- 錯誤使用沒有擴展名的庫名稱
cc consoleDemo.c -L。 -lusbcan64
以下是編譯
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible ./libUSBCAN64.a when searching for -lUSBCAN64
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible ./libUSBCAN64.a when searching for -lUSBCAN64
/tmp/ccTh3hGd.o:ConsoleDemo.c:(.text+0x2b9): undefined reference to `_kbhit'
/tmp/ccTh3hGd.o:ConsoleDemo.c:(.text+0x2b9): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_kbhit'
/tmp/ccTh3hGd.o:ConsoleDemo.c:(.text+0x2c6): undefined reference to `_getch'
/tmp/ccTh3hGd.o:ConsoleDemo.c:(.text+0x2c6): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_getch'
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanInitHardware' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanDeinitHardware' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanGetModuleTime' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanInitCanEx2' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanResetCanEx' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanReadCanMsgEx' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanWriteCanMsgEx' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): relocation truncated to fit: R_X86_64_32 against symbol `__imp_UcanGetStatusEx' defined in .idata$5 section in /usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b)
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/../../../../lib/USBCAN64.lib(USBCAN64.dll.b):(.text+0x2): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
什麼問題? –
將您的lib重命名爲libusbcan32.a,然後嘗試cc consoleDemo.c -L。 -lusbcan32 – Pras
「.a」文件的實際名稱是什麼? –