我是C++新手。我試圖使用libserial錯誤:在包含外部庫後程序中出現' 224'
bitmap_test.cpp
#include <SerialStream.h>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
using namespace LibSerial ;
int main()
{
SerialStream serial_port("/dev/ttyS0") ;
return 0;
}
錯誤:
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:520: error: null character(s) ignored [-Werror]
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:1: error: stray ‘\17’ in program
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:525: error: null character(s) ignored [-Werror]
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:1: error: stray ‘\231’ in program
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:529: error: null character(s) ignored [-Werror]
/usr/local/lib/libserial.a:118:532: error: null character(s) ignored [-Werror]
In file included from <command-line>:0:0:
/usr/local/lib/libserial.a:118:1: error: stray ‘\10’ in program
/usr/local/lib/libserial.a:118:1: error: stray ‘\34’ in program
...
COMPILER = -c++
OPTIONS = -ansi -pedantic-errors -Wall -Wall -Werror -Wextra -o
LINKER_OPT = -L/usr/lib -lserial -include/usr/local/lib/libserial.a -lstdc++ -lm
all: bitmap_test
bitmap_test: bitmap_test.cpp bitmap_image.hpp
$(COMPILER) $(OPTIONS) bitmap_test bitmap_test.cpp $(LINKER_OPT)
我做研究和了解它是一個問題的生成文件編碼,但不知道如何解決它。 任何幫助,非常感謝。
編輯: 圖書館是在正確的道路:
/sbin/ldconfig -p | grep libserial
libserial.so.0 (libc6,x86-64) => /usr/local/lib/libserial.so.0
libserial.so.0 (libc6,x86-64) => /usr/lib/libserial.so.0
libserial.so (libc6,x86-64) => /usr/local/lib/libserial.so
libserial.so (libc6,x86-64) => /usr/lib/libserial.so
但是,如果我改變Makefile文件的建議,我都會有這樣的問題:
c++ -ansi -pedantic-errors -Wall -Wall -Werror -Wextra -o bitmap_test bitmap_test.cpp -L/usr/local/lib -lstdc++ -lm -lserial
bitmap_test.cpp: In function ‘int main()’:
bitmap_test.cpp:32:40: error: call of overloaded ‘SerialStream(const char [11])’ is ambiguous
SerialStream serial_port("/dev/ttyS0") ;
^
bitmap_test.cpp:32:40: note: candidates are:
In file included from bitmap_test.cpp:19:0:
/usr/local/include/SerialStream.h:98:13: note: LibSerial::SerialStream::SerialStream(std::string, LibSerial::SerialStreamBuf::BaudRateEnum, LibSerial::SerialStreamBuf::CharSizeEnum, LibSerial::SerialStreamBuf::ParityEnum, short int, LibSerial::SerialStreamBuf::FlowControlEnum)
SerialStream(const std::string fileName,
^
/usr/local/include/SerialStream.h:84:22: note: LibSerial::SerialStream::SerialStream(std::string, std::ios_base::openmode)
explicit SerialStream(const std::string fileName,
^
make: [bitmap_test] Error 1 (ignored)
究竟應該選擇'-include/usr/local/lib/libserial.a'實際上是這樣嗎?我很確定這是罪魁禍首。 –
由eclipse生成的生成文件顯示該選項,因爲我包含來自C/C++構建/設置/工具設置/包括 –
的文件我覺得我只是將include內部make文件更改爲這個-L/usr/local/lib/libserial.la –