cross compilation of opencv for arm - arm

I am a newbie to ARM. I am trying to cross compile opencv 2.3.1 for ARM9 board with linux 2.3
After generating a cmake file when i make i get the error as follows
Desktop/opencv/OpenCV-2.3.1/modules/flann/include/opencv2/flann/dist.h: In function 'T cvflann::abs(T) [with T = long double]':
OpenCV-2.3.1/modules/flann/include/opencv2/flann/dist.h:63: error: 'fabsl' was not declared in this scope
make[2]: * [modules/flann/CMakeFiles/opencv_flann.dir/src/precomp.obj] Error 1
make[1]: * [modules/flann/CMakeFiles/opencv_flann.dir/all] Error 2
make: * [all] Error 2
Thanx all

double and long double are the same on ARM. It looks like fabsl was just removed from libstdc++.
I had the same problem when compiling for my ARM board. Replace fabsl() with fabs() in
/OpenCV-2.3.1/modules/flann/include/opencv2/flann/dist.h
This gets things compiling, I have not tested the build yet as I am still cross compiling some other deps first. Good luck!
John

Related

Unable to compile SDL2 for obscure reasons

I don't know if the current SDL code source is reliable (normally it is), but here is what I got when I try to compile it by myself.
/usr/include/spa-0.2/spa/utils/string.h: In "spa_strtod" function:
/usr/include/spa-0.2/spa/utils/string.h:325:9: error: ISO C90 prohibits mixing declarations and code [-Werror=declaration-after-statement]
325 | locale_t prev = uselocale(locale);
| ^~~~~~~~
cc1: some warnings are treated as errors
make: *** [Makefile:627:build/SDL_pipewire.lo] Error 1
I'm on Arch, I'm using gcc as C/C++ compiler. Please help me because I need to recompile SDL myself to maybe solve another problem I got with the library.

How to add linker flags in CLion [duplicate]

This question already has answers here:
How to add "-l" (ell) compiler flag in CMake
(2 answers)
Closed 3 years ago.
Im trying to use libsodium, ive installed the librarys and trying to make the simplests of tests, when making the project using Makefile there are no probkems but when using CLion and Cmake i get "undefined reference to `sodium_init'"
Im working on Ubuntu 18.04.
I found the reason for the error was the need to link to add the -lsodium flag to the linking (adding the flag makes a normal Makefile work)
as i searched the web for ways to link to an external library using CMake or in CLion i found many solutions that did not work, including :
add_link_options(-lsodium)
set (CMAKE_STATIC_LINKER_FLAGS "-lsodium")
this is the code im trying to compile:
#include <stdio.h>
#include <sodium.h>
int main()
{
if (sodium_init() < 0)
{
printf("sodium init error");
}
__uint32_t rand = randombytes_random();
printf("hello %d, this is a random number \n", &rand);
return 0;
}
The full error message in CLion looks like this :
MakeFiles/TestC.dir/main.c.o: In function `main':
/home/--username--/Projects/TestC/main.c:7: undefined reference to `sodium_init'
collect2: error: ld returned 1 exit status
CMakeFiles/TestC.dir/build.make:83: recipe for target 'TestC' failed
make[3]: *** [TestC] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/TestC.dir/all' failed
make[2]: *** [CMakeFiles/TestC.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/TestC.dir/rule' failed
make[1]: *** [CMakeFiles/TestC.dir/rule] Error 2
Makefile:118: recipe for target 'TestC' failed
make: *** [TestC] Error 2
EDIT:
Ive solved the problem, after looking at - https://stackoverflow.com/a/43136754/7276240
I added the following line to my CMakeLists.txt:
target_link_libraries(TestC libsodium.a)
TestC being the name of the executable.
You can use the usual find_package() or find_library() CMake commands and link it with target_link_libraries(). If you don't want to specify the path manually, there already is a Findsodium.cmake in the official repository. Here is one random example of a CMakeLists.txt found on Github.

GDK cross compilation error

I have cross-compiled libpng 1.6.28, libjpeg-turbo 1.5.1 and GLib 2.50.3 for MS Windows with i686-w64-mingw32 on Debian Stretch to a special folder, but still can't get gdk-pixbuf working. My commandline used for configure is:
./configure --host=i686-w64-mingw32 PKG_CONFIG_PATH=/usr/local/mingw32-i686/lib/pkgconfig --prefix=/usr/local/mingw32-i686
It passes the configure part fine, but problems start at making point. It throws the following error:
/usr/local/mingw32-i686/lib/libgio-2.0.a(libgio_2_0_la-giomodule.o): In function `DllMain#12':
/home/maju/GTK-build/glib-2.50.3/gio/giomodule.c:942: multiple definition of `DllMain#12'
./.libs/libgdk_pixbuf-2.0.a(libgdk_pixbuf_2_0_la-gdk-pixbuf-io.o):gdk-pixbuf-io.c:(.text+0x1ca): first defined here
collect2: error: ld returned 1 exit status
Makefile:1859: polecenia dla obiektu 'gdk-pixbuf-csource.exe' nie powiodły się
(last line is just untranslated error message for gdk-pixbuf-csource.exe).
It's also followed by warning messages:
*** Warning: This system cannot link to static lib archive libgdk_pixbuf-2.0.la.
*** I have the capability to make that library automatically link in when
*** you link to this library. But I can only do this if you have a
*** shared version of the library, which you do not appear to have.
*** But as you try to build a module library, libtool will still create
*** a static module, that should work as long as the dlopening application
*** is linked with the -dlopen flag to resolve symbols at runtime.
for every required library.
Can anyone explain it to me?
the DllMain might mean “glib for doze doesn’t build static right”
this patch
https://lists.fedoraproject.org/pipermail/mingw/2013-March/006441.html
still applies for later versions of glib. lame.
updated version of patch https://bugzilla.redhat.com/show_bug.cgi?id=1306047
https://bugzilla.redhat.com/attachment.cgi?id=1122789 is seemingly final version of that patch, see
https://smani.fedorapeople.org/glib-prefer-constructors-over-DllMain.patch
Not sure about the cannot link, I configure glib for cross compile like --host=i686-w64-mingw32 --prefix=/Users/rdp/dev/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32 --disable-shared --enable-static --with-pcre=internal
FWIW

Error compiling the Linux kernel 3.19.0-25-generic

I try to execute fakeroot debian/rules binary-headers binary-genericand compile when building kernel but get the error.
Here error in below
arch/x86/built-in.o:(.rodata+0x1cb8): undefined reference to 'sys_monlak'
make[2]: *** [vmlinux] Error 1
make[2]: Leaving directory '/home/su/linux-lts-vivid-3.19.0/debian/build/build-generic'
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory '/home/su/linux-lts-vivid-3.19.0'
make: *** [/home/su/linux-lts-vivid-3.19.0/debian/stamps/stamp-build-generic] Error 2
I tried to build kernel following Build your own kernel and Clarkson.edu
I don't see any reference to the symbol "sys_monlak" inside any branch of the official Linux kernel. Are you using a branch obtained from somewhere else?
This error would happen if a driver depends on a symbol "sys_monlak" which should be defined elsewhere in the kernel but isn't, or perhaps the correct kernel module isn't enabled in the kernel config.
You can try running:
$ grep -R "sys_monlak"
If this produces a c file then you can then try to find the Makefile which should compile in this c file. If, for example, the file was called "arch/x86/monlak.c" you might find the following in the file "arch/x86/Makefile":
obj-$(CONFIG_MONLAK) += monlak.o
In this case you would want to try to enable CONFIG_MONLAK in the kernel config.
The other possibility is that you might want to disable the module that depends on the symbol 'sys_monlak'. Try to carefully read the description in the Kconfig file to see what each module does (the one that depends and the one that provides).

Adding fpirntf() into xnu kernel tcp_xxx.c, stdio.h not found

Greeting everyone on stackoverflow!
I am trying to add fpirntf() to XNU kernel tcp_xxx.c file, so when TCP moves it can print parameters to a file, for better understanding how TCP works, but fatal error occurs like follows:
$ sudo make ARCH_CONFIGS=X86_64 KERNEL_CONFIGS=DEBUG
CC tcp_output.o
/Users/wangweikai/Desktop/xnubuilder/xnu-2422.90.20/bsd/netinet/tcp_output.c:135:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^
1 error generated.
make[7]: *** [tcp_output.o] Error 1
make[6]: *** [build_all] Error 2
make[5]: *** [do_all] Error 2
make[4]: *** [build_all] Error 2
make[3]: *** [build_all_recurse_into_conf] Error 2
make[2]: *** [build_all_recurse_into_bsd] Error 2
make[1]: *** [build_all_bootstrap_DEBUG^X86_64^NONE] Error 2
make: *** [all] Error 2
It looks there is no stdio.h in xnu source code, to solve this I re-installed xcode 5.0.2(only this works with xnu-2422) and outputs mach_kernel able to boot; I tried install command line tools by "xcode-select --install" in terminal, but not working neither.
BTW if I add printf() without #include it gives no error, it looks print function is defined by file with name other than stdio.h.
Since my point is to log how TCP parameters(such as congestion window size and next sequence number and so on)changes in a file, so if there is any way can do this please also tell me, I am total new to xnu and C programming.
Best regards.
Standard I/O (i.e, stdio) is not available in the kernel. To output debugging information from the kernel, call printf(); its output will be visible in the kernel log. Writing data to files directly from the kernel is complicated, and is rarely advisable. (In this case, it may in fact lead to hard lockups, e.g, if the file being written to is on a network volume!)
If you are new to C programming, this is not a good first project. Kernel development is difficult, unforgiving stuff, particularly for the XNU kernel; errors will often cause your computer to crash, potentially losing data, and debugging services are often not available. If you have your heart set on examining an OS kernel, though, the Linux kernel is much easier to work with — it can be easily booted and debugged in a virtual machine, and is far better documented.

Resources