linking QuaZip with Qt 4.8.0 into project - quazip

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

Related

Thingsboard provisioning example not working

For some reason https://github.com/thingsboard/thingsboard-arduino-sdk/blob/master/examples/0008-esp8266_provision_device/0008-esp8266_provision_device.ino is not compiling on Windows Arduino IDE 1.8.19 for FireBeetle ESP32. Error as follows:
Arduino: 1.8.19 (Windows 10), Board: "FireBeetle ESP32-E, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None"
C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:7: warning: "WIFI_AP" redefined
#define WIFI_AP "Lemmiku IoT"
In file included from C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi\src/WiFi.h:31,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:4:
C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi\src/WiFiType.h:32: note: this is the location of the previous definition
#define WIFI_AP WIFI_MODE_AP
Provision_test:86:46: error: conversion from 'void(Provision_Data&)' {aka 'void(const ArduinoJson6194_F1::ObjectConstRef&)'} to non-scalar type 'const Provision_Callback' requested
const Provision_Callback provisionCallback = processProvisionResponse;
^~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayIterator.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayRef.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:24,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
from C:\Users\Timo\Documents\Arduino\libraries\ThingsBoard\src/ThingsBoard.h:16,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:2:
C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp: In instantiation of 'typename ArduinoJson6194_F1::enable_if<((! ArduinoJson6194_F1::is_same<T, char*>::value) && (! ArduinoJson6194_F1::is_same<T, char>::value)), T>::type ArduinoJson6194_F1::VariantConstRef::as() const [with T = ArduinoJson6194_F1::ObjectRef; typename ArduinoJson6194_F1::enable_if<((! ArduinoJson6194_F1::is_same<T, char*>::value) && (! ArduinoJson6194_F1::is_same<T, char>::value)), T>::type = ArduinoJson6194_F1::ObjectRef]':
C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:75:76: required from here
C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:253:34: error: invalid use of incomplete type 'class ArduinoJson6194_F1::InvalidConversion<ArduinoJson6194_F1::VariantConstRef, ArduinoJson6194_F1::ObjectRef>'
return Converter::fromJson(*this);
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
In file included from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:14,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayIterator.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayRef.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:24,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
from C:\Users\Timo\Documents\Arduino\libraries\ThingsBoard\src/ThingsBoard.h:16,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:2:
C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/Converter.hpp:14:7: note: declaration of 'class ArduinoJson6194_F1::InvalidConversion<ArduinoJson6194_F1::VariantConstRef, ArduinoJson6194_F1::ObjectRef>'
class InvalidConversion; // Error here? See https://arduinojson.org/v6/invalid-conversion/
^~~~~~~~~~~~~~~~~
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi
Not used: C:\Users\Timo\Documents\Arduino\libraries\WiFiEspAT
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
conversion from 'void(Provision_Data&)' {aka 'void(const ArduinoJson6194_F1::ObjectConstRef&)'} to non-scalar type 'const Provision_Callback' requested
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Can anyone help out why it's not working?
#devaskim I tried, but nothing:
C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:6: warning: "WIFI_AP" redefined
#define WIFI_AP "Lemmiku IoT"
In file included from C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi\src/WiFi.h:31,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:3:
C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi\src/WiFiType.h:32: note: this is the location of the previous definition
#define WIFI_AP WIFI_MODE_AP
Provision_test:85:46: error: conversion from 'void (*)(Provision_Data&)' {aka 'void (*)(const ArduinoJson6194_F1::ObjectConstRef&)'} to non-scalar type 'const Provision_Callback' requested
const Provision_Callback provisionCallback = &processProvisionResponse;
^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayIterator.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayRef.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:24,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
from C:\Users\Timo\Documents\Arduino\libraries\ThingsBoard\src/ThingsBoard.h:16,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:2:
C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp: In instantiation of 'typename ArduinoJson6194_F1::enable_if<((! ArduinoJson6194_F1::is_same<T, char*>::value) && (! ArduinoJson6194_F1::is_same<T, char>::value)), T>::type ArduinoJson6194_F1::VariantConstRef::as() const [with T = ArduinoJson6194_F1::ObjectRef; typename ArduinoJson6194_F1::enable_if<((! ArduinoJson6194_F1::is_same<T, char*>::value) && (! ArduinoJson6194_F1::is_same<T, char>::value)), T>::type = ArduinoJson6194_F1::ObjectRef]':
C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:74:76: required from here
C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:253:34: error: invalid use of incomplete type 'class ArduinoJson6194_F1::InvalidConversion<ArduinoJson6194_F1::VariantConstRef, ArduinoJson6194_F1::ObjectRef>'
return Converter<T>::fromJson(*this);
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
In file included from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:14,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayIterator.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayRef.hpp:8,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:24,
from C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
from C:\Users\Timo\Documents\Arduino\libraries\ThingsBoard\src/ThingsBoard.h:16,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:2:
C:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/Converter.hpp:14:7: note: declaration of 'class ArduinoJson6194_F1::InvalidConversion<ArduinoJson6194_F1::VariantConstRef, ArduinoJson6194_F1::ObjectRef>'
class InvalidConversion; // Error here? See https://arduinojson.org/v6/invalid-conversion/
^~~~~~~~~~~~~~~~~
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
Not used: C:\Users\Timo\Documents\Arduino\libraries\WiFiEspAT
exit status 1
conversion from 'void (*)(Provision_Data&)' {aka 'void (*)(const ArduinoJson6194_F1::ObjectConstRef&)'} to non-scalar type 'const Provision_Callback' requested
Hmm, I got something different this time:
C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:6: warning: "WIFI_AP" redefined
#define WIFI_AP "Lemmiku IoT"
In file included from C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi\src/WiFi.h:31,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:3:
C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi\src/WiFiType.h:32: note: this is the location of the previous definition
#define WIFI_AP WIFI_MODE_AP
In file included from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayIterator.hpp:8,
from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayRef.hpp:8,
from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:24,
from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
from c:\Users\Timo\Documents\Arduino\libraries\ThingsBoard\src/ThingsBoard.h:16,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:2:
c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp: In instantiation of 'typename ArduinoJson6194_F1::enable_if<((! ArduinoJson6194_F1::is_same<T, char*>::value) && (! ArduinoJson6194_F1::is_same<T, char>::value)), T>::type ArduinoJson6194_F1::VariantConstRef::as() const [with T = ArduinoJson6194_F1::ObjectRef; typename ArduinoJson6194_F1::enable_if<((! ArduinoJson6194_F1::is_same<T, char*>::value) && (! ArduinoJson6194_F1::is_same<T, char>::value)), T>::type = ArduinoJson6194_F1::ObjectRef]':
C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:74:76: required from here
c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:253:34: error: invalid use of incomplete type 'class ArduinoJson6194_F1::InvalidConversion<ArduinoJson6194_F1::VariantConstRef, ArduinoJson6194_F1::ObjectRef>'
return Converter<T>::fromJson(*this);
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
In file included from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:14,
from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayIterator.hpp:8,
from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Array/ArrayRef.hpp:8,
from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:24,
from c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,
from c:\Users\Timo\Documents\Arduino\libraries\ThingsBoard\src/ThingsBoard.h:16,
from C:\Users\Timo\Documents\Arduino\Provision_test\Provision_test.ino:2:
c:\Users\Timo\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/Converter.hpp:14:7: note: declaration of 'class ArduinoJson6194_F1::InvalidConversion<ArduinoJson6194_F1::VariantConstRef, ArduinoJson6194_F1::ObjectRef>'
class InvalidConversion; // Error here? See https://arduinojson.org/v6/invalid-conversion/
^~~~~~~~~~~~~~~~~
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Timo\AppData\Local\Arduino15\packages\DFRobot\hardware\esp32\0.2.1\libraries\WiFi
Not used: C:\Users\Timo\Documents\Arduino\libraries\WiFiEspAT
exit status 1
Compilation error: exit status 1
As you've already noticed, there are two issues to fix, which I've highlighted in the code sample below.
There is also an open issue about this here: https://github.com/thingsboard/thingsboard-arduino-sdk/issues/89
Note that while this fixes the compilation issues, at least my self-hosted ThingsBoard server fails to register the provisioning request, so there's likely more that's broken with it.
// ...
// FIX #1
//
// We're dealing with const data
//
//JsonObject credentials_value = data["credentialsValue"].as<JsonObject>();
JsonObjectConst credentials_value = data["credentialsValue"].as<JsonObjectConst>();
// ...
// FIX #2
//
// Provision_Callback is a class that takes the callback as a constructor parameter
//
//const Provision_Callback provisionCallback = processProvisionResponse;
const Provision_Callback provisionCallback(processProvisionResponse);
// ...

How to get linker script, used during Clang compilation process?

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.

Quectel BG96 drivers on ubuntu

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&LTE_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

Enum initializer as const

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).

undefined reference to `soup_session_new'

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;
}

Resources