I am trying to make a get request in vala following this: https://wiki.gnome.org/Vala/LibSoupSample. I do exactly what it says and the compiler throws this:
Connection.vala.c:(.text+0x76): undefined reference to `soup_session_new'
collect2: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
And this is the result from pkg-config --libs --cflags libsoup-2.4
-pthread -I/usr/include/libsoup-2.4 -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lsoup-2.4 -lgio-2.0 -lgobject-2.0 -lglib-2.0
I have vala 0.20.1. runing on elementaryos (the newest stable version). Any ideas?
I had the same issue earlier today. It seems like the example is out of date. It's no longer called soup_session_new, the reference is now soup_session_sync_new. Use new Soup.SessionSync () and it should work.
Here's a working example:
using Soup;
int main (string[] args) {
string url = "http://google.com";
stdout.printf ("Getting data from %s\n", url);
var session = new Soup.SessionSync ();
var message = new Soup.Message ("GET", url);
session.send_message (message);
stdout.write (message.response_body.data);
return 0;
}
Related
It is possible to get linker script, used during GCC (Binutils ld linker) compilation process:
$ gcc -o main funcs.c main.c -Wl,--verbose
...
SECTIONS
{
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0)); . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS;
.interp : { *(.interp) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
...
}
However, there is no such an information if to use CLANG with LLD:
$ clang -fuse-ld=lld -o main funcs.c main.c -Wl,--verbose
ld.lld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crt1.o
...
ld.lld: /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a
ld.lld: /usr/lib/gcc/x86_64-linux-gnu/9/crtend.o
ld.lld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/crtn.o
I'm just curious how to get required information for the CLANG/LLD.
I come to you with questions about Quectel's BG96 drivers installation on Ubuntu. I tried on 14.4, 16.04, 18.04, 20.04 but none of these see the BG96 that I plugged into PCi on my PC. I followed the instruction on https://www.quectel.com/UploadImage/Downlad/Quectel_WCDMA<E_Linux_USB_Driver_User_Guide_V1.8.pdf but to no avail. Everything stops when I want to issue
sudo make -C /lib/modules/`uname -r`/build M=`pwd`/drivers/usb/serial obj-m=option.o modules
After I issue that command these errors show up
make: Entering directory '/usr/src/linux-headers-4.15.0-45-generic'
scripts/Makefile.build:45: /lib/modules/4.15.0-45-generic/drivers/usb/serial/Makefile: No such file or directory
make[1]: *** No rule to make target '/lib/modules/4.15.0-45-generic/drivers/usb/serial/Makefile'. Stop.
Makefile:1551: recipe for target '_module_/lib/modules/4.15.0-45-generic/drivers/usb/serial' failed
make: *** [_module_/lib/modules/4.15.0-45-generic/drivers/usb/serial] Error 2
make: Leaving directory '/usr/src/linux-headers-4.15.0-45-generic'
And these are the files that I placed into my /lib/modules/4.15.0-45-generic/drivers/usb/serial/
option.c
static const struct usb_device_id option_ids[]={
#if 1
{ USB_DEVICE(0x2C7C, 0x0296) },
#endif
}
static struct usb_serial_driver option_1port_device = {
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,
#if 1
.reset_resume = usb_wwan_resume,
#endif
#endif
};
usb_wwan.c
static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint, int dir, void *ctx, char *buf, int len, void (*callback) (struct urb*)){
usb_fill_bulk_urb(urb, serial->dev, usb_sndbulkpipe(serial->dev, endpoint) | dir, but, len, callback, ctx);
#if 1
if(dir == USB_DIR_OUT){
struct usb_device_descriptor *desc = &serial->dev->descriptor;
if(desc->idVendor == cpu_to_le16(0x2C7C)){
urb->transfer_flags |= URB_ZERO_PACKET;
}
}
#endif
return urb;
}
You'll find your solution here : https://github.com/bacnh85/Quectel_Linux_USB_Driver
It works for me on Ubuntu 20.04 with kernel 5.4.
there is just some updates, probably because the developper change it's github URL.
git clone https://github.com/bacnh85/Quectel_Linux_USB_Driver.git
cd Quectel_Linux_USB_Driver
make
sudo make install
Are vala enums not integer based? This example generates a "c" compile error. Not a big deal, but would like to understand why.
const int INT_UNINITIALIZED = 999;
public enum ScopeTypes {
/*OSS:Fix:GLib requires a default value, set GLOBALS = 0
(VSCodeDbgSvr.exe:31979): GLib-GObject-CRITICAL **: g_param_spec_enum: assertion 'g_enum_get_value (enum_class, default_value) != NULL' failed*/
NONE = INT_UNINITIALIZED,
GLOBALS = 0,
ARGUMENTS,
LOCALS,
EXCEPTIONS,
TOT_SCOPE_TYPES;
//Vala enums may have methods:
public bool is_global() {
return (this == GLOBALS || this == EXCEPTIONS);
}
public bool is_function() {
return (this == ARGUMENTS || this == LOCALS);
}
public bool is_valid() {
return (this != NONE);
}
}
The compile output:
> Executing task: /opt/vala/bin/valac helloworld.vala class1.vala --pkg libvala-0.40 -X -I/opt/vala/include/vala-0.40 -X -O0 --vapidir=/opt/vala/share/vala/vapi --debug --save-temps -o helloworld.exe <
/media/george/SharedData/Projects/Vala/Examples/playground-2/helloworld.c:82:21: error: ‘INT_UNINITIALIZED’ undeclared here (not in a function)
SCOPE_TYPES_NONE = INT_UNINITIALIZED,
^~~~~~~~~~~~~~~~~
error: cc exited with status 256
Compilation failed: 1 error(s), 1 warning(s)
The terminal process terminated with exit code: 1
The relevant part of the error message is:
error: ‘INT_UNINITIALIZED’ undeclared here (not in a function)
The C compiler is complaining that it can not find the declaration of your constant. So it is not a type problem at all.
It is a scope / ordering problem.
If you compile the code with valac -C you get a .c file that looks something like this:
typedef enum {
SCOPE_TYPES_NONE = INT_UNINITIALIZED,
SCOPE_TYPES_GLOBALS = 0,
SCOPE_TYPES_ARGUMENTS,
SCOPE_TYPES_LOCALS,
SCOPE_TYPES_EXCEPTIONS,
SCOPE_TYPES_TOT_SCOPE_TYPES
} ScopeTypes;
#define INT_UNINITIALIZED 999
Note how the Vala compiler has reordered the code to declare the enum first and the constant later.
Since in C the order of declarations in a file is important this can not compile.
I would consider this to be a compiler bug and you may want to report this to the GNOME bugtracker (product Vala).
I have the following code, for which address sanitizer only catches the violation when LTO is off. Changing between -Os and -O0 doesn't affect it. Any ideas why?
char *__attribute((noinline)) SCObfuscatedMalloc();
void SCCauseAddressSanitizerViolation() {
char *chars = SCObfuscatedMalloc();
if (rand() & 1) {
chars[2] = 3;
} else {
chars[2] = 2;
}
printf("yo: %zd\n", (NSInteger)chars[2]);
}
char *__attribute((noinline)) SCObfuscatedMalloc() {
return malloc(1);
}
I recently ran into this problem, not on clang bug GCC though. I looked at the objdump with and without -flto: it appears LTO removed all calls to the instrumented checker functions.
I guess what LTO did is: it looked at the inserted check code and found that these code can never be reachable, because they are checking UBs, which LTO assumes can never happen. So LTO just removed them.
But O3 was good.
I have a project where I want to unzip files.
I have found Quazip to be close to the implementation I want(check), but....
when build the project the compiler says
Makefile.Release:241: warning: overriding commands for target
release/moc_quazipfile.o' Makefile.Release:219: warning: ignoring
old commands for targetrelease/moc_quazipfile.o'
release\moc_quazipfile.cpp:40: warning: 'static void
QuaZipFile::qt_static_metacall(QObject*, QMetaObject::Call, int,
void**)' redeclared without dllimport attribute: previous dllimport
ignored release\moc_quazipfile.cpp:48: warning:
'QuaZipFile::staticMetaObjectExtraData' redeclared without dllimport
attribute after being referenced with dll linkage
release\moc_quazipfile.cpp:52: warning:
'QuaZipFile::staticMetaObject' redeclared without dllimport attribute
after being referenced with dll linkage
release\moc_quazipfile.cpp:61: warning: 'virtual const QMetaObject*
QuaZipFile::metaObject() const' redeclared without dllimport
attribute: previous dllimport ignored release\moc_quazipfile.cpp:66:
warning: 'virtual void* QuaZipFile::qt_metacast(const char*)'
redeclared without dllimport attribute: previous dllimport ignored
release\moc_quazipfile.cpp:74: warning: 'virtual int
QuaZipFile::qt_metacall(QMetaObject::Call, int, void*)' redeclared
without dllimport attribute: previous dllimport ignored
mingw32-make.exe[1]: Leaving directory `*
**quazip_test-build-desktop-Qt_4_8_0_for_Desktop_-MinGW_Qt_SDK__Release'
release\moc_quazipfile.cpp:48: error: definition of static data
member 'QuaZipFile::staticMetaObjectExtraData' of dllimport'd class
mingw32-make.exe[1]: * [release/moc_quazipfile.o] Error 1
mingw32-make.exe: * [release] Error 2 13:29:01: The process
"C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2. Error while
building project quazip_test (target: Desktop) When executing build
step 'Make'
.pro:
QT += core gui
TARGET = quazip_test
TEMPLATE = app
INCLUDEPATH += C:/QtSDK/QtSources/4.8.0/src/3rdparty/zlib
SOURCES += main.cpp\
mainwindow.cpp \
quazip/quazipnewinfo.cpp \
quazip/quazipfile.cpp \
quazip/quazip.cpp \
quazip/quacrc32.cpp \
quazip/qioapi.cpp \
quazip/moc_quazipfile.cpp \
quazip/JlCompress.cpp \
quazip/quaadler32.cpp
HEADERS += mainwindow.h \
quazip/crypt.h \
quazip/unzip.h \
quazip/quaadler32.h \
quazip/quazipnewinfo.h \
quazip/quazipfileinfo.h \
quazip/quazipfile.h \
quazip/quazip_global.h \
quazip/quazip.h \
quazip/quacrc32.h \
quazip/quachecksum32.h \
quazip/JlCompress.h \
quazip/ioapi.h \
quazip/zip.h
FORMS += mainwindow.ui
mainwindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "quazip/quazip.h"
#include "quazip/quazipfile.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
mainwindow.cpp:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QuaZip *temp = new QuaZip();
}
MainWindow::~MainWindow()
{
delete ui;
}
What am I doing wrong??
BR