Failed to build LibcOverlayShims.h - swift

I am attempting to build a framework that I just ported some code from Objective C to Swift in, and I'm getting this error:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "LibcOverlayShims.h"
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/lib/swift/shims/LibcOverlayShims.h:80:15: error: declaration of 'sem_t' must be imported from module 'Darwin.sys.semaphore' before it is required
static inline sem_t *_stdlib_sem_open2(const char *name, int oflag) {
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/sys/semaphore.h:43:13: note: declaration here is not visible
typedef int sem_t;
^
<unknown>:0: error: could not build Objective-C module 'SwiftOverlayShims'
The error is happening because of this one file:
https://github.com/losnoco/Cog/blob/swiftingly/Audio/Visualization/VisualizationController.swift
What am I doing wrong?

Related

AOSP build: Api check failed when replacing public java files under frameworks/base/core with prebuilt .jar

I am compiling Android 8.1 AOSP, I want to remove any specified java files under frameworks/base/services and frameworks/base/core, and build the removed java files into .jar libraries, then add the library to framework to make it compile successfully. I succeeded in frameworks/base/services, but failed with API check when do it in frameworks/base/core.
What I did:
Disable JACK compile tool, modify file build/make/core/combo/javac.mk
ANDROID_COMPILE_WITH_JACK := false
Copy frameworks/base/core/java/android/app/ActivityManager.java to frameworks/base/core/mytest/core/java/ActivityManager.java
Create frameworks/base/core/mytest/Android.mk:
include $(CLEAR_VARS)
LOCAL_MODULE := frameworks.base.core.mytest
LOCAL_SRC_FILES += \
$(call all-java-files-under,core/java)
# depends on it to make compilition success
LOCAL_JAVA_LIBRARIES := services
include $(BUILD_STATIC_JAVA_LIBRARY)
Run command: mmm frameworks/base/core/mytest
Then it will generat a .jar file: out/target/product/mydevice/obj/JAVA_LIBRARIES/frameworks.base.core.mytest_intermediates/javalib.jar, copy it into prebuilt/mylibs/
Create prebuilt/mylibs/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# my lib is named as 'myam'
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += myam:javalib.jar
include $(BUILD_MULTI_PREBUILT)
Modify frameworks/base/Android.mk, in framework module, add line:
LOCAL_MODULE := framework
# add my lib to framework.jar
LOCAL_STATIC_JAVA_LIBRARIES += myam
REMOVE the original file: rm frameworks/base/core/java/android/app/ActivityManager.java
Run make command to build the AOSP project, I got the error log:
javadoc: error - In doclet class com.google.doclava.Doclava, method start has thrown an exception java.lang.reflect.InvocationTargetException
java.lang.IllegalArgumentException: Unable to find ActivityManager.java. This is usually because doclava has been asked to generate stubs for a file that isn't present in the list of input source files but exists in the input classpath.
at com.google.doclava.Stubs.parseLicenseHeader(Stubs.java:656)
at com.google.doclava.Stubs.writeClassFile(Stubs.java:635)
Where throws the exception is in external/doclava/src/com/google/doclava/Stubs.java:
private static String parseLicenseHeader(/* #Nonnull */ SourcePositionInfo positionInfo) {
//...
File sourceFile = new File(positionInfo.file);
if (!sourceFile.exists()) {
throw new IllegalArgumentException("Unable to find " + sourceFile +
". This is usually because doclava has been asked to generate stubs for a file " +
"that isn't present in the list of input source files but exists in the input " +
"classpath.");
}
Since the source file has been removed, so I specified the source file path to a Stub file that generated by a previous successful built:
out/target/common/obj/JAVA_LIBRARIES/android_system_stubs_current_intermediates/src/android/app/ActivityManager.java, copy it to /data1/myAOSProot/generated/stubs/ActivityManager.java,
private static String parseLicenseHeader(/* #Nonnull */ SourcePositionInfo positionInfo) {
//...
File sourceFile = new File(positionInfo.file);
if (!sourceFile.exists()) {
// As it can't find the source file, I specified it as below:
if (positionInfo.file.equals("ActivityManager.java") || positionInfo.file.endsWith("/ActivityManager.java")) {
sourceFile = new File("/data1/myAOSProot/generated/stubs/ActivityManager.java");
} else {
throw new IllegalArgumentException("Unable to find " + sourceFile +
". This is usually because doclava has been asked to generate stubs for a file " +
"that isn't present in the list of input source files but exists in the input " +
"classpath.");
}
}
But I got a new error:
ActivityManager.java:0: warning: Method android.app.ActivityManager.TaskSnapshot.getSnapshot returns unavailable type GraphicBuffer m.position? ActivityManager.java [110]
ActivityManager.java:0: warning: Method android.app.ActivityManager.getGrantedUriPermissions returns unavailable type ParceledListSlice m.position? ActivityManager.java [110]
ActivityManager.java:0: warning: Method android.app.ActivityManager.getService returns unavailable type IActivityManager m.position? ActivityManager.java [110]
ActivityManager.java:0: warning: Parameter of unavailable type android.content.pm.IPackageDataObserver in android.app.ActivityManager.clearApplicationUserData() [110]
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/core/java/android/app/IActivityManager.java:10691: warning: Parameter of hidden type android.app.ContentProviderHolder in android.app.IActivityManager.publishContentProviders() [110]
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/core/java/android/app/IApplicationThread.java:2321: warning: Parameter of hidden type android.app.ResultInfo in android.app.IApplicationThread.scheduleSendResult() [110]
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/core/java/android/app/IApplicationThread.java:2322: warning: Parameter of hidden type android.app.ResultInfo in android.app.IApplicationThread.scheduleLaunchActivity() [110]
out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/core/java/android/app/IApplicationThread.java:2341: warning: Parameter of hidden type android.app.ResultInfo in android.app.IApplicationThread.scheduleRelaunchActivity() [110]
This is because of the #hide or #removed comments in GraphicBuffer.java etc., I try ignoring the errors by comment the codes reporting error in external/doclava/src/com/google/doclava/Errors.java:
public static void error(Error error, SourcePositionInfo where, String text) {
// all commented
}
But still, another error:
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/content/pm/ParceledListSlice.java:19: error: cannot find symbol
extends android.content.pm.BaseParceledListSlice<T>
^
symbol: class BaseParceledListSlice
location: package android.content.pm
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/app/IApplicationThread.java:13: error: cannot find symbol
public abstract void scheduleSendResult(android.os.IBinder token, java.util.List<android.app.ResultInfo> results) throws android.os.RemoteException;
^
symbol: class ResultInfo
location: package android.app
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/app/IApplicationThread.java:14: error: cannot find symbol
public abstract void scheduleLaunchActivity(android.content.Intent intent, android.os.IBinder token, int ident, android.content.pm.ActivityInfo info, android.content.res.Configuration curConfig, android.content.res.Configuration overrideConfig, android.content.res.CompatibilityInfo compatInfo, java.lang.String referrer, com.android.internal.app.IVoiceInteractor voiceInteractor, int procState, android.os.Bundle state, android.os.PersistableBundle persistentState, java.util.List<android.app.ResultInfo> pendingResults, java.util.List<com.android.internal.content.ReferrerIntent> pendingNewIntents, boolean notResumed, boolean isForward, android.app.ProfilerInfo profilerInfo) throws android.os.RemoteException;
^
symbol: class ResultInfo
location: package android.app
out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/app/IApplicationThread.java:33: error: cannot find symbol
public abstract void scheduleRelaunchActivity(android.os.IBinder token, java.util.List<android.app.ResultInfo> pendingResults, java.util.List<com.android.internal.content.ReferrerIntent> pendingNewIntents, int configChanges, boolean notResumed, android.content.res.Configuration config, android.content.res.Configuration overrideConfig, boolean preserveWindow) throws android.os.RemoteException;
^
symbol: class ResultInfo
location: package android.app
The files reporting error like out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/src/android/content/pm/ParceledListSlice.java actually is NOT existed in a NORMAL AOSP compiling, and the file it refers like BaseParceledListSlice.java is just under the same directory as ParceledListSlice.java, I am confused why would this error happen.
Did I miss anything or is there a different way to achieve my goal? I just want to replace java files to .jar libraries.
Anyone could help me out? Thanks a lot!

Error not a valid device model name in Qemu

I am trying to add a custom device in Qemu source code.
Below are the steps which I followed to add a device in Qemu source code:
Go to directory where qemu is installed
Then
created a custom device file in hw/misc/.c
created a entry in qemu/hw/misc/Makefile.objs
created a entry in qemu/config-all-devices.mak
created a entry in qemu/arm-softmmu/config-devices.mak
created a entry in qemu/arm-softmmu/config-devices.mak.old
After I run below two commands
sudo make CFLAGS="-Wno-error"
sudo make install
Then I run qemu with my custom device
Below is the script to run qemu
#!/bin/bash
KERNEL="/lhome/priyamvad/debian_qemu_arm32/vmlinuz-3.16.0-6-armmp-lpae"
INIT_IMAGE="/lhome/priyamvad/debian_qemu_arm32/initrd.img-3.16.0-6-armmp-lpae"
DISK="/lhome/priyamvad/debian_qemu_arm32/hda30.qcow2"
/lhome/priyamvad/arm_qemu_Setup/qemu/arm-softmmu/qemu-system-arm \
-M virt \
-m 1024 \
-smp 4 \
-kernel $KERNEL \
-object rng-random,filename=/dev/urandom,id=rng0 \
-device virtio-rng-device,rng=rng0 \
-initrd $INIT_IMAGE \
-append 'root=/dev/vda2' \
-drive if=none,file=$DISK,format=qcow2,id=hd \
**-device hello-world-device** \
-device virtio-blk-device,drive=hd \
-device virtio-net-device,netdev=usernet \
-netdev user,id=usernet,hostfwd=tcp::2222-:22 \
-nographic
When I run above script, I get following error:
ERROR:
qemu-system-arm: -device hello-world-device: 'hello-world-device' is
not a valid device model name
So what i am missing in above steps?
You're trying to edit some files which are autogenerated by the configure and make process, so when you run make your changes will be overwritten again: config-devices.mak, config-devices.mak.old and config-all-devices.mak are all autogenerated.
The place you want to put your new CONFIG_HELLO_DEVICE=y is in default-configs/arm-softmmu.mak. Then hw/misc/Makefile.objs can use it in a line like "common-obj-$(CONFIG_HELLO_DEVICE) += hello.o".
Check that your source file is actually getting compiled and linked into the QEMU binary when you run make. If it is, then the problem is something in your C sources; if it is not, then you haven't got your makefile/default-configs stuff right.
Some extra advice:
sudo make CFLAGS="-Wno-error" sudo make install
is a really bad way to do "compile QEMU for testing":
it's running the whole make process as root unnecessarily
it's doing an install, which you don't need to do to just run the QEMU binary you've built for testing
you're overriding the default "warnings are errors" setting, which is just hiding bugs in your code you need to fix (and if you really do need to do this for some reason, it's the wrong way to do it: there is a configure --disable-werror option)
it's doing a build in the source directory, which means that autogenerated files from the build get mixed in with the source files. This is why you got confused and tried to edit the autogenerated config-devices.mak files I think.
Upstream QEMU strongly recommends doing a build in a separate build directory (I give some plausible configure options but use what you want):
mkdir build
(cd build && ../configure --target-list=arm-softmmu --enable-debug)
make -j8 -C build
(You will need to do a 'distclean' on your current source tree to get rid of the results of the build-in-source-tree or just throw it away and start again to get to a clean state that you can then do an out-of-tree build from.)
Once you've done 'make' you can simply run the built qemu binary directly as ./build/arm-softmmu/qemu-system-arm.
I have tried the method you suggested for adding custom device to Qemu(arm-32bit) source code but it give following errors:
Added entry for my device in following file hw/misc/Makefile.objs and default-configs/arm-softmmu.mak
Run make by giving below commands
make distclean
make -j8 -C build
I am attaching below image to show output containing error
qemu-system-arm build error
After checking the output shown by above image, I created a file "config-devices.mak" in build/arm-softmmu.
I once again run commands described in step 2.
I get following output and error show below.
ERROR
ar: creating libfdt/libfdt.a
ar: creating /lhome/priyamvad/debian_qemu_arm32_updated/qemu/build/capstone/libcapstone.a
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:19:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/hw.h:8:20: error: expected \u2018=\u2019, \u2018,\u2019, \u2018;\u2019, \u2018asm\u2019 or \u2018__attribute__\u2019 before \u2018hw_error\u2019
void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
^~~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:7,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:19,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/hwaddr.h:11:9: error: unknown type name \u2018uint64_t\u2019
typedef uint64_t hwaddr;
^~~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:19,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:15:28: error: unknown type name \u2018CPUState\u2019
void tcg_flush_softmmu_tlb(CPUState *cs);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:37:9: error: unknown type name \u2018uintptr_t\u2019
typedef uintptr_t ram_addr_t;
^~~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:46:60: error: unknown type name \u2018uint32_t\u2019
typedef void CPUWriteMemoryFunc(void *opaque, hwaddr addr, uint32_t value);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:47:9: error: unknown type name \u2018uint32_t\u2019
typedef uint32_t CPUReadMemoryFunc(void *opaque, hwaddr addr);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:52:1: error: unknown type name \u2018RAMBlock\u2019
RAMBlock *qemu_ram_block_by_name(const char *name);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:53:1: error: unknown type name \u2018RAMBlock\u2019
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:53:47: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset,
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:55:39: error: unknown type name \u2018RAMBlock\u2019
ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:56:25: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:56:60: error: unknown type name \u2018DeviceState\u2019
void qemu_ram_set_idstr(RAMBlock *block, const char *name, DeviceState *dev);
^~~~~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:57:27: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_unset_idstr(RAMBlock *block);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:58:32: error: unknown type name \u2018RAMBlock\u2019
const char *qemu_ram_get_idstr(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:59:30: error: unknown type name \u2018RAMBlock\u2019
void *qemu_ram_get_host_addr(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:60:32: error: unknown type name \u2018RAMBlock\u2019
ram_addr_t qemu_ram_get_offset(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:61:37: error: unknown type name \u2018RAMBlock\u2019
ram_addr_t qemu_ram_get_used_length(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:62:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool qemu_ram_is_shared(RAMBlock *rb);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:62:25: error: unknown type name \u2018RAMBlock\u2019
bool qemu_ram_is_shared(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:63:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:63:30: error: unknown type name \u2018RAMBlock\u2019
bool qemu_ram_is_uf_zeroable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:64:31: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_set_uf_zeroable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:65:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool qemu_ram_is_migratable(RAMBlock *rb);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:65:29: error: unknown type name \u2018RAMBlock\u2019
bool qemu_ram_is_migratable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:66:30: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_set_migratable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:67:32: error: unknown type name \u2018RAMBlock\u2019
void qemu_ram_unset_migratable(RAMBlock *rb);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:1: error: unknown type name \u2018size_t\u2019
size_t qemu_ram_pagesize(RAMBlock *block);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:1: note: \u2018size_t\u2019 is defined in header \u2018\u2019; did you forget to \u2018#include \u2019?
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:8:1:
+#include
#endif
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:1:
size_t qemu_ram_pagesize(RAMBlock *block);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:69:26: error: unknown type name \u2018RAMBlock\u2019
size_t qemu_ram_pagesize(RAMBlock *block);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:70:1: error: unknown type name \u2018size_t\u2019
size_t qemu_ram_pagesize_largest(void);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:70:1: note: \u2018size_t\u2019 is defined in header \u2018\u2019; did you forget to \u2018#include \u2019?
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:72:42: error: unknown type name \u2018uint8_t\u2019
void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
^~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h: In function \u2018cpu_physical_memory_read\u2019:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:77:5: error: implicit declaration of function \u2018cpu_physical_memory_rw\u2019; did you mean \u2018cpu_physical_memory_read\u2019? [-Werror=implicit-function-declaration]
cpu_physical_memory_rw(addr, buf, len, 0);
^~~~~~~~~~~~~~~~~~~~~~
cpu_physical_memory_read
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:77:5: error: nested extern declaration of \u2018cpu_physical_memory_rw\u2019 [-Werror=nested-externs]
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h: At top level:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:89:30: error: unknown type name \u2018QEMUBH\u2019; did you mean \u2018QEMU_HW_H\u2019?
void cpu_register_map_client(QEMUBH *bh);
^~~~~~
QEMU_HW_H
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:90:32: error: unknown type name \u2018QEMUBH\u2019; did you mean \u2018QEMU_HW_H\u2019?
void cpu_unregister_map_client(QEMUBH *bh);
^~~~~~
QEMU_HW_H
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:92:1: error: unknown type name \u2018bool\u2019; did you mean \u2018_Bool\u2019?
bool cpu_physical_memory_is_io(hwaddr phys_addr);
^~~~
_Bool
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:103:32: error: unknown type name \u2018RAMBlock\u2019
typedef int (RAMBlockIterFunc)(RAMBlock *rb, void *opaque);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:105:28: error: unknown type name \u2018RAMBlockIterFunc\u2019
int qemu_ram_foreach_block(RAMBlockIterFunc func, void *opaque);
^~~~~~~~~~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:29: error: unknown type name \u2018RAMBlock\u2019
int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:43: error: unknown type name \u2018uint64_t\u2019
int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:59: error: unknown type name \u2018size_t\u2019
int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length);
^~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/cpu-common.h:106:59: note: \u2018size_t\u2019 is defined in header \u2018\u2019; did you forget to \u2018#include \u2019?
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:21,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memattrs.h:69:9: error: unknown type name \u2018uint32_t\u2019
typedef uint32_t MemTxResult;
^~~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/host-utils.h:29,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memop.h:15,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:22,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:87:9: error: unknown type name \u2018uint8_t\u2019
typedef uint8_t flag;
^~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:93:9: error: unknown type name \u2018uint16_t\u2019
typedef uint16_t float16;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:94:9: error: unknown type name \u2018uint32_t\u2019
typedef uint32_t float32;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:95:9: error: unknown type name \u2018uint64_t\u2019
typedef uint64_t float64;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:106:5: error: unknown type name \u2018uint64_t\u2019
uint64_t low;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:107:5: error: unknown type name \u2018uint16_t\u2019
uint16_t high;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:115:5: error: unknown type name \u2018uint64_t\u2019
uint64_t low, high;
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/fpu/softfloat-types.h:169:5: error: unknown type name \u2018uint8_t\u2019
uint8_t float_exception_flags;
^~~~~~~
In file included from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/host-utils.h:29,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memop.h:15,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/exec/memory.h:22,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/hw/pci/pci.h:4,
from /lhome/priyamvad/debian_qemu_arm32_updated/qemu/hw/misc/testpci.c:20:
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:29:15: error: unknown type name \u2018uint16_t\u2019
static inline uint16_t bswap16(uint16_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:29:32: error: unknown type name \u2018uint16_t\u2019
static inline uint16_t bswap16(uint16_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:35:15: error: unknown type name \u2018uint32_t\u2019
static inline uint32_t bswap32(uint32_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:35:32: error: unknown type name \u2018uint32_t\u2019
static inline uint32_t bswap32(uint32_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:43:15: error: unknown type name \u2018uint64_t\u2019
static inline uint64_t bswap64(uint64_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:43:32: error: unknown type name \u2018uint64_t\u2019
static inline uint64_t bswap64(uint64_t x)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:56:29: error: unknown type name \u2018uint16_t\u2019
static inline void bswap16s(uint16_t *s)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:61:29: error: unknown type name \u2018uint32_t\u2019
static inline void bswap32s(uint32_t *s)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:66:29: error: unknown type name \u2018uint64_t\u2019
static inline void bswap64s(uint64_t *s)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:142:15: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type endian ## size ## _to_cpu(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:142:46: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type endian ## size ## _to_cpu(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:147:15: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type cpu_to_ ## endian ## size(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:147:46: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline type cpu_to_ ## endian ## size(type v)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:152:47: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline void endian ## size ## _to_cpus(type *p)\
^~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:162:21: error: unknown type name \u2018uint16_t\u2019
CPU_CONVERT(be, 16, uint16_t)
^~~~~~~~
/lhome/priyamvad/debian_qemu_arm32_updated/qemu/include/qemu/bswap.h:157:51: note: in definition of macro \u2018CPU_CONVERT\u2019
static inline void cpu_to_ ## endian ## size ## s(type *p)\
Are the above errors due to bugs in qemu source code or I am doing something nasty?
Some description about my work
Creating a custom device in Qemu.
Creating a device driver to test custom device.
I have created custom device and now I want to run my custom device on Qemu
Qemu is imitating ARM(32 bit) hardware and running debian on it.
Is it necessary to create device driver for custom device or it can be tested by a user application ?
Code of files used
custom device source file
custom device
Makefile.objs source file
Makefile.objs
config-device.mak souce file
config-device.mak

C++ dylib in Swift project - undefined symbols for function exposed in dylib

C++ dylib exposes as follows
__attribute__((visibility("default"))) int addNumber(int number) {
return 0;
}
in my Swift project, I set the Import Paths dir to the dir containing my module.map file:
module MyLib {
header "myLib.h"
export *
}
I manually add myLib.h to my project:
#ifndef mylib_h
#define mylib_h
int addNumber(int number);
#endif
My main.swift does the following:
import Foundation
import MyLib
print("Hello, World!")
var result = addNumber(3)
When I compile the swift project, I can see that it links against my dylib (-lMyLib), but I get the following error:
Undefined symbols for architecture x86_64: "_addNumber", referenced
from:
_main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see
invocation)
So although it's linking correctly, it can't find the symbols.
I've verified both with nm (0000000000000d00 (__TEXT,__text) external addNumber) and Hopper that this function does exist in the dylib.
In the C++ library, your function must be marked with extern "C"
for C linkage:
extern "C" __attribute__((visibility("default"))) int addNumber(int number) {
return 0;
}
so that the compiler does not mangle the exported name. Swift can only
call C functions, not C++ functions.
See also What is the effect of extern "C" in C++?.

Updateing code to swift 4 results in an error message

I wan to update this code to swift 4:
rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
return rc;
}
But I get two errors:
Declaration of 'select' must be imported from module 'Darwin.POSIX.sys.time' before it is required
Implicit declaration of function 'select' is invalid in C99
How can I can fix this?
Add this near the top of your file:
#include <sys/time.h>

Eclipse undefined reference

I'm using Eclipse and MinGW. I've got undefined reference to error to all that I write in h files, that I do include in cpp-file where main located. I create an empty project, and the same thing again (
main.cpp
#include <iostream>
#include "Stack.h"
using namespace std;
int main(){
Stack<int> stack(10);
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
stack.h
#ifndef STACK_H_
#define STACK_H_
template <class T>
class Stack{
private:
struct StackEl;
StackEl *top;
public:
Stack();
Stack(T el);
~Stack();
void Push(const T& el);
T Pop();
};
#endif /* STACK_H_ */
and stack.cpp inplements everything from stack.h
If I include not h-file, but cpp - all works. Help please!
I've got following errors
D:/Workspacee/Stack2/Debug/../src/Stack2.cpp:16: undefined reference to `Stack<int>::Stack(int)'
D:/Workspacee/Stack2/Debug/../src/Stack2.cpp:18: undefined reference to `Stack<int>::~Stack()'
D:/Workspacee/Stack2/Debug/../src/Stack2.cpp:18: undefined reference to `Stack<int>::~Stack()'
This is a linker error. I'm no Eclipse expert, but you have to tell it somehow to add Stack.o to the linking command.
If you include Stack.cpp instead of Stack.h, the implementations from the cpp-file get included into main.cpp by the preprocessor before compilation, so the linking stage has no unresolved references to outside functions.
My bad, that is becouse templates! When you use template, all code, including realization of functions, must be in header-file, or you have to write prototypes for every type you are going to use you template-functions with. I've forgot about that working with templates is not the same as with usual function :(