vxworks compile success but "ld" command fail - compilation

I use IDE WindRiver Workbench to compile DKM project! It compiles successfully. But "ld" command fails complaining like:
Warning: module 0x1e2f0b8 holds reference to undefined symbol __GOTT_BASE__.
Warning: module 0x1e2f0b8 holds reference to undefined symbol __GOTT_INDEX__.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Assert.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Stoul.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Getpctype.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Stderr.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Getptoupper.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Getptolower.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Stod.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Flt.
Warning: module 0x1e2f0b8 holds reference to undefined symbol _Stdout.
ld(): error loading file (errno = 0xe0005).

You get these errors because the mentioned symbols cannot be resolved in the system symbol table.
From the VxWorks Kernel Programmer's Guide 6.8, ch. 16.3.7 (very useful chapter for loading issues)
The system symbol table is used to store the names and addresses of functions and variables already installed in the system. This has the side effect that once symbols are installed in the
system symbol table, they are available for future linking by any module that is
loaded. Moreover, when attempting to resolve undefined symbols in a module,
the loader uses all global symbols compiled into the target image, as well as all
global symbols of previously loaded modules.
Tips:
Check that the order in which you are loading modules is correct. Loading will fail on that DKM if you are loading the symbols afterwards in another DKM.
[...] dependencies between modules must be taken into account when
modules are loaded to ensure that references can be resolved for each new module,
using either code compiled into the VxWorks image or modules that have already
been loaded into the system.
Failure to do so results in incompletely resolved code [...]
"lkup" command is useful to find what symbols have been previously loaded

Related

glib build failure after adding Y2038 glibc patches

