create main binary

This commit is contained in:
mrbesen 2023-01-08 17:23:25 +01:00
parent e5803f3b17
commit 38984339fc
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
3 changed files with 38 additions and 0 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ build/
Makefile
.qmake.stash
.vscode/settings.json
qtdebugger

View File

@ -36,3 +36,18 @@ HEADERS += \
FORMS += \
ui/debugwindow.ui
# main binary target
qtdebugger.depends = src/main.c
qtdebugger.commands = $$QMAKE_CC src/main.c -o qtdebugger
qtdebugger.path = /usr/local/bin/
qtdebugger.files = qtdebugger
QMAKE_EXTRA_TARGETS += qtdebugger
PRE_TARGETDEPS += qtdebugger
# install targets
target.path = /usr/local/lib/
INSTALLS += \
qtdebugger \
target

22
src/main.c Normal file
View File

@ -0,0 +1,22 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char** argv) {
if( argc < 2 ) {
fprintf(stderr, "missing arguments\n");
return 1;
}
setenv("LD_PRELOAD", "/usr/local/lib/libqtdebugger.so", 1);
// should never return
execv(argv[1], argv+1);
fprintf(stderr, "exec failed: %s\n", strerror(errno));
return 2;
}