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.
Related
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'm really stuck with the cordova in app plugin..
I get the following error when i build the iOS app:
** BUILD FAILED **
The following build commands failed:
CompileC build/roma16.build/Debug-iphonesimulator/roma16.build/Objects-normal/i386/InAppPurchase.o roma16/Plugins/cc.fovea.cord
ova.purchase/InAppPurchase.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
ERROR building one of the platforms: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/patrickhofer/Documents/Apps/roma
16/platforms/ios/cordova/build-debug.xcconfig,-project,roma16.xcodeproj,ARCHS=i386,-target,roma16,-configuration,Debug,-sdk,iphonesimul
ator,build,VALID_ARCHS=i386,CONFIGURATION_BUILD_DIR=/Users/patrickhofer/Documents/Apps/roma16/platforms/ios/build/emulator,SHARED_PRECO
MPS_DIR=/Users/patrickhofer/Documents/Apps/roma16/platforms/ios/build/sharedpch
You may not have the required environment or OS to build this project
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/patrickhofer/Documents/Apps/roma16/platforms/ios/cordova/build
-debug.xcconfig,-project,roma16.xcodeproj,ARCHS=i386,-target,roma16,-configuration,Debug,-sdk,iphonesimulator,build,VALID_ARCHS=i386,CO
NFIGURATION_BUILD_DIR=/Users/patrickhofer/Documents/Apps/roma16/platforms/ios/build/emulator,SHARED_PRECOMPS_DIR=/Users/patrickhofer/Do
cuments/Apps/roma16/platforms/ios/build/sharedpch
I also got this one before:
In file included from /Users/patrickhofer/Documents/Apps/roma16/platforms/ios/roma16/Plugins/cc.fovea.cordova.purchase/InAppPurchase.m:
9:
/Users/patrickhofer/Documents/Apps/roma16/platforms/ios/roma16/Plugins/cc.fovea.cordova.purchase/InAppPurchase.h:13:9: fatal error: 'Co
rdova/NSData+Base64.h' file not found
#import <Cordova/NSData+Base64.h>
^
1 error generated.
And i think this is strange as well:
In module 'Foundation' imported from /Users/patrickhofer/Documents/Apps/roma16/platforms/ios/roma16/Plugins/cordova-plugin-globalizatio
n/CDVGlobalization.h:20:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Fram
eworks/Foundation.framework/Headers/NSCalendar.h:69:2: note: 'NSMinuteCalendarUnit' has been explicitly marked deprecated here
NSMinuteCalendarUnit NS_CALENDAR_ENUM_DEPRECATED(10_4, 10_10, 2_0, 8_0, "Use NSCalendarUnitMinute instead") = NSCalendarUnitMin
ute,
^
Here is what i did before:
ionic plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="XXX"
and i added the logic in my app:
var app = angular.module('starter', ['ionic', 'pascalprecht.translate']);
app.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if((window.device && device.platform == "iOS") && window.storekit) {
storekit.init({
debug: true,
ready: onReady,
purchase: onPurchase,
restore: onRestore,
error: onError
});
}
var onReady = function() { }
var onPurchase = function(transactionId, productId, receipt) { }
var onRestore = function(transactionId, productId, transactionReceipt) { }
var onError = function(errorCode, errorMessage) { }
if((window.device && device.platform == "iOS") && window.storekit) {
storekit.init({
debug: true,
ready: function() {
storekit.load(["unlockall"], function (products, invalidIds) {
console.log("In-app purchases are ready to go");
});
},
purchase: function(transactionId, productId, receipt) {
if(productId === 'unlockall') {
console.log("Purchased product id 1");
}
},
restore: function(transactionId, productId, transactionReceipt) {
if(productId === 'unlockall') {
console.log("Restored product id 1 purchase")
}
},
error: function(errorCode, errorMessage) {
console.log("ERROR: " + errorMessage);
}
});
}
if (window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
});
Any help much appreciated! I'm going crazy...
I struggled with this for a long time as well. This solution worked for me:
remove your cordova-plugin-purchase plugin
reinstall, cordova plugin
add https://github.com/j3k0/cordova-plugin-purchase.git
https://github.com/j3k0/cordova-plugin-purchase/issues/403
I know what duplicate symbol linker error means, but in my case I don't know how I'm getting it. I have the following file, which defines some simple globals
// defines.h
#ifndef _DEFINES_H
#define _DEFINES_H
BOOL useTestCode = YES;
#endif
Then I import it in two *.m files, and use the global.
// someFile1.m
#import "defines.h"
- (void)foo
{
if (useTestCode) {
NSLog(#"Using test code");
}
else {
NSLog(#"NOT Using test code");
}
}
// someFile2.m
#import "defines.h"
- (void)foo
{
if (useTestCode) {
NSLog(#"Using test code");
}
else {
NSLog(#"NOT Using test code");
}
}
If I comment out one of the #import "defines.h" statement in either file, I don't get the duplicate symbol linker error, but of course the corresponding *.m file will fail to compile. Why am I getting the duplicate symbol linker error? How do I solve it in iOS 7?
Here is the linker error message. It's literally for the simple code above.
duplicate symbol _useTestCode in:
/Users/cfouts/Library/Developer/Xcode/DerivedData/DupSymbol-bnfownlxdoyqelbhxzpyaaitfshy/Build/Intermediates/DupSymbol.build/Debug-iphonesimulator/DupSymbol.build/Objects-normal/x86_64/DSsomeFile2.o
/Users/cfouts/Library/Developer/Xcode/DerivedData/DupSymbol-bnfownlxdoyqelbhxzpyaaitfshy/Build/Intermediates/DupSymbol.build/Debug-iphonesimulator/DupSymbol.build/Objects-normal/x86_64/DSsomeFile1.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
in your header you have
BOOL useTestCode = YES;
which is copied to every .m file that includes it so you have multiple useTestCode symbols
you need to change the header to contain
extern BOOL useTestCode;
and in one .m file, define the variable
BOOL useTestCode = YES;
Though Bryan C's answer is one solution, and it gave me a clue, I like this better.
// defines.h
#ifndef _DEFINES_H
#define _DEFINES_H
static BOOL useTestCode = YES;
#endif
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;
}
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