I am facing one issue with IMX7 Yocto build failure, we have added the Y2038 issue fix patches
in glibc, after this when we build using bitbake we are getting build error in other module, however glibc has no failure.
./.libs/g-ir-compiler:
/data/server/tmp/fsl-community-bsp/build/tmp/work/cortexa7hf-neon-jupiter-linux-gnueabi/gobject-introspection/1.48.0-r0/build/.libs/libgirepository-1.0.so.1:
no version information available (required by
/data/server/tmp/fsl-community-bsp/build/tmp/sysroots/imx7dsabresd-jupiter//usr/lib/libgio-2.0.so.0) ./.libs/g-ir-compiler:
/data/server/tmp/fsl-community-bsp/build/tmp/work/cortexa7hf-neon-jupiter-linux-gnueabi/gobject-introspection/1.48.0-r0/build/.libs/libgirepository-1.0.so.1:
no version information available (required by
/data/server/tmp/fsl-community-bsp/build/tmp/sysroots/imx7dsabresd-jupiter//usr/lib/libgio-2.0.so.0) ./.libs/g-ir-compiler: symbol lookup error:
/data/server/tmp/fsl-community-bsp/build/tmp/sysroots/imx7dsabresd-jupiter//usr/lib/libglib-2.0.so.0:
undefined symbol: pcre_free ./.libs/g-ir-compiler: symbol lookup
error:
/data/server/tmp/fsl-community-bsp/build/tmp/sysroots/imx7dsabresd-jupiter//usr/lib/libglib-2.0.so.0:
undefined symbol: pcre_free ./.libs/g-ir-compiler: symbol lookup
error:
/data/server/tmp/fsl-community-bsp/build/tmp/sysroots/imx7dsabresd-jupiter//usr/lib/libglib-2.0.so.0:
undefined symbol: pcre_free ./.libs/g-ir-compiler: symbol lookup
error:
/data/server/tmp/fsl-community-bsp/build/tmp/sysroots/imx7dsabresd-jupiter//usr/lib/libglib-2.0.so.0:
undefined symbol: pcre_free If the above error message is about
missing .so libraries, then setting up GIR_EXTRA_LIBS_PATH in the
recipe should help. (typically like this:
GIR_EXTRA_LIBS_PATH="${B}/something/.libs" ) make[2]: ***
[gir/libxml2-2.0.typelib] Error 1
Any help will be highly appreciated.
I think backporting these two patches to core might be helpful
glib-2.0
libpcre

Google Analytics issue on Xamarin.ios

I am building xamarin.forms project and integrated google analytics for ios and droid.
Currently I used Google Analytics for iOS framework by installed nuget for xamarin.ios. By the way, when I build ios, native library linking failed exception happens.
How can I fix this issue?
Here is exception lists.
Error Native linking failed, undefined symbol: __monodroid_lref_log_delete. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_lref_log_delete. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_max_gref_get. This symbol was referenced by the managed member Java.Interop.Runtime._monodroid_max_gref_get. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_weak_gref_new. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_weak_gref_new. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_gref_get. This symbol was referenced by the managed member Android.Runtime.AndroidObjectReferenceManager._monodroid_gref_get. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_getifaddrs. This symbol was referenced by the managed member Android.Runtime.AndroidEnvironment._monodroid_getifaddrs. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_gref_log_new. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_gref_log_new. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: _monodroid_typemap_managed_to_java. This symbol was referenced by the managed member Android.Runtime.JNIEnv.monodroid_typemap_managed_to_java. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_gc_wait_for_bridge_processing. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_gc_wait_for_bridge_processing. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_freeifaddrs. This symbol was referenced by the managed member Android.Runtime.AndroidEnvironment._monodroid_freeifaddrs. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_lref_log_delete. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_lref_log_delete. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed. Please review the build log.
Error Native linking failed, undefined symbol: __monodroid_detect_cpu_and_architecture. This symbol was referenced by the managed member Android.Runtime.AndroidEnvironment._monodroid_detect_cpu_and_architecture. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_gref_log_delete. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_gref_log_delete. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: _monodroid_typemap_java_to_managed. This symbol was referenced by the managed member Java.Interop.TypeManager.monodroid_typemap_java_to_managed. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_timezone_get_default_id. This symbol was referenced by the managed member Android.Runtime.AndroidEnvironment._monodroid_timezone_get_default_id. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_lref_log_new. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_lref_log_new. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_weak_gref_delete. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_weak_gref_delete. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_get_identity_hash_code. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_get_identity_hash_code. Please verify that all the necessary frameworks have been referenced and native libraries linked.
Error Native linking failed, undefined symbol: __monodroid_gref_log. This symbol was referenced by the managed member Android.Runtime.JNIEnv._monodroid_gref_log. Please verify that all the necessary frameworks have been referenced and native libraries linked.
I had the same weird error. My fix was to remove the Mono.Android reference from PCL and then clean and rebuild fixed all the above errors.
In my case Mono.Android reference was actually a required reference but, to get rid of these errors, I commented out the code in PCL that was using Mono.Android . After a successful build ( without Mono.Android ), I reverted the code in PCL and added Mono.Android reference back to PCL . Surprisingly a clean and rebuild with Mono.Android as a reference in PCL worked this time ! I have no clue how .

Undefined reference to '_Unwind_GetIP'

I'm having a bit of trouble getting a rustc compiled staticlib for triple, arm-linux-androideabi, to link up nicely within Android Studio.
Steps taken...
Install Rust via multirust
Build a rustc for Android API v14
Build lib with --target=arm-linux-androideabi
Add to jniLibs/ within Android Studio
Create a little C++ shim for hooks to/from JNI
Build and link (almost)
When building my crate, I get the following output:
note: link against the following native artifacts when linking
against this static library
note: the order and any duplication can be significant on some platforms,
and so may need to be preserved
note: library: c
note: library: m
note: library: dl
note: library: log
note: library: gcc
note: library: c
note: library: m
So naturally, my Android.mk includes these libs when using the staticlib.
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hydrogen
LOCAL_SRC_FILES := ../jniLibs/$(TARGET_ARCH_ABI)/libhydrogen.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := hydrogen-android
LOCAL_SRC_FILES := shim.cpp
LOCAL_STATIC_LIBRARIES := hydrogen
LOCAL_LDLIBS := -lc -lm -ldl -llog -lgcc -lc -lm
include $(BUILD_SHARED_LIBRARY)
Building in Android Studio gives me the following output:
:app:buildCppShim
Android NDK: WARNING:/Android.mk:hydrogen: non-system libraries in linker flags: -lgcc -lgccunwind
Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
Android NDK: current module
[armeabi] Compile++ thumb: hydrogen-android <= shim.cpp
[armeabi] SharedLibrary : libhydrogen-android.so
[snipped]function sync::rwlock::StaticRwLock::read::ha5ec9717ccd1ed83Lxp: error: undefined reference to 'pthread_rwlock_rdlock'
[snipped]function sys_common::rwlock::RWLock::read::h7f3d472c79e2e1e2Z1q: error: undefined reference to 'pthread_rwlock_rdlock'
[snipped]function sys_common::rwlock::RWLock::read_unlock::hd7d67e9c5c47b9f5B2q: error: undefined reference to 'pthread_rwlock_unlock'
[snipped]function sync::rwlock::StaticRwLock::try_read::hddd396186cced62f8xp: error: undefined reference to 'pthread_rwlock_tryrdlock'
[snipped]function sys_common::rwlock::RWLock::try_read::ha5aede723e91a3c881q: error: undefined reference to 'pthread_rwlock_tryrdlock'
[snipped]function sync::rwlock::StaticRwLock::write::h787666bb30e75d28Ryp: error: undefined reference to 'pthread_rwlock_wrlock'
[snipped]function sys_common::rwlock::RWLock::write::h0273da9a7ade68c0i2q: error: undefined reference to 'pthread_rwlock_wrlock'
[snipped]function sync..rwlock..RwLockWriteGuard$LT$$LP$$RP$$GT$::drop.34348::h4c8fbe45843b9a01: error: undefined reference to 'pthread_rwlock_unlock'
[snipped]function sync::rwlock::StaticRwLock::try_write::h5d30a7fdd53c86b4ezp: error: undefined reference to 'pthread_rwlock_trywrlock'
[snipped]function sys_common::rwlock::RWLock::try_write::h0ec4bcc0cb460718r2q: error: undefined reference to 'pthread_rwlock_trywrlock'
[snipped]function sync::rwlock::StaticRwLock::destroy::ha1e9f51e62905aedXzp: error: undefined reference to 'pthread_rwlock_destroy'
[snipped]function sys_common::rwlock::RWLock::destroy::h602ce773ff2356e6T2q: error: undefined reference to 'pthread_rwlock_destroy'
[snipped]function sys::rwlock::RWLock::read::h241f5fdff06a76ab00u: error: undefined reference to 'pthread_rwlock_rdlock'
[snipped]function sys::rwlock::RWLock::write::h48034b52e6491ea4h3u: error: undefined reference to 'pthread_rwlock_wrlock'
~/bin/rust/src/compiler-rt/lib/builtins/gcc_personality_v0.c
Error:(206) undefined reference to '_Unwind_GetIP'
Error:(273) undefined reference to '_Unwind_SetGR'
Error:(274) undefined reference to '_Unwind_SetGR'
Error:(275) undefined reference to '_Unwind_SetIP'
pthread errors
I'm not sure why I received the errors about pthread, because I have #include <pthread.h> in my shim, and these functions are defined in Android's pthread.
unwind errors
For this, I've tried including unwind.h in the shim and libgccunwind.a in the Android.mk, but still throws the same errors. I found this thread where a hack-solution was to just declare the prototypes in the shim, but when I do this, I receive the following errors about unwind.h
Error:(231, 3) error: previous declaration 'void _Unwind_SetGR(_Unwind_Context*, int, _Unwind_Word)' here
So, it is able to find their declarations when I declare them, because they conflict, but has no idea where they are if I do not? I'm assuming it has to be something wrong with my linking order, but unsure of how to solve it, because the required libs are linked against after pulling in the rust created lib.
Any help would be greatly appreciated!
Edit 1
Adjusted makefile to link during Shared Library creation.
LOCAL_LDLIBS is meaningless for a static library (static libraries don't get linked). You need to add those libraries whenever you use that library in a real binary (like a shared library or executable).
The solution happened to be building unwind and including some portability headers. See module example here

Can't compile and link library

I try to use a library compiled with gcc called matlisp based on fortran code. After specifyng the f77 compiler, I could performed the autoreconf, configure and make command to obtain the file libmatlisp.so.
But when I try to use it i get a:
Error opening shared object ".../libmatlisp.so":
/usr/lib/libf2c.so.2: undefined symbol: MAIN__.
And when i perform the command ld libmatlisp.so i get:
...
libmatlisp.so: undefined reference to `idamax_'
libmatlisp.so: undefined reference to `dger_'
/usr/lib/libf2c.so.2: undefined reference to `MAIN__'
libmatlisp.so: undefined reference to `zscal_'
libmatlisp.so: undefined reference to `dscal_'
....
Is there a way to improve the situation?
I already try this solution but it does not work.
I also try to change the compiler to gfortran but i get some some run time error messages mentionning missing libraries that are part of libf2c.
Ok. I move to a more recent source of matlisp 2012 instead of 2003, and it run properly in my environment now.

Ignoring an undefined symbol in a dynamic library from Xcode

I have a symbol that is being referenced in an Xcode dynamic library target, but it is not defined there. I NEED this symbol to be undefined. This is because it will be compiled differently in each process that includes it (based upon some compile time defines).
The dynamic library target in Xcode that fails to link because it contains a reference to this symbol (which is not unexpected), but I know that the symbol will be available at run time. I will be compiling this function into each target that the common library is linked to.
I am trying to get the linker to mark this particular symbol for dynamic lookup at run time.
I have been able to get it to link if I specify "-undefined dynamic_lookup" as one of the "Other Linker Flags" in my Xcode project. The problem is that I don't want to go that far. I know that only 1 symbol is supposed to be undefined. I want all the rest of the symbols to generate errors if they are left as undefined (I want to avoid a run time missing symbol error basically).
I found a ld linker option that seems like it should do what I need (from ld man page):
-U symbol_name
Specified that it is ok for symbol_name to have no definition. With -two_levelnamespace, the resulting symbol will be marked dynamic_lookup which means dyld will search all loaded images.
However, I cannot seem to get it to work. Whenever I specify "-U symbolName" or "-UsymbolName" in the "Other Linker Flags" I am still greeted with this linker error:
Undefined symbols for architecture x86_64:
"_symbolName", referenced from: <various object files>
Am I using -U incorrectly perhaps? Is it not really the option I need, or is it just not working like it is supposed too?
Set -Wl,-undefined,dynamic_lookup to OTHER_LDFLAGS.
Link: Xcode clang link: Build Dynamic Framework (or dylib) not embed dependencies
Setting -Wl,-undefined,dynamic_lookup is dangerous, since it disables all undefined warning.
Use -Wl,-U,symbol_namein OTHER_LDFLAGS to disable warnings for a single symbol.
In Xcode:
Go to Project/Select Target
Click Build Settings
Search Other Linker Flags
Enter options

Resources