I'm trying to follow a tutorial for the Diagrams library for haskell.
I've installed Cairo and gtk2hs with macports.
But when I try to run the tutorial examples, I get the following error:
$ ghc --make diagramsTutorial.lhs
Linking diagramsTutorial ...
ld: warning: in /opt/local/lib/libgtk-x11-2.0.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /opt/local/lib/libgdk-x11-2.0.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /opt/local/lib/libatk-1.0.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /opt/local/lib/libpangocairo-1.0.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
.. etc...
I'm using OS X 10.6.8, core i5 macbook pro.
EDIT I have just found that I'm using the 32bit haskell platform, which may be part of the problem. However I can't install the 64 bit version (it has an unspecified error during install). I can't find the uninstaller. According to this page, I should find an uninstaller at /Library/Frameworks/GHC.framework/Tools/Uninstaller but there is nothing there.
It looks like the Macports libraries are 64-bit only. You can check with lipo -info /opt/local/lib/libgtk-x11-2.0.dylib If this is the case, you should reinstall them using the +universal variant, which will allow for linking both 32bit and 64bit code.
Related
Compiling/Linking COBOL code on a RHEL 8.6, which compiles fine but then when it tries to link I get an error with one of the variables:
cob2 -F//etc/cob2.cfg -v <cobolprog.cbl> -L/lib64 -ldb2 -I/include/cobol_a/ -q"size(16384K) -o cobolprog
The output is /usr/bin/ld: skipping incompatible lib64/libdb2.so when searching for -ldb2
/usr/bin/ld: cannot find -ldb2
If I remove the -ldb2 I get 'undefined reference to 'SQLGSTRT', 'SQLGALOC etc
When I try this with lib32 and -ldb2 I dont see issues?
I did try using the -q64 on the cmd line but apparently this is not supported on linux.
db2level
Informational tokens are "DB2 v11.5.0.0", "s1906101300", "DYN1906101300AMD64", and Fix Pack "0".
Product is installed at "/opt/IBM/db2/V11.5"
cob2 -V
Program cob2
Version 1.1.0
Built Mon Sep 27 10:39:30 2021
Tried 32 bit which compiles the cobol fine, but it now seems to have an issue with linking a static library I need:
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/8/../../../../lib/Scrtl.0(.text+0x1c): unresolvable R_386_GOTOFF relocation against symbol '__libc_csu_fini'
It appears that you are using IBM COBOL for Linux on x86 version 1.1.
According to IBM's documentation at this link
the ADDR compiler option specifies whether to create a 32-bit or 64-bit object file.
Additionally, as you are on version 1.1 (the currently available version as of February-2023), the documentation also has this specific relevant note:
Note: The ADDR(64) and -q64 options are not currently supported. The
compiler accepts and ignores these options and defaults to ADDR(32).
This means that your object file is 32-bit, but you are trying to link (ld) with the 64-bit Db2 libraries, and consequently ld skips the incomptabile library with the message that you see. You should Link with the 32-bit Db2 libraries instead, they are in the lib32 directory of the Db2 client, so arrange for this in your command line options.
I have been attempting to link a MACHO formatted object file on Linux, but I have failed miserably. So far, I have created the object file by running:
nasm -fmacho -o machoh.o hello.o
I have tried linking using:
clang --target=x86_64-apple-darwin machoh.o
but that failed. I have attempted using GCC, LD, and other linkers but I have still failed miserably. Are there any ideas on how I could solve my problem?
Thank you very much.
The most accessible solution would be lld, the LLVM linker.
lld does not ship with clang, but is a separate package.
sudo apt install lld
If you installed a version of clang that isn't the default (e.g. clang-12 explicitly), then you should use the same version for lld (i.e. lld-12).
Get a MacOS SDK from somewhere. This GitHub repo archives them.
If you're uncomfortable using the above, the "legitimate" way of obtaining it without a Mac would be:
Create an Apple ID
Go to https://developer.apple.com/download/all/
Download the "Command Line Tools for Xcode <version>"
Mount or extract the dmg
Extract the XAR package
For each ".pkg" folder inside, run pbzx <Payload | cpio -i
Find the Library/Developer/CommandLineTools/SDKs/MacOSX.sdk inside.
Feed both of the above to clang:
clang --target=x86_64-apple-darwin -fuse-ld=lld --sysroot=path/to/MacOSX.sdk machoh.o
I have tried linking using: clang --target=x86_64-apple-darwin machoh.o
but that failed.
Failed how? Details matter.
Anyway, there are 3 commonly used linkers on Linux: BFD-ld, Gold, and (newest) LLD.
Of these, Gold is an ELF-only linker, and will not work for Mach-O.
BFD-ld is only configured to support a few emulations (use ld --help to see which ones) in my distribution. BFD does appear to support Mach-O, so it's probably possible to build a Linux BFD-ld cross-linker with such support.
LLD should support Mach-O out of the box, but you are probably not using LLD.
So your first step should be to figure out which linker clang --target=x86_64-apple-darwin ... uses, and then make it use the one which does support Mach-O.
EDIT: I managed to built x86_64 version of libreactnativejni.so (see my answer). However it didn't resolved my problem.
To sum up what I learned here is:
You cannot test android components, which are using native libraries on Linux, because "libandroid.so" (core android lib), doesn't exists for Linux.
Original question:
My goal is to run tests on my Linux box using PowerMockito similar to RootViewTest.java.
Not sure how react-native team managed to run this test, but from my experience mocking Arguments.createArray is not possible, without loading jni library reactnativejni. Reason is that Arguments.createArray() calls WritableNativeArray which in static initializer ReactBridge.staticInit() calls SoLoader.loadLibrary("reactnativejni").
So I thought I've no other option, but compile this reactnativejni shared library for linux, using 64bit android-ndk-r10e
I managed to load this jni lib and test my code using:
ndkDir=$(pwd)/react-ndk/all/x86 \
JAVA_OPTS="-Djava.library.path=\".:$ndkDir\"" \
LD_LIBRARY_PATH="$ndkDir:$LD_LIBRARY_PATH" ./gradlew app:test
But test failed with:
libreactnativejni.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
Checked platform with objdump:
objdump -s --section .comment libreactnativejni.so
libreactnativejni.so: file format elf32-i386
My question how is possible that 64 bit ndk produced 32 bit library and how to force to produce 64 bit.
Library build script is written as gradle script:
https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/ReactAndroid/build.gradle#L199
ReactAndroid explicitly requests 32-bit targets. If you wish, you can replace this line to read
APP_ABI := all
I'm going to answer my own question (thank Alex for good APP_ABI lead). To compile x86_64 variant of reactnativejni follow this steps:
Update APP_ABI to APP_ABI := armeabi-v7a x86_64 x86 in file ReactAndroid/src/main/jni/Application.ml
The next problem is dependency jsc-android, which is not build for X86_64 target. There is alternative jsc-android-buildscripts which is also built for X86_64.
Extract folder X86_64 directly from aar and put it in ReactAndroid/build/third-party-ndk/jsc/jni/x86_64
However compilation will be failing on X86_64 with errors: lambda capture initializers only available with -std=c++1y or -std=gnu++1y
Fix that error, by replacing all occurrences of -std=c++1y with -std=c++11 in all Android.mk files.
Now you can start build with: ./gradlew buildReactNdkLib
Optionally you might need to clean build folder with ./gradlew cleanReactNdkLib
Built reactnativejni - libreactnativejni.so will be present in ReactAndroid/build/react-ndk/all/x86_64.
But unfortunately libreactnativejni.so will not work on Linux, as it has dependency on libandroid.so, which doesn't exists for Linux.
I am try to cross-compile boost 1.52.0 for a freescale ARM processor board from a PC running Linux.
Based on the (rather minimal) documentation on cross compiling boost, I have set up with a user-config.jam file that reads as follows:
using gcc : arm : /mnt/lv1/src/ROM1210/cross_compiler/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi-g++ ;
I then ran
bootstrap.sh --prefix=`realpath ../tools`
./b2 toolset=gcc-arm
The results were:
/mnt/lv1/src/ROM1210/extras/boost_1_52_0/tools/build/v2/tools/gcc.jam:107: in gcc.init from module gcc
error: toolset gcc initialization:
error: version 'arm' requested but 'g++-arm' not found and version '4.3.2' of default 'g++' does not match
error: initialized from
/mnt/lv1/src/ROM1210/extras/boost_1_52_0/tools/build/v2/build/toolset.jam:39: in toolset.using from module toolset
/mnt/lv1/src/ROM1210/extras/boost_1_52_0/tools/build/v2/build-system.jam:481: in process-explicit-toolset-requests from module build-system
/mnt/lv1/src/ROM1210/extras/boost_1_52_0/tools/build/v2/build-system.jam:562: in load from module build-system
/mnt/lv1/src/ROM1210/extras/boost_1_52_0/tools/build/v2/kernel/modules.jam:283: in import from module modules
/mnt/lv1/src/ROM1210/extras/boost_1_52_0/tools/build/v2/kernel/bootstrap.jam:142: in boost-build from module
/mnt/lv1/src/ROM1210/extras/boost_1_52_0/boost-build.jam:17: in module scope from module
Running b2 with --debug-configuration offers little extra info, other than confirming that the correct user-config.jam file is being read.
Any ideas what I'm doing wrong?
Turns out it wasn't my user-config.jam file being loaded, but one packaged with the boost distribution and with a very similar filename. Always pays to double check these things when something goes wrong!
Let me explain.
I'm using webots in combination with aldebaran SDK. My operating system is Debian Squeeze amd64. Webots (64bit) will not work with aldebaran SDK because their libraries are compiled for 32bit. I do not have the source of the libs to recompile in 64bit.
While trying to compile the default nao controller under webots, i get the following error:
g++ -o naoqi_for_webots
naoqi_for_webots.o naoproxy.o
-L"/usr/local/webots/lib" -lController -L"/home/alex/naoqi-sdk-1.10.44-linux/lib"
-lnaoqiclient /usr/bin/ld: skipping incompatible
/home/vor73x/naoqi-sdk-1.10.44-linux/lib/libnaoqiclient.so
when searching for -lnaoqiclient
/usr/bin/ld: cannot find -lnaoqiclient
doing a
file libnaqoqiclient.so
tells me:
libnaoqiclient.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
The default project in webots has a Makefile which among other things has:
additional libraries:
LIBRARIES=-L"$(AL_DIR)/lib" -lnaoqiclient
I have downloaded and installed the 32bit version of webots, which links fine with the libnaoqiclient.so but will not link with other webots libraries (libController.so) where again, ld complains about incompatible type.
Can I link using webots 64bit with the 32bit aldebaran sdk ?
Can I link using webots 32bit with the 32bit aldebaran ? (I should, but I still get errors).
How can I specify to ld (or through Makefile even better) that the library is 32bits ?
Or in the case of using webots 32bit how can I specify that I want a 32bit binary ?
I do not care if my binary is 32 or 64bit, I do not care if I use the 32 or 64bit version of webots, all I want is to be able to compile the controllers.
Well, you can't mix and match 32-bit and 64-bit code. If you compile all your code using -m32 (to make it build as 32-bit), you may be able to get your application to link if you have 32-bit versions of all your libraries available.