I have been trying to bind a lib called Scandit used for scanning barcodes from images.
So far I have been unsuccessful. The Library says it supports armv6 arm7 and i386. but I cannot get it to build.
lipo -info libscanditsdk-iphone-2.1.17.a
Architectures in the fat file: libscanditsdk-iphone-2.1.17.a are: armv6 armv7 i386
here is my build output
https://gist.github.com/4ee195063b61ae292ea3
Here is what my LinkWith file looks like
using System;
using MonoTouch.ObjCRuntime;
[assembly: LinkWith ("libmeScanditWrapper.a", LinkTarget.ArmV7 | LinkTarget.ArmV6
,ForceLoad = true, IsCxx=true
,Frameworks="CoreVideo CoreGraphics AudioToolbox AVFoundation CoreMedia QuartzCore SystemConfiguration"
,LinkerFlags="-lz -liconv -lstdc++"
)]
I am able to use the library natively on my device using the sample project they provided but I cannot get it to compile at all. using LinkTarget.ArmV6. If I remove this and just leave LinkTarget.ArmV7 then it wil compile but it won't work none of the bound functions will work even in a simple test lib i made.
Correct me if i am wrong these means my phone requires armv6?
thats why i can get sample libs to work using armv6.
if this is the case I need to know if anyone has any ideas why it won't build with armv6 support when it seems the lib supports it.
Correct me if i am wrong these means my phone requires armv6?
Newer iPhones uses armv7 but can execute armv6 code.
Assertion failed: (_mode == modeFinalAddress), function finalAddress, file /SourceCache/ld64/ld64-127.2/src/ld/ld.hpp, line 588.
0 0x100011c51 __assert_rtn + 81
1 0x10008d45c ld::tool::OutputFile::addressOf(ld::Internal const&, ld::Fixup const*, ld::Atom const**) + 172
2 0x10008f361 ld::tool::OutputFile::applyFixUps(ld::Internal&, unsigned long long, ld::Atom const*, unsigned char*) + 369
3 0x10008c3b7 ld::tool::OutputFile::writeOutputFile(ld::Internal&) + 807
4 0x100085079 ld::tool::OutputFile::write(ld::Internal&) + 153
5 0x1000121ab main + 1147
collect2: ld returned 1 exit status
That's Apple's provided linker crashing. That's uncommon and likely means it's being fed something corrupted.
You're showing the output of lipo on libscanditsdk-iphone-2.1.17.a but you're using [LinkWith] on libmeScanditWrapper.a. What happened between the two ?
Related
I'm using MXE to build my own cross-compiler toolchain (this specific version). Only I don't use the default gcc 5.5 but gcc 6.3.0 instead.
I'm not specifically tied to that version - I just picked it because it was also used to generate the latest portaudio binaries
It appears that for some reason, some MSVCRT symbols have been included in and are exported by the portaudio DLL:
dumpbin /exports libportaudio64bit.dll
992 3DF 00032F30 mbrlen
993 3E0 00032D90 mbrtowc
994 3E1 00032E00 mbsrtowcs
1112 457 00033180 wcrtomb
1113 458 000331C0 wcsrtombs
I only found out because I was trying to cross-compile and build bzip2 1.0.8
This is pretty old and it doesn't have all the infrastructure in place to support cross-compiling. However it can be done by hand in a couple of very simple steps:
make CC=x86_64-w64-mingw32.shared-gcc AR=x86_64-w64-mingw32.shared-ar RANLIB=x86_64-w64-mingw32.shared-ranlib libbz2.a
x86_64-w64-mingw32.shared-gcc *.o -s -shared -o libbz2-1.dll
Alike the portaudio DLLs, the above exports the same symbols:
dumpbin /exports libbz2-1.dll
36 23 00012B60 mbrlen
37 24 000129F0 mbrtowc
38 25 00012A60 mbsrtowcs
39 26 00012DC0 wcrtomb
40 27 00012E00 wcsrtombs
Needless to say, this is causing issues at link time, due to multiple definitions of the same symbol (mingw-w64-v8.0.0/mingw-w64-crt/misc/mbrtowc.c:98: multiple definition of 'mbrtowc' - x86_64-w64-mingw32.shared/lib/../lib/libmsvcrt.a(lib64_libmsvcrt_os_a-mbrtowc.o): first defined here)
My question is not how to avoid this issue. That can be done by using a DEF file when building the DLLs, to control the exact list of exported functions.
My question is more fundamental: why would these symbols be exported in the first place ? Is this a bug somewhere ?
I cannot link my program to pytorch under Linux, get the following error:
/tmp/ccbgkLx2.o: In function `long long* at::Tensor::data<long long>() const':
test.cpp:(.text._ZNK2at6Tensor4dataIxEEPT_v[_ZNK2at6Tensor4dataIxEEPT_v]+0x14): undefined reference to `long long* at::Tensor::data_ptr<long long>() const'
I am building a very simple minimal example:
#include "torch/script.h"
#include <iostream>
int main() {
auto options = torch::TensorOptions().dtype(torch::kInt64);
torch::NoGradGuard no_grad;
auto T = torch::zeros(20, options).view({ 10, 2 });
long long *data = (long long *)T.data<long long>();
data[0] = 1;
return 0;
}
The command used to build it:
g++ -w -std=c++17 -o test-torch test.cpp -D_GLIBCXX_USE_CXX11_ABI=1 -Wl,--whole-archive -ldl -lpthread -Wl,--no-whole-archive -I../libtorch/include -L../libtorch/lib -ltorch -ltorch_cpu -lc10 -Wl,-rpath,../libtorch/lib
Pytorch has been downloaded from the link https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcpu.zip and unzipped (so I have the libtorch folder next to the folder with test.cpp).
Any ideas how to solve this problem? Same program works just fine under Visual C++.
P.S. I know pytorch is kind of designed for cmake, but I have zero experience with cmake and no desire to write a cmake-based build system for my app. Also, the examples they give are seemingly supposed to only work if pytorch is "installed" in the system. So I cannot just download the .zip with libs? And if I "install" it (e.g. from sources or in whatever other way) on an AVX512 system, will the binary I link to it and distribute to end-users work on non-AVX512? The documentation is completely incomprehensible for newbies.
UPDATE: I tried to do this via CMake following the tutorial https://pytorch.org/cppdocs/installing.html and got exactly the same error. Specifically, I renamed my directory to example-app and the source file to example-app.cpp. Then I created CMakeLists.txt in this directory with the following contents:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example-app)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
add_executable(example-app example-app.cpp)
target_link_libraries(example-app "${TORCH_LIBRARIES}")
set_property(TARGET example-app PROPERTY CXX_STANDARD 14)
Then
mkdir build
cd build
cmake -DCMAKE_PREFIX_PATH=../../libtorch ..
cmake --build . --config Release
And here's the output:
CMakeFiles/example-app.dir/example-app.cpp.o: In function `long long* at::Tensor::data<long long>() const':
example-app.cpp:(.text._ZNK2at6Tensor4dataIxEEPT_v[_ZNK2at6Tensor4dataIxEEPT_v]+0x14): undefined reference to `long long* at::Tensor::data_ptr<long long>() const'
Makes me think, maybe I forgot to include some header or define some variable?
Oh, this is all on Mint 19.2 (equivalent to Ubuntu 18.04), g++ version is 7.5.0, glibc is 2.27. Compiling with g++-8 gives the same result.
This is not a cmake-related error, it's just how the library was implemented. I do not know why, but it appears that the specialization of T* at::Tensor::data<T> const with T = long long was forgotten/omitted.
If you want to get your signed 64-bits pointer, you can still get it with int64_t:
auto data = T.data<int64_t>();
It's good practice to use these types for which the size is explicit in general, in order to avoid compatibility issues.
Here are some details:
Host/Test OS, Toolchain:
Linux Mint 19.3 Tricia (Ubuntu 18.04), GCC 7
V8 GN build arguments:
is_debug=true
target_os="linux"
target_cpu="x64"
is_clang = false
is_component_build=false
use_glib=false
use_custom_libcxx = false
v8_static_library=true
v8_enable_i18n_support=false
v8_use_external_startup_data=false
The v8 engine is successfully built and I got all expected static libraries. Then I tried to build Hello_World app (provided in v8 source), linking with generated static libs. I got the following linking errors:
/usr/bin/g++-7 -o ./build-Debug/bin/Hello_World #./build-Debug//ObjectsList.txt -L. -L../../out.gn/linux.x86_64.Debug -L../../out.gn/linux.x86_64.Debug/obj -L../../out.gn/linux.x86_64.Debug/obj/tools/debug_helper -L../../out.gn/linux.x86_64.Debug/obj/third_party/zlib -L../../out.gn/linux.x86_64.Debug/obj/third_party/zlib/google -lv8_libbase -lv8_libplatform -lv8_base_without_compiler -lv8_bigint -lv8_compiler_opt -lv8_compiler -lv8_cppgc_shared -lv8_debug_helper -lv8_init -lv8_initializers -lv8_snapshot -lchrome_zlib -ltorque_base -ltorque_ls_base -ltorque_generated_initializers -ltorque_generated_definitions -lwee8 -lcompression_utils_portable -lpthread
../../out.gn/linux.x86_64.Debug/obj/torque_generated_initializers/promise-misc-tq-csa.o: In function `v8::internal::PromiseInit_0(v8::internal::compiler::CodeAssemblerState*, v8::internal::TNode<v8::internal::JSPromise>)':
/media/hongkun/Windows/Users/hongkun/v8/v8/out.gn/linux.x86_64.Debug/gen/torque-generated/src/builtins/promise-misc-tq-csa.cc:297: undefined reference to `v8::internal::PromiseBuiltinsAssembler::ZeroOutEmbedderOffsets(v8::internal::TNode<v8::internal::JSPromise>)'
../../out.gn/linux.x86_64.Debug/obj/torque_generated_initializers/promise-misc-tq-csa.o: In function `v8::internal::InnerNewJSPromise_0(v8::internal::compiler::CodeAssemblerState*, v8::internal::TNode<v8::internal::Context>)':
/media/hongkun/Windows/Users/hongkun/v8/v8/out.gn/linux.x86_64.Debug/gen/torque-generated/src/builtins/promise-misc-tq-csa.cc:377: undefined reference to `v8::internal::PromiseBuiltinsAssembler::AllocateJSPromise(v8::internal::TNode<v8::internal::Context>)'
../../out.gn/linux.x86_64.Debug/obj/torque_generated_initializers/promise-misc-tq-csa.o: In function `v8::internal::NewJSPromise_2(v8::internal::compiler::CodeAssemblerState*, v8::internal::TNode<v8::internal::Context>, v8::Promise::PromiseState, v8::internal::TNode<v8::internal::Object>)':
/media/hongkun/Windows/Users/hongkun/v8/v8/out.gn/linux.x86_64.Debug/gen/torque-generated/src/builtins/promise-misc-tq-csa.cc:1143: undefined reference to `v8::internal::PromiseBuiltinsAssembler::ZeroOutEmbedderOffsets(v8::internal::TNode<v8::internal::JSPromise>)'
Obviously, linker cannot find the class v8::internal::PromiseBuiltinsAssembler in any of the provided libraries. I have added all generated v8 libraries in the linker options.
How can I fix this error? Thanks for any suggestions.
Neither PromiseBuiltinsAssembler nor promise-misc-tq-csa.o should go into final binaries, both are only used by mksnapshot.
Have you tried following the official documentation?
Recently I decided to retry building a CLFS machine http://www.clfs.org and am at step 5.5 of 3.0.0 SYSTEMD. We are told to run make -C include and then make -C progs tic. I am failing at the last command. Am I missing any packages, or am I doing something wrong?
I am using ArchLinux as my CLFS host in VMWare which is running on Windows 10.
Here is the page I am looking at for the commands: http://clfs.org/files/BOOK/3.0.0/SYSTEMD/view/x86_64/cross-tools/ncurses.html
Here is the output from the console when I run that last command:
In file included from ../ncurses/curses.priv.h:283:0,
from ../ncurses/lib_gen.c:19:_33528.c:835:15: error: expected ')' before 'int'
../include/curses.h:1594:56: note: in definition of macro 'mouse_trafo'
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
^
The error message is pointing to the y symbol,
which could be (mis)defined in some header file on your system.
aside from stray #define's, the only interesting thing about the line is that the prototype for wmouse_trafo uses bool, which the configure script should have (given the compiler version used for CLFS) equated to a c99 _Bool (which should not be a problem).
You can see what the compiler sees by doing
make -C ncurses lib_gen.i
and looking for wmouse_trafo in ncurses/lib_gen.i.
For example, I see it mentioned twice:
extern _Bool wmouse_trafo (const WINDOW*, int*, int*, _Bool);
extern _Bool mouse_trafo (int*, int*, _Bool);
and
_Bool (mouse_trafo) (int * a1, int * a2, _Bool z)
{
; return wmouse_trafo(stdscr,a1,a2,z);
}
The stray semicolon is not a problem, but if there were some problem with the cross-compiler it might make the _Bool missing.
The instructions for CLFS 3.0 use gcc 4.8.3 (versions of all of the parts do matter). However, the error message cited here looks like a recent report due to gcc 5 — which is addressed in ncurses 6.0
I have a problem with a shared library (Linux) and a program that links against this library but does not find the symbols - although they are there. That's what I have:
A shared library "libetest.so" that is located in /usr/lib. When I do an
readelf -Ws /usr/lib/libetest.so.0
it gives (beside some others) this output:
54: 000052c0 905 FUNC LOCAL DEFAULT 11 ETEST_open_connection
Now I have an application that makes use of ETEST_open_connection(). When I build it with
gcc lib_test.cpp -DENV_LINUX -letest
it fails with a linker error
lib_test.cpp:(.text+0x32): undefined reference to `ETEST_open_connection'
As shown before the symbol is there! Any idea why this fails?
Please try:
gcc -DENV_LINUX -letest lib_test.cpp
This should be the correct argument order.