我正在尝试使用libserial
文件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
...
makefile
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)
1条答案
按热度按时间vojdkbi01#
杂散字符通常与源编码有关。
“null character(s)ignored”诊断通常会指示源代码是UTF-16或UTF-32。
但是,makefile显示您正在将静态库视为强制包含文件:
在Windows中使用g++: