我正在尝试使用 SQLite3 编译一个小 C 程序。我已经包含头文件并将 .dll 文件转换为 .lib 文件。
有趣的是,在 windows 上,gcc (CodeBlocks) 可以毫无问题地编译源代码。但是在 Debian (Raspberry Pi) 下,我收到此错误消息:/usr/bin/ld: cannot find -lsqlite3.lib
sqlite3.lib 文件与我要编译的 main.c 文件位于同一文件夹中。(我也尝试将 .lib 文件复制到 /usr/bin/ - 没有成功)
如果我尝试在我的树莓上运行 Windows 编译的程序,我会收到另一条错误消息......
这是我的源代码:
#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"
static int callback(void *NotUsed, int argc, char **argv, char **azColName);
int main(void){
sqlite3 *db=NULL;
int erg = 0;
char *errMsg = NULL;
erg = sqlite3_open("temp_values.db", &db);
if (erg == 1){
fprintf(stderr, "Fehler beim Oeffnen der DB!\n");
sqlite3_close(db);
return EXIT_FAILURE; …Run Code Online (Sandbox Code Playgroud) 我写了一个小的bash脚本来每3秒启动一个程序.此脚本在启动时执行,并将其PID保存到pidfile中:
#!/bin/bash
echo $$ > /var/run/start_gps-read.pid
while [ true ] ; do
if [ "$1" == "stop" ] ;
then
echo "Stopping GPS read script ..."
sudo pkill -F /var/run/start_gps-read.pid
exit
fi
sudo /home/dh/gps_read.exe /dev/ttyACM0 /home/dh/gps_files/gpsMaus_1.xml
sleep 3
done
Run Code Online (Sandbox Code Playgroud)
问题是,我无法通过调用终止shell脚本start_gps-read.sh stop.它应该读取pidfile并停止初始化过程(从启动).
但是当我打电话时stop,脚本仍会运行:
dh@Raspi_DataHarvest:~$ sudo /etc/init.d/start_gps-read.sh stop
Stopping GPS read script ...
dh@Raspi_DataHarvest:~$ ps aux | grep start
root 488 0.0 0.3 5080 2892 ? Ss 13:30 0:00 /bin/bash /etc/init.d/start_gps-read.sh start
dh 1125 0.0 0.2 4296 2016 …Run Code Online (Sandbox Code Playgroud) 我想fprintf通过将目标文件重定向到来禁止某些调用/dev/null.但我能确定,fopen("/dev/null", "w");永远不会回来NULL.换句话说,是否每次都可以打开这个"文件"?
如果是这样,我可以使用这个漂亮的三元运算符:
FILE *whereToPrint = (strcmp(custom_topic, ERROR_TOPIC) == 0) ? fopen("/dev/null", "w") : stdout;
fprintf(whereToPrint, "Message sent!\n\n");
Run Code Online (Sandbox Code Playgroud